Your Perfect Assignment is Just a Click Away

Starting at $8.00 per Page

100% Original, Plagiarism Free, Customized to Your instructions!


DS 715 UW Milwaukee Class for The Cars Dataset Python OOP Project

DS 715 UW Milwaukee Class for The Cars Dataset Python OOP Project

Question Description

Part 1 – Create a class for the Cars dataset

At the bottom of part 1 is a code cell. This is where you write your class. First, read steps 1 and 2, then write your class.

Step 1 – Initialize the following 2 instance variables:

Notice, they are prefixed with the keyword self.

  • self.all_cars_by_make – make this a dictionary. Recall, dictionaries consist of keys and values. The keys in this dictionary will be car ‘makes’. The value of each key will be a single list of multiple dictionaries – with each dictionary containing the fields in step 2 for every model_id of that make.
  • self.all_cars_list – make this a list. This will be a list of lists. Each sub-list is for a distinct model_id, and contains the fields in step 2.

In the code cell at the bottom of part 1, we have defined the variables for you. But you must populate them (step 2).

Step 2 – Populate both containers (from step 1) with values for the following fields:

  • Model_year
  • Model_id
  • year
  • horsepower
  • highway_mpg
  • city_mpg
  • width
  • hybrid

Add logic for step 2 in the code cell below:

Notice, the class is already partially written to help guide your thinking.

Create 4 methods to accomplish tasks 1 – 4 below:

You will use these methods in part 3 to answer questions.

1. Find the number of model ID‘s for a given make.

  • Call this method “find_model_id
  • Argument: Make (string)
  • Return: 1 tuple of 2 elements –
    • Element 1: count of model IDs for a given Make
    • Element 2: list of model IDs for a given Make
  • Example method call: num_ids, chevy_model_ids = carsdata.find_model_id(“Chevrolet”)

2. Retrieve maximum horsepower for a list of model ids.

  • Call this method “find_max_horsepower
  • Argument: Model_ids (list)
  • Return: 1 tuple of 2 elements –
    • Element 1: max horsepower
    • Element 2: list of model ids that have the max horsepower
  • Example method call: chevy_hp, chevy_hp_models = carsdata.find_max_horsepower(chevy_model_ids)

3. Calculate the highest city-mpg to highway-mpg ratio for given Make.

  • Call this method “find_mpgratio
  • Argument: Make (string)
  • Return: 1 tuple of 2 elements –
    • Element 1: Maximum/highest city-to-highway mpg ratio for a given make
    • Element 2: list of model IDs that have the max ratio above
  • Example method call: chevy_mpg_ratio, chevy_mpg_models = carsdata.find_mpgratio(“Chevrolet”)
  • Note: make sure you convert both mpg (highway and city) to float before calculating.

4. Calculate the number of hybrid model ids for a given year.

  • Call this method “count_hybrid
  • Argument: Year (integer)
  • Return (1 value): Count of hybrid model_ids
  • Example method call: count_hybrid_2009 = carsdata.count_hybrid(2009)
  • Note: The Cars data has limited years.

Important notes

  • Add these methods to your class in the code cell from part 1.
  • For the purposes of this assignment, every method has the self parameter.
  • Do not be alarmed when you see text prefixed by ‘u’. This stands for unicode, which is the default string type in Python3. Strings meant to be human-readable should always be in unicode.
  • Make sure that your methods account for ties.
  • ?? After creating the class, first test it with the sample dataset (instantiate an object with ‘cars_truncated.json’).
  • ?? If everything works, then test it on the full dataset.

With regard to this assignment, try to avoid the following:

  • Any unnecessary iteration
  • Nested loops. Such as to loop through the entire all_cars_list for every model_id.
  • String manipulation (not needed here)
  • Creating excessive containers and assignment operations

Use your class and methods to answer the questions below.

1. How many Audi model_ids are in this dataset, and what are the models?

2. Which Audi model has the most horsepower? Use your second method to find this answer.

3. Find the model with the highest city-to-highway mpg for Chevrolet. Print the ratio and model(s) that have this ratio.

4. How many hybrid cars were produced in 2009? How many in 2011?

"Place your order now for a similar assignment and have exceptional work written by our team of experts, guaranteeing you A results."

Order Solution Now

Our Service Charter

1. Professional & Expert Writers: Eminence Papers only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed of papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by Eminence Papers are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Eminence Papers are known for the timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit in all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Eminence Papers, we have put in place a team of experts who answer all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.