Data-Informed Thinking + Doing

Regression With Implementation Ease

Predicting car MSRP for high interpretability—using regression trees in R, Python, and Julia.

Classification and Regression Trees (CART) are decision tree algorithms used for both classification and regression tasks. In particular, regression Trees are valuable for predicting numerical outcomes, like housing prices, stock prices, or sales forecasts. They provide interpretable models, allowing us to understand the impact of predictors on the target variable, making them essential for accurate and transparent predictions in regression problems.

Like Classification Trees, the significance of Regression Trees lies in their ability to model non-linear relationships between input variables and continuous target variables. They recursively split data into homogenous segments, predicting the average response within each segment.

Let’s examine this technique by using the Edmunds car dataset.

Getting Started

If you are interested in reproducing this work, here are the versions of R, Python, and Julia used (as well as the respective packages for each). Additionally, Leland Wilkinson’s approach to data visualization (Grammar of Graphics) has been adopted for this work. Finally, my coding style here is verbose, in order to trace back where functions/methods and variables are originating from, and make this a learning experience for everyone—including me.

cat(R.version$version.string, R.version$nickname)
R version 4.2.3 (2023-03-15) Shortstop Beagle
require(devtools)
devtools::install_version("dplyr", version="1.1.2", repos="http://cran.us.r-project.org")
devtools::install_version("ggplot2", version="3.4.2", repos="http://cran.us.r-project.org")
library(dplyr)
library(ggplot2)
import sys
print(sys.version)
3.11.4 (v3.11.4:d2340ef257, Jun  6 2023, 19:15:51) [Clang 13.0.0 (clang-1300.0.29.30)]
!pip install pandas==2.0.3
!pip install plotnine==0.12.1
import pandas
import plotnine
using InteractiveUtils
InteractiveUtils.versioninfo()
Julia Version 1.9.2
Commit e4ee485e909 (2023-07-05 09:39 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin22.4.0)
  CPU: 8 × Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, skylake)
  Threads: 1 on 8 virtual cores
Environment:
  DYLD_FALLBACK_LIBRARY_PATH = /Library/Frameworks/R.framework/Resources/lib:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/server
using Pkg
Pkg.add(name="CSV", version="0.10.11")
Pkg.add(name="DataFrames", version="1.5.0")
Pkg.add(name="CategoricalArrays", version="0.10.8")
Pkg.add(name="Colors", version="0.12.10")
Pkg.add(name="Cairo", version="1.0.5")
Pkg.add(name="Gadfly", version="1.3.4")
using CSV
using DataFrames
using CategoricalArrays
using Colors
using Cairo
using Gadfly

Importing and Examining Dataset

cars_r <- read.csv("../../dataset/cars-edmunds.csv", stringsAsFactors=TRUE)
utils::str(object=cars_r)
'data.frame':	11914 obs. of  16 variables:
 $ make             : Factor w/ 48 levels "Acura","Alfa Romeo",..: 6 6 6 6 6 6 6 6 6 6 ...
 $ model            : Factor w/ 915 levels "1 Series","1 Series M",..: 2 1 1 1 1 1 1 1 1 1 ...
 $ year             : int  2011 2011 2011 2011 2011 2012 2012 2012 2012 2013 ...
 $ engine_fuel_type : Factor w/ 11 levels "","diesel","electric",..: 10 10 10 10 10 10 10 10 10 10 ...
 $ engine_hp        : int  335 300 300 230 230 230 300 300 230 230 ...
 $ engine_cylinders : int  6 6 6 6 6 6 6 6 6 6 ...
 $ transmission_type: Factor w/ 5 levels "AUTOMATED_MANUAL",..: 4 4 4 4 4 4 4 4 4 4 ...
 $ wheels_driven    : Factor w/ 4 levels "all wheel drive",..: 4 4 4 4 4 4 4 4 4 4 ...
 $ doors_number     : int  2 2 2 2 2 2 2 2 2 2 ...
 $ market_category  : Factor w/ 72 levels "Crossover","Crossover,Diesel",..: 39 68 65 68 64 68 68 65 64 64 ...
 $ vehicle_size     : Factor w/ 3 levels "Compact","Large",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ vehicle_style    : Factor w/ 16 levels "2dr Hatchback",..: 9 7 9 9 7 9 7 9 7 7 ...
 $ mpg_highway      : int  26 28 28 28 28 28 26 28 28 27 ...
 $ mpg_city         : int  19 19 20 18 18 18 17 20 18 18 ...
 $ popularity       : int  3916 3916 3916 3916 3916 3916 3916 3916 3916 3916 ...
 $ msrp             : int  46135 40650 36350 29450 34500 31200 44100 39300 36900 37200 ...
utils::head(x=cars_r, n=8)
  make      model year            engine_fuel_type engine_hp engine_cylinders transmission_type    wheels_driven doors_number                       market_category vehicle_size vehicle_style mpg_highway mpg_city popularity  msrp
1  BMW 1 Series M 2011 premium unleaded (required)       335                6            MANUAL rear wheel drive            2 Factory Tuner,Luxury,High-Performance      Compact         Coupe          26       19       3916 46135
2  BMW   1 Series 2011 premium unleaded (required)       300                6            MANUAL rear wheel drive            2                    Luxury,Performance      Compact   Convertible          28       19       3916 40650
3  BMW   1 Series 2011 premium unleaded (required)       300                6            MANUAL rear wheel drive            2               Luxury,High-Performance      Compact         Coupe          28       20       3916 36350
4  BMW   1 Series 2011 premium unleaded (required)       230                6            MANUAL rear wheel drive            2                    Luxury,Performance      Compact         Coupe          28       18       3916 29450
5  BMW   1 Series 2011 premium unleaded (required)       230                6            MANUAL rear wheel drive            2                                Luxury      Compact   Convertible          28       18       3916 34500
6  BMW   1 Series 2012 premium unleaded (required)       230                6            MANUAL rear wheel drive            2                    Luxury,Performance      Compact         Coupe          28       18       3916 31200
7  BMW   1 Series 2012 premium unleaded (required)       300                6            MANUAL rear wheel drive            2                    Luxury,Performance      Compact   Convertible          26       17       3916 44100
8  BMW   1 Series 2012 premium unleaded (required)       300                6            MANUAL rear wheel drive            2               Luxury,High-Performance      Compact         Coupe          28       20       3916 39300
which(is.na(cars_r))
  [1]  48196  48197  48198  50562  50563  50564  50565  51860  51861  51862  51863  52362  52363  52442  52446  52455  52571  52572  52573  52574  52575  52576  53435  53482  53487  53488  53490  53496  53497  54042  54043  54044  54045  54046  54047  54048  54049  54050  54051  54235  54565  54567  54573  54575  54578  54579  54580  54581  54582  54583  54584  54585  54586  54587  54588  54589  54590  54591  54592  54593  54594  54595  56031  56032  57507  57508  57509  57510  57511  61554  61555  63287  63288  63289  63290  65349  65350  65351  67944  68266  68267  68268  68269  68270  68271  68272  68273  68274  68275  68276  68277  68278  68279  68280  68281  68282  68283  68284  68285  99979 102243 102244 102245 102246 102247
cars_py = pandas.read_csv("../../dataset/cars-edmunds.csv")
cars_py.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 11914 entries, 0 to 11913
Data columns (total 16 columns):
 #   Column             Non-Null Count  Dtype  
---  ------             --------------  -----  
 0   make               11914 non-null  object 
 1   model              11914 non-null  object 
 2   year               11914 non-null  int64  
 3   engine_fuel_type   11911 non-null  object 
 4   engine_hp          11845 non-null  float64
 5   engine_cylinders   11884 non-null  float64
 6   transmission_type  11914 non-null  object 
 7   wheels_driven      11914 non-null  object 
 8   doors_number       11908 non-null  float64
 9   market_category    8172 non-null   object 
 10  vehicle_size       11914 non-null  object 
 11  vehicle_style      11914 non-null  object 
 12  mpg_highway        11914 non-null  int64  
 13  mpg_city           11914 non-null  int64  
 14  popularity         11914 non-null  int64  
 15  msrp               11914 non-null  int64  
dtypes: float64(3), int64(5), object(8)
memory usage: 1.5+ MB
cars_py.head(n=8)
  make       model  year             engine_fuel_type  engine_hp  engine_cylinders transmission_type     wheels_driven  doors_number                        market_category vehicle_size vehicle_style  mpg_highway  mpg_city  popularity   msrp
0  BMW  1 Series M  2011  premium unleaded (required)      335.0               6.0            MANUAL  rear wheel drive           2.0  Factory Tuner,Luxury,High-Performance      Compact         Coupe           26        19        3916  46135
1  BMW    1 Series  2011  premium unleaded (required)      300.0               6.0            MANUAL  rear wheel drive           2.0                     Luxury,Performance      Compact   Convertible           28        19        3916  40650
2  BMW    1 Series  2011  premium unleaded (required)      300.0               6.0            MANUAL  rear wheel drive           2.0                Luxury,High-Performance      Compact         Coupe           28        20        3916  36350
3  BMW    1 Series  2011  premium unleaded (required)      230.0               6.0            MANUAL  rear wheel drive           2.0                     Luxury,Performance      Compact         Coupe           28        18        3916  29450
4  BMW    1 Series  2011  premium unleaded (required)      230.0               6.0            MANUAL  rear wheel drive           2.0                                 Luxury      Compact   Convertible           28        18        3916  34500
5  BMW    1 Series  2012  premium unleaded (required)      230.0               6.0            MANUAL  rear wheel drive           2.0                     Luxury,Performance      Compact         Coupe           28        18        3916  31200
6  BMW    1 Series  2012  premium unleaded (required)      300.0               6.0            MANUAL  rear wheel drive           2.0                     Luxury,Performance      Compact   Convertible           26        17        3916  44100
7  BMW    1 Series  2012  premium unleaded (required)      300.0               6.0            MANUAL  rear wheel drive           2.0                Luxury,High-Performance      Compact         Coupe           28        20        3916  39300
cars_py.tail(n=8)
          make   model  year                engine_fuel_type  engine_hp  engine_cylinders transmission_type      wheels_driven  doors_number             market_category vehicle_size  vehicle_style  mpg_highway  mpg_city  popularity   msrp
11906    Acura     ZDX  2011     premium unleaded (required)      300.0               6.0         AUTOMATIC    all wheel drive           4.0  Crossover,Hatchback,Luxury      Midsize  4dr Hatchback           23        16         204  46020
11907    Acura     ZDX  2011     premium unleaded (required)      300.0               6.0         AUTOMATIC    all wheel drive           4.0  Crossover,Hatchback,Luxury      Midsize  4dr Hatchback           23        16         204  56570
11908    Acura     ZDX  2011     premium unleaded (required)      300.0               6.0         AUTOMATIC    all wheel drive           4.0  Crossover,Hatchback,Luxury      Midsize  4dr Hatchback           23        16         204  50520
11909    Acura     ZDX  2012     premium unleaded (required)      300.0               6.0         AUTOMATIC    all wheel drive           4.0  Crossover,Hatchback,Luxury      Midsize  4dr Hatchback           23        16         204  46120
11910    Acura     ZDX  2012     premium unleaded (required)      300.0               6.0         AUTOMATIC    all wheel drive           4.0  Crossover,Hatchback,Luxury      Midsize  4dr Hatchback           23        16         204  56670
11911    Acura     ZDX  2012     premium unleaded (required)      300.0               6.0         AUTOMATIC    all wheel drive           4.0  Crossover,Hatchback,Luxury      Midsize  4dr Hatchback           23        16         204  50620
11912    Acura     ZDX  2013  premium unleaded (recommended)      300.0               6.0         AUTOMATIC    all wheel drive           4.0  Crossover,Hatchback,Luxury      Midsize  4dr Hatchback           23        16         204  50920
11913  Lincoln  Zephyr  2006                regular unleaded      221.0               6.0         AUTOMATIC  front wheel drive           4.0                      Luxury      Midsize          Sedan           26        17          61  28995
cars_jl = CSV.File("../../dataset/cars-edmunds.csv") |> DataFrames.DataFrame
11914×16 DataFrame
   Row │ make           model       year   engine_fuel_type                engine_hp  engine_cylinders  transmission_type  wheels_driven      doors_number  market_category                    vehicle_size  vehicle_style  mpg_highway  mpg_city  popularity  msrp
       │ String15       String      Int64  String?                         Int64?     Int64?            String31           String31           Int64?        String                             String7       String31       Int64        Int64     Int64       Int64
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
     1 │ BMW            1 Series M   2011  premium unleaded (required)           335                 6  MANUAL             rear wheel drive              2  Factory Tuner,Luxury,High-Perfor…  Compact       Coupe                   26        19        3916   46135
     2 │ BMW            1 Series     2011  premium unleaded (required)           300                 6  MANUAL             rear wheel drive              2  Luxury,Performance                 Compact       Convertible             28        19        3916   40650
     3 │ BMW            1 Series     2011  premium unleaded (required)           300                 6  MANUAL             rear wheel drive              2  Luxury,High-Performance            Compact       Coupe                   28        20        3916   36350
     4 │ BMW            1 Series     2011  premium unleaded (required)           230                 6  MANUAL             rear wheel drive              2  Luxury,Performance                 Compact       Coupe                   28        18        3916   29450
     5 │ BMW            1 Series     2011  premium unleaded (required)           230                 6  MANUAL             rear wheel drive              2  Luxury                             Compact       Convertible             28        18        3916   34500
     6 │ BMW            1 Series     2012  premium unleaded (required)           230                 6  MANUAL             rear wheel drive              2  Luxury,Performance                 Compact       Coupe                   28        18        3916   31200
     7 │ BMW            1 Series     2012  premium unleaded (required)           300                 6  MANUAL             rear wheel drive              2  Luxury,Performance                 Compact       Convertible             26        17        3916   44100
     8 │ BMW            1 Series     2012  premium unleaded (required)           300                 6  MANUAL             rear wheel drive              2  Luxury,High-Performance            Compact       Coupe                   28        20        3916   39300
     9 │ BMW            1 Series     2012  premium unleaded (required)           230                 6  MANUAL             rear wheel drive              2  Luxury                             Compact       Convertible             28        18        3916   36900
    10 │ BMW            1 Series     2013  premium unleaded (required)           230                 6  MANUAL             rear wheel drive              2  Luxury                             Compact       Convertible             27        18        3916   37200
    11 │ BMW            1 Series     2013  premium unleaded (required)           300                 6  MANUAL             rear wheel drive              2  Luxury,High-Performance            Compact       Coupe                   28        20        3916   39600
    12 │ BMW            1 Series     2013  premium unleaded (required)           230                 6  MANUAL             rear wheel drive              2  Luxury,Performance                 Compact       Coupe                   28        19        3916   31500
    13 │ BMW            1 Series     2013  premium unleaded (required)           300                 6  MANUAL             rear wheel drive              2  Luxury,Performance                 Compact       Convertible             28        19        3916   44400
    14 │ BMW            1 Series     2013  premium unleaded (required)           230                 6  MANUAL             rear wheel drive              2  Luxury                             Compact       Convertible             28        19        3916   37200
    15 │ BMW            1 Series     2013  premium unleaded (required)           230                 6  MANUAL             rear wheel drive              2  Luxury,Performance                 Compact       Coupe                   28        19        3916   31500
    16 │ BMW            1 Series     2013  premium unleaded (required)           320                 6  MANUAL             rear wheel drive              2  Luxury,High-Performance            Compact       Convertible             25        18        3916   48250
    17 │ BMW            1 Series     2013  premium unleaded (required)           320                 6  MANUAL             rear wheel drive              2  Luxury,High-Performance            Compact       Coupe                   28        20        3916   43550
    18 │ Audi           100          1992  regular unleaded                      172                 6  MANUAL             front wheel drive             4  Luxury                             Midsize       Sedan                   24        17        3105    2000
    19 │ Audi           100          1992  regular unleaded                      172                 6  MANUAL             front wheel drive             4  Luxury                             Midsize       Sedan                   24        17        3105    2000
    20 │ Audi           100          1992  regular unleaded                      172                 6  AUTOMATIC          all wheel drive               4  Luxury                             Midsize       Wagon                   20        16        3105    2000
    21 │ Audi           100          1992  regular unleaded                      172                 6  MANUAL             front wheel drive             4  Luxury                             Midsize       Sedan                   24        17        3105    2000
    22 │ Audi           100          1992  regular unleaded                      172                 6  MANUAL             all wheel drive               4  Luxury                             Midsize       Sedan                   21        16        3105    2000
    23 │ Audi           100          1993  regular unleaded                      172                 6  MANUAL             front wheel drive             4  Luxury                             Midsize       Sedan                   24        17        3105    2000
    24 │ Audi           100          1993  regular unleaded                      172                 6  AUTOMATIC          all wheel drive               4  Luxury                             Midsize       Wagon                   20        16        3105    2000
    25 │ Audi           100          1993  regular unleaded                      172                 6  MANUAL             front wheel drive             4  Luxury                             Midsize       Sedan                   24        17        3105    2000
    26 │ Audi           100          1993  regular unleaded                      172                 6  MANUAL             front wheel drive             4  Luxury                             Midsize       Sedan                   24        17        3105    2000
    27 │ Audi           100          1993  regular unleaded                      172                 6  MANUAL             all wheel drive               4  Luxury                             Midsize       Sedan                   21        16        3105    2000
    28 │ Audi           100          1994  regular unleaded                      172                 6  AUTOMATIC          front wheel drive             4  Luxury                             Midsize       Wagon                   21        16        3105    2000
    29 │ Audi           100          1994  regular unleaded                      172                 6  MANUAL             all wheel drive               4  Luxury                             Midsize       Sedan                   22        16        3105    2000
    30 │ Audi           100          1994  regular unleaded                      172                 6  MANUAL             front wheel drive             4  Luxury                             Midsize       Sedan                   22        17        3105    2000
    31 │ Audi           100          1994  regular unleaded                      172                 6  AUTOMATIC          front wheel drive             4  Luxury                             Midsize       Sedan                   22        16        3105    2000
    32 │ Audi           100          1994  regular unleaded                      172                 6  AUTOMATIC          all wheel drive               4  Luxury                             Midsize       Wagon                   21        16        3105    2000
    33 │ FIAT           124 Spider   2017  premium unleaded (recommended)        160                 4  MANUAL             rear wheel drive              2  Performance                        Compact       Convertible             35        26         819   27495
    34 │ FIAT           124 Spider   2017  premium unleaded (recommended)        160                 4  MANUAL             rear wheel drive              2  Performance                        Compact       Convertible             35        26         819   24995
    35 │ FIAT           124 Spider   2017  premium unleaded (recommended)        160                 4  MANUAL             rear wheel drive              2  Performance                        Compact       Convertible             35        26         819   28195
    36 │ Mercedes-Benz  190-Class    1991  regular unleaded                      130                 4  MANUAL             rear wheel drive              4  Luxury                             Compact       Sedan                   26        18         617    2000
    37 │ Mercedes-Benz  190-Class    1991  regular unleaded                      158                 6  MANUAL             rear wheel drive              4  Luxury                             Compact       Sedan                   25        17         617    2000
    38 │ Mercedes-Benz  190-Class    1992  regular unleaded                      158                 6  MANUAL             rear wheel drive              4  Luxury                             Compact       Sedan                   25        17         617    2000
    39 │ Mercedes-Benz  190-Class    1992  regular unleaded                      130                 4  MANUAL             rear wheel drive              4  Luxury                             Compact       Sedan                   26        18         617    2000
    40 │ Mercedes-Benz  190-Class    1993  regular unleaded                      130                 4  MANUAL             rear wheel drive              4  Luxury                             Compact       Sedan                   26        18         617    2000
    41 │ Mercedes-Benz  190-Class    1993  regular unleaded                      158                 6  MANUAL             rear wheel drive              4  Luxury                             Compact       Sedan                   25        17         617    2000
    42 │ BMW            2 Series     2016  premium unleaded (required)           240                 4  AUTOMATIC          rear wheel drive              2  Luxury,Performance                 Compact       Coupe                   35        23        3916   32850
    43 │ BMW            2 Series     2016  premium unleaded (required)           240                 4  AUTOMATIC          rear wheel drive              2  Luxury                             Compact       Convertible             34        23        3916   38650
    44 │ BMW            2 Series     2016  premium unleaded (required)           320                 6  AUTOMATIC          rear wheel drive              2  Factory Tuner,Luxury,High-Perfor…  Compact       Convertible             31        20        3916   48750
    45 │ BMW            2 Series     2016  premium unleaded (required)           240                 4  AUTOMATIC          all wheel drive               2  Luxury,Performance                 Compact       Coupe                   35        23        3916   34850
    46 │ BMW            2 Series     2016  premium unleaded (required)           240                 4  AUTOMATIC          all wheel drive               2  Luxury                             Compact       Convertible             34        22        3916   40650
   ⋮   │       ⋮            ⋮         ⋮                  ⋮                     ⋮             ⋮                  ⋮                  ⋮               ⋮                        ⋮                       ⋮              ⋮             ⋮          ⋮          ⋮         ⋮
 11870 │ GMC            Yukon        2016  premium unleaded (recommended)        420                 8  AUTOMATIC          rear wheel drive              4  Performance                        Large         4dr SUV                 22        15         549   65325
 11871 │ GMC            Yukon        2016  flex-fuel (unleaded/E85)              355                 8  AUTOMATIC          four wheel drive              4  Flex Fuel,Performance              Large         4dr SUV                 22        16         549   51315
 11872 │ GMC            Yukon        2016  premium unleaded (recommended)        420                 8  AUTOMATIC          four wheel drive              4  Performance                        Large         4dr SUV                 21        15         549   68325
 11873 │ GMC            Yukon        2016  flex-fuel (unleaded/E85)              355                 8  AUTOMATIC          rear wheel drive              4  Flex Fuel,Performance              Large         4dr SUV                 23        16         549   57000
 11874 │ GMC            Yukon        2016  flex-fuel (unleaded/E85)              355                 8  AUTOMATIC          rear wheel drive              4  Flex Fuel,Performance              Large         4dr SUV                 23        16         549   48315
 11875 │ GMC            Yukon        2016  flex-fuel (unleaded/E85)              355                 8  AUTOMATIC          four wheel drive              4  Flex Fuel,Performance              Large         4dr SUV                 22        16         549   60000
 11876 │ GMC            Yukon        2017  premium unleaded (recommended)        420                 8  AUTOMATIC          four wheel drive              4  Performance                        Large         4dr SUV                 20        15         549   68965
 11877 │ GMC            Yukon        2017  flex-fuel (unleaded/E85)              355                 8  AUTOMATIC          rear wheel drive              4  Flex Fuel,Performance              Large         4dr SUV                 23        16         549   57315
 11878 │ GMC            Yukon        2017  flex-fuel (unleaded/E85)              355                 8  AUTOMATIC          four wheel drive              4  Flex Fuel,Performance              Large         4dr SUV                 22        16         549   51530
 11879 │ GMC            Yukon        2017  premium unleaded (recommended)        420                 8  AUTOMATIC          rear wheel drive              4  Performance                        Large         4dr SUV                 22        15         549   65965
 11880 │ GMC            Yukon        2017  flex-fuel (unleaded/E85)              355                 8  AUTOMATIC          four wheel drive              4  Flex Fuel,Performance              Large         4dr SUV                 22        16         549   60315
 11881 │ GMC            Yukon        2017  flex-fuel (unleaded/E85)              355                 8  AUTOMATIC          rear wheel drive              4  Flex Fuel,Performance              Large         4dr SUV                 23        16         549   48530
 11882 │ BMW            Z3           2000  regular unleaded                      193                 6  MANUAL             rear wheel drive              2  Luxury,Performance                 Compact       Convertible             24        17        3916    4976
 11883 │ BMW            Z3           2000  regular unleaded                      193                 6  MANUAL             rear wheel drive              2  Hatchback,Luxury,Performance       Compact       2dr Hatchback           24        17        3916    4697
 11884 │ BMW            Z3           2000  regular unleaded                      170                 6  MANUAL             rear wheel drive              2  Luxury,Performance                 Compact       Convertible             25        17        3916    4755
 11885 │ BMW            Z3           2001  premium unleaded (required)           225                 6  MANUAL             rear wheel drive              2  Luxury,Performance                 Compact       Convertible             26        19        3916   37900
 11886 │ BMW            Z3           2001  premium unleaded (required)           184                 6  MANUAL             rear wheel drive              2  Luxury,Performance                 Compact       Convertible             25        18        3916   31300
 11887 │ BMW            Z3           2001  premium unleaded (required)           225                 6  MANUAL             rear wheel drive              2  Hatchback,Luxury,Performance       Compact       2dr Hatchback           26        19        3916   37700
 11888 │ BMW            Z3           2002  premium unleaded (required)           225                 6  MANUAL             rear wheel drive              2  Luxury,Performance                 Compact       Convertible             26        19        3916   37900
 11889 │ BMW            Z3           2002  premium unleaded (required)           184                 6  MANUAL             rear wheel drive              2  Luxury,Performance                 Compact       Convertible             25        18        3916   31300
 11890 │ BMW            Z3           2002  premium unleaded (required)           225                 6  MANUAL             rear wheel drive              2  Hatchback,Luxury,Performance       Compact       2dr Hatchback           26        19        3916   37700
 11891 │ BMW            Z4 M         2007  premium unleaded (required)           330                 6  MANUAL             rear wheel drive              2  Factory Tuner,Luxury,High-Perfor…  Compact       Coupe                   22        15        3916   50100
 11892 │ BMW            Z4 M         2007  premium unleaded (required)           330                 6  MANUAL             rear wheel drive              2  Factory Tuner,Luxury,High-Perfor…  Compact       Convertible             22        15        3916   52100
 11893 │ BMW            Z4 M         2008  premium unleaded (required)           330                 6  MANUAL             rear wheel drive              2  Factory Tuner,Luxury,High-Perfor…  Compact       Coupe                   23        15        3916   50400
 11894 │ BMW            Z4 M         2008  premium unleaded (required)           330                 6  MANUAL             rear wheel drive              2  Factory Tuner,Luxury,High-Perfor…  Compact       Convertible             23        15        3916   52400
 11895 │ BMW            Z4           2014  premium unleaded (required)           240                 4  MANUAL             rear wheel drive              2  Luxury,Performance                 Compact       Convertible             34        22        3916   48950
 11896 │ BMW            Z4           2014  premium unleaded (required)           300                 6  MANUAL             rear wheel drive              2  Luxury,High-Performance            Compact       Convertible             26        19        3916   56950
 11897 │ BMW            Z4           2014  premium unleaded (required)           335                 6  AUTOMATED_MANUAL   rear wheel drive              2  Luxury,High-Performance            Compact       Convertible             24        17        3916   65800
 11898 │ BMW            Z4           2015  premium unleaded (required)           240                 4  MANUAL             rear wheel drive              2  Luxury,Performance                 Compact       Convertible             34        22        3916   48950
 11899 │ BMW            Z4           2015  premium unleaded (required)           300                 6  AUTOMATED_MANUAL   rear wheel drive              2  Luxury,High-Performance            Compact       Convertible             24        17        3916   56950
 11900 │ BMW            Z4           2015  premium unleaded (required)           335                 6  AUTOMATED_MANUAL   rear wheel drive              2  Luxury,High-Performance            Compact       Convertible             24        17        3916   65800
 11901 │ BMW            Z4           2016  premium unleaded (required)           300                 6  AUTOMATED_MANUAL   rear wheel drive              2  Luxury,High-Performance            Compact       Convertible             24        17        3916   57500
 11902 │ BMW            Z4           2016  premium unleaded (required)           240                 4  MANUAL             rear wheel drive              2  Luxury,Performance                 Compact       Convertible             34        22        3916   49700
 11903 │ BMW            Z4           2016  premium unleaded (required)           335                 6  AUTOMATED_MANUAL   rear wheel drive              2  Luxury,High-Performance            Compact       Convertible             24        17        3916   66350
 11904 │ BMW            Z8           2001  premium unleaded (required)           394                 8  MANUAL             rear wheel drive              2  Exotic,Luxury,High-Performance     Compact       Convertible             19        12        3916  128000
 11905 │ BMW            Z8           2002  premium unleaded (required)           394                 8  MANUAL             rear wheel drive              2  Exotic,Luxury,High-Performance     Compact       Convertible             19        12        3916  130000
 11906 │ BMW            Z8           2003  premium unleaded (required)           394                 8  MANUAL             rear wheel drive              2  Exotic,Luxury,High-Performance     Compact       Convertible             19        12        3916  131500
 11907 │ Acura          ZDX          2011  premium unleaded (required)           300                 6  AUTOMATIC          all wheel drive               4  Crossover,Hatchback,Luxury         Midsize       4dr Hatchback           23        16         204   46020
 11908 │ Acura          ZDX          2011  premium unleaded (required)           300                 6  AUTOMATIC          all wheel drive               4  Crossover,Hatchback,Luxury         Midsize       4dr Hatchback           23        16         204   56570
 11909 │ Acura          ZDX          2011  premium unleaded (required)           300                 6  AUTOMATIC          all wheel drive               4  Crossover,Hatchback,Luxury         Midsize       4dr Hatchback           23        16         204   50520
 11910 │ Acura          ZDX          2012  premium unleaded (required)           300                 6  AUTOMATIC          all wheel drive               4  Crossover,Hatchback,Luxury         Midsize       4dr Hatchback           23        16         204   46120
 11911 │ Acura          ZDX          2012  premium unleaded (required)           300                 6  AUTOMATIC          all wheel drive               4  Crossover,Hatchback,Luxury         Midsize       4dr Hatchback           23        16         204   56670
 11912 │ Acura          ZDX          2012  premium unleaded (required)           300                 6  AUTOMATIC          all wheel drive               4  Crossover,Hatchback,Luxury         Midsize       4dr Hatchback           23        16         204   50620
 11913 │ Acura          ZDX          2013  premium unleaded (recommended)        300                 6  AUTOMATIC          all wheel drive               4  Crossover,Hatchback,Luxury         Midsize       4dr Hatchback           23        16         204   50920
 11914 │ Lincoln        Zephyr       2006  regular unleaded                      221                 6  AUTOMATIC          front wheel drive             4  Luxury                             Midsize       Sedan                   26        17          61   28995
                                                                                                                                                                                                                                                    11823 rows omitted

References

  • James, G., Witten, D., Hastie, T., & Tibshirani, R. (2021). An Introduction to Statistical Learning: With Applications in R (2nd ed.). Springer. https://doi.org/10.1007/978-1-0716-1418-1
  • Shmueli, G., Patel, N. R., & Bruce, P. C. (2007). Data Mining for Business Intelligence. Wiley.
  • Albright, S. C., Winston, W. L., & Zappe, C. (2003). Data Analysis for Managers with Microsoft Excel (2nd ed.). South-Western College Publishing.
Applied Advanced Analytics & AI in Sports