1"use strict";(globalThis.webpackChunkportfolio=globalThis.webpackChunkportfolio||[]).push([[797],{193(e,t,i){i.r(t),i.d(t,{assets:()=>d,contentTitle:()=>a,default:()=>c,frontMatter:()=>l,metadata:()=>n,toc:()=>o});var n=i(2120),s=i(4848),r=i(8453);const l={slug:"exploratory-data-analysis-auto-mpg",title:"Exploratory Data Analysis with Auto MPG Dataset",authors:["rossbulat"],tags:["Machine Learning","Introduction","Unit 2"]},a=void 0,d={authorsImageUrls:[void 0]},o=[{value:"Introduction",id:"introduction",level:2},{value:"1. Loading and inspecting the data",id:"1-loading-and-inspecting-the-data",level:2},{value:"2. Identifying missing values",id:"2-identifying-missing-values",level:2},{value:"3. Encoding categorical values",id:"3-encoding-categorical-values",level:2},{value:"4. Skewness and kurtosis",id:"4-skewness-and-kurtosis",level:2},{value:"5. Correlation heat map",id:"5-correlation-heat-map",level:2},{value:"6. Scatter plots",id:"6-scatter-plots",level:2},{value:"7. Grouped summaries",id:"7-grouped-summaries",level:2},{value:"8. Reflection against the learning outcomes",id:"8-reflection-against-the-learning-outcomes",level:2},{value:"Conclusion",id:"conclusion",level:2}];function h(e){const t={a:"a",code:"code",h2:"h2",img:"img",li:"li",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.strong,{children:"Google Colab notebook:"})," ",(0,s.jsx)(t.a,{href:"https://colab.research.google.com/drive/1P-_U8k6PZkqrnI1KQ_KgakW7T-2v_rGZ",children:"Open in Google Colab"})," \xb7 ",(0,s.jsx)(t.strong,{children:"Raw Notebook:"})," ",(0,s.jsxs)(t.a,{target:"_blank","data-noBrokenLinkCheck":!0,href:i(9568).A+"",children:["Download ",(0,s.jsx)(t.code,{children:".ipynb"})]})]}),"\n",(0,s.jsx)(t.h2,{id:"introduction",children:"Introduction"}),"\n",(0,s.jsx)(t.p,{children:"I used exploratory data analysis (EDA) to assess whether the Auto MPG dataset was suitable for machine learning and to identify key uncertainties before modelling."}),"\n",(0,s.jsx)(t.p,{children:"I followed a standard EDA workflow: importing the analysis libraries, loading the data, inspecting its structure and summary statistics, separating numeric and categorical variables, checking for missing values, and using visualisations (including heat maps and scatter plots) to examine relationships."}),"\n",(0,s.jsxs)(t.p,{children:["The dataset contains ",(0,s.jsx)(t.strong,{children:"398 rows"})," and ",(0,s.jsx)(t.strong,{children:"9 original columns"}),". The main variables are fuel economy (",(0,s.jsx)(t.code,{children:"mpg"}),"), engine size (",(0,s.jsx)(t.code,{children:"displacement"}),"), engine power (",(0,s.jsx)(t.code,{children:"horsepower"}),"), vehicle weight, acceleration, model year, origin, and car name."]}),"\n",(0,s.jsx)(t.h2,{id:"1-loading-and-inspecting-the-data",children:"1. Loading and inspecting the data"}),"\n",(0,s.jsxs)(t.p,{children:["I began by loading ",(0,s.jsx)(t.code,{children:"auto-mpg.csv"})," into pandas and reviewing the first and last rows, dataset shape, and inferred data types. This initial check exposed an important quality issue: ",(0,s.jsx)(t.code,{children:"horsepower"}
1)," had been read as an object column instead of a numeric variable."]}),"\n",(0,s.jsxs)(t.p,{children:["This was because missing values were represented by a question mark (",(0,s.jsx)(t.code,{children:"?"}),") rather than standard ",(0,s.jsx)(t.code,{children:"NaN"}),". It was a useful reminder that missing data is not always immediately visible through ",(0,s.jsx)(t.code,{children:"isna()"})," on raw input, especially when pandas has inferred a text type."]}),"\n",(0,s.jsx)(t.h2,{id:"2-identifying-missing-values",children:"2. Identifying missing values"}),"\n",(0,s.jsxs)(t.p,{children:["After converting ",(0,s.jsx)(t.code,{children:"horsepower"})," using ",(0,s.jsx)(t.code,{children:"pd.to_numeric(..., errors='coerce')"}),", the question marks were correctly converted to missing values. The missing-value summary was:"]}),"\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"}}),(0,s.jsx)(t.th,{style:{textAlign:"right"},children:"missing_count"}),(0,s.jsx)(t.th,{style:{textAlign:"right"},children:"missing_percent"})]})}),(0,s.jsxs)(t.tbody,{children:[(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"horsepower"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"6"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"1.51"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"mpg"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"cylinders"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"displacement"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"weight"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"acceleration"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"model year"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"origin"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"car name"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"horsepower_imputed"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"origin_label"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"origin_America"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"origin_Europe"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"origin_Japan"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"})]})]})]}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.img,{alt:"Bar chart of missing values by column, showing six for horsepower and zero for the other original columns",src:i(8593).A+"",width:"884",height:"384"})}),"\n",(0,s.jsxs)(t.p,{children:["The chart confirms that the missing values are confined to ",(0,s.jsx)(t.code,{children:"horsepower"}),". This left a small but non-trivial missing-data issue: ",(0,s.jsxs)(t.strong,{children:["six missing ",(0,s.jsx)(t.code,{children:"horsepower"})," values"]})," (approximately ",(0,s.jsx)(t.strong,{children:"1.51%"})," of records). To keep the workflow transparent, I retained the original ",(0,s.jsx)(t.code,{children:"horsepower"})," column and created a separate ",(0,s.jsx)(t.code,{children:"horsepower_imputed"})," feature using median imputation for analysis that required complete numeric inputs."]}),"\n",(0,s.jsx)(t.p,{children:"I selected median imputation because it is straightforward, reproducible, and generally more robust to skew than mean imputation."}),"\n",(0,s.jsx)(t.h2,{id:"3-encoding-categorical-values",children:"3. Encoding categorical values"}),"\n",(0,s.jsxs)(t.p,{children:["The task required categorical values to be represented numerically. In this dataset, ",(0,s.jsx)(t.code,{children:"origin"}),' was already stored as integer codes (America = 1, Europe = 2, Japan = 3). However, integer encoding (1, 2, 3) implies an artificial order and distance between what are actually nominal categories\u2014there is no meaningful sense in which Japan is "three times" America, or in which Europe sits "between" the other two.']}),"\n",(0,s.jsxs)(t.p,{children:["For this reason, I first mapped the integer codes to readable labels and then applied ",(0,s.jsx)(t.strong,{children:"one-hot encoding"})," using ",(0,s.jsx)(t.code,{children:"pd.get_dummies(...)"}),", which produced three binary indicator columns:"]}),"\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{children:"Original origin"}),(0,s.jsx)(t.th,{style:{textAlign:"right"},children:"origin_America"}),(0,s.jsx)(t.th,{style:{textAlign:"right"},children:"origin_Europe"}),(0,s.jsx)(t.th,{style:{textAlign:"right"},children:"origin_Japan"})]})}),(0,s.jsxs)(t.tbody,{children:[(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{children:"America"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"1"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{children:"Europe"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"1"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{children:"Japan"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"1"})]})]})]}),"\n",(0,s.jsxs)(t.p,{children:["One-hot encoding avoids the false ordinal assumption that integer encoding can introduce, and it is generally the more appropriate choice for nominal categorical features in machine learning pipelines. Each indicator column is itself a valid numeric feature (a Bernoulli 0/1 variable), so unlike a single arbitrary integer code, the one-hot columns can legitimately appear in a Pearson correlation matrix against ",(0,s.jsx)(t.code,{children:"mpg"})," and other continuous variables."]}),"\n",(0,s.jsx)(t.p,{children:"The origin counts were:"}),"\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"origin_label"}),(0,s.jsx)(t.th,{style:{textAlign:"right"},children:"count"})]})}),(0,s.jsxs)(t.tbody,{children:[(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"America"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"249"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"Japan"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"79"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"Europe"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"70"})]})]})]}),"\n",(0,s.jsx)(t.h2,{id:"4-skewness-and-kurtosis",children:"4. Skewness and kurtosis"}),"\n",(0,s.jsxs)(t.p,{children:["I calculated skewness and kurtosis for the continuous numeric variables only. Skewness indicates asymmetry in a distribution, while kurtosis indicates tail behaviour relative to a normal distribution. The one-hot ",(0,s.jsx)(t.code,{children:"origin_*"})," columns are excluded from this analysis because they are binary indicator variables. Distribution shape statistics like skewness and kurtosis are not informative for 0/1 features (their shape is fully described by their proportion)."]}),"\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"}}),(0,s.jsx)(t.th,{style:{textAlign:"right"},children:"skewness"}),(0,s.jsx)(t.th,{style:{textAlign:"right"},children:"kurtosis"})]})}),(0,s.jsxs)(t.tbody,{children:[(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"mpg"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0.457"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"-0.511"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"cylinders"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0.527"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"-1.377"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"displacement"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0.72"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"-0.747"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"horsepower"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"1.087"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0.697"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"horsepower_imputed"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"1.106"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0.764"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"weight"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0.531"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"-0.786"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"acceleration"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0.279"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0.419"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"model year"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0.012"}),(0,s.jsx)(t.td,{style:{textAlign:"right"}
1,children:"-1.181"})]})]})]}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.img,{alt:"Histogram and density curve of the right-skewed imputed horsepower distribution",src:i(890).A+"",width:"684",height:"384"})}),"\n",(0,s.jsxs)(t.p,{children:["The histogram makes the right skew in ",(0,s.jsx)(t.code,{children:"horsepower_imputed"})," clear. Most vehicles sit in the low-to-mid power range, with a smaller number of high-powered vehicles forming the right tail. ",(0,s.jsx)(t.code,{children:"displacement"}),", ",(0,s.jsx)(t.code,{children:"weight"}),", and ",(0,s.jsx)(t.code,{children:"cylinders"})," also showed positive skew, which aligns with a dataset dominated by moderate vehicles and fewer extreme large-engine observations."]}),"\n",(0,s.jsx)(t.p,{children:"Most kurtosis values were close to zero or negative, so the distributions were not generally dominated by heavy tails. Since skew and outliers can affect algorithm performance and interpretation, later stages may require transformation, scaling, or more robust estimators depending on the model chosen."}),"\n",(0,s.jsx)(t.h2,{id:"5-correlation-heat-map",children:"5. Correlation heat map"}),"\n",(0,s.jsxs)(t.p,{children:["I used a correlation heat map to examine linear relationships between numeric features. Because ",(0,s.jsx)(t.code,{children:"origin"})," is represented as three binary one-hot columns, each can be included in the correlation matrix as a point-biserial-style relationship with ",(0,s.jsx)(t.code,{children:"mpg"}),". This is a valid use of Pearson correlation between a continuous variable and a 0/1 indicator."]}),"\n",(0,s.jsxs)(t.p,{children:["The correlations with ",(0,s.jsx)(t.code,{children:"mpg"})," for the continuous variables were:"]}),"\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"}}),(0,s.jsx)(t.th,{style:{textAlign:"right"},children:"mpg"})]})}),(0,s.jsxs)(t.tbody,{children:[(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"mpg"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"1"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"model year"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0.579"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"acceleration"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"0.42"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"horsepower_imputed"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"-0.773"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"cylinders"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"-0.775"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"displacement"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"-0.804"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"weight"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"-0.832"})]})]})]}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.img,{alt:"Correlation heat map for the continuous variables and one-hot encoded origin columns",src:i(7416).A+"",width:"948",height:"684"})}),"\n",(0,s.jsxs)(t.p,{children:["The strongest negative relationship was between ",(0,s.jsx)(t.code,{children:"mpg"})," and ",(0,s.jsx)(t.code,{children:"weight"}),", which is intuitive: heavier vehicles tend to consume more fuel. ",(0,s.jsx)(t.code,{children:"displacement"}),", ",(0,s.jsx)(t.code,{children:"horsepower"}),", and ",(0,s.jsx)(t.code,{children:"cylinders"})," were also strongly negatively associated with ",(0,s.jsx)(t.code,{children:"mpg"}),"."]}),"\n",(0,s.jsxs)(t.p,{children:["The heat map also shows strong correlations between several mechanical variables. ",(0,s.jsx)(t.code,{children:"displacement"})," and ",(0,s.jsx)(t.code,{children:"weight"})," have a correlation of ",(0,s.jsx)(t.strong,{children:"0.93"}),", while ",(0,s.jsx)(t.code,{children:"cylinders"})," and ",(0,s.jsx)(t.code,{children:"displacement"})," have a correlation of ",(0,s.jsx)(t.strong,{children:"0.95"}),". This degree of multicollinearity would need to be considered when selecting and interpreting a model, even if the main aim were simply to predict ",(0,s.jsx)(t.code,{children:"mpg"}),"."]}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.code,{children:"model year"})," showed a positive relationship with ",(0,s.jsx)(t.code,{children:"mpg"}),", suggesting that newer vehicles in this historical sample were generally more fuel efficient. I treated this carefully in interpretation, since correlation alone does not establish causation and may reflect broader historical factors such as regulation, design shifts, or market priorities."]}),"\n",(0,s.jsxs)(t.p,{children:["The one-hot ",(0,s.jsx)(t.code,{children:"origin_*"})," columns showed the direction expected from the grouped summaries in Section 7: ",(0,s.jsx)(t.code,{children:"origin_America"})," was negatively correlated with ",(0,s.jsx)(t.code,{children:"mpg"}),", while ",(0,s.jsx)(t.code,{children:"origin_Japan"})," and ",(0,s.jsx)(t.code,{children:"origin_Europe"})," were positively correlated with ",(0,s.jsx)(t.code,{children:"mpg"}),". Because the three indicators are mutually exclusive and sum to 1 for every row, they are not independent of each other, so they should be interpreted together rather than as fully separate features."]}),"\n",(0,s.jsx)(t.h2,{id:"6-scatter-plots",children:"6. Scatter plots"}),"\n",(0,s.jsxs)(t.p,{children:["The scatter plots focused on pairwise relationships involving ",(0,s.jsx)(t.code,{children:"mpg"}),", particularly:"]}),"\n",(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.code,{children:"mpg"})," vs ",(0,s.jsx)(t.code,{children:"weight"})]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.code,{children:"mpg"})," vs ",(0,s.jsx)(t.code,{children:"horsepower_imputed"})]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.code,{children:"mpg"})," vs ",(0,s.jsx)(t.code,{children:"displacement"})]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.code,{children:"mpg"})," vs ",(0,s.jsx)(t.code,{children:"acceleration"})]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.code,{children:"mpg"})," vs ",(0,s.jsx)(t.code,{children:"model year"})]}),"\n"]}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.img,{alt:"Scatter plot of MPG against vehicle weight, coloured by vehicle origin",src:i(9164).A+"",width:"684",height:"434"})}),"\n",(0,s.jsxs)(t.p,{children:["The ",(0,s.jsx)(t.code,{children:"weight"})," plot shows this pattern most clearly: ",(0,s.jsx)(t.code,{children:"mpg"})," falls as vehicles become heavier, and the fitted line highlights the inverse relationship. The same downward trend appeared as ",(0,s.jsx)(t.code,{children:"horsepower_imputed"})," and ",(0,s.jsx)(t.code,{children:"displacement"})," increased. Colouring the points by origin also revealed clusters in different parts of the feature space. In this dataset, American-origin vehicles appeared more frequently in heavier, larger-displacement regions, while Japanese and European vehicles were more common in lighter, higher-mpg regions."]}),"\n",(0,s.jsx)(t.p,{children:"These patterns are useful for modelling, but need to be interpreted with caution. Origin may be acting as a proxy for other factors (vehicle size, production era, market segment, or design choices), so it should not be treated as a standalone causal explanation."}),"\n",(0,s.jsx)(t.h2,{id:"7-grouped-summaries",children:"7. Grouped summaries"}),"\n",(0,s.jsx)(t.p,{children:"I also compared averages by origin:"}),"\n",(0,s.jsxs)(t.table,{children:[(0,s.jsx)(t.thead,{children:(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.th,{style:{textAlign:"left"},children:"origin_label"}),(0,s.jsx)(t.th,{style:{textAlign:"right"},children:"count"}),(0,s.jsx)(t.th,{style:{textAlign:"right"},children:"avg_mpg"}),(0,s.jsx)(t.th,{style:{textAlign:"right"},children:"avg_weight"}),(0,s.jsx)(t.th,{style:{textAlign:"right"},children:"avg_horsepower"})]})}),(0,s.jsxs)(t.tbody,{children:[(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"Japan"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"79"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"30.45"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"2221.23"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"79.84"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"Europe"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"70"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"27.89"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"2423.3"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"80.93"})]}),(0,s.jsxs)(t.tr,{children:[(0,s.jsx)(t.td,{style:{textAlign:"left"},children:"America"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"249"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"20.08"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"3361.93"}),(0,s.jsx)(t.td,{style:{textAlign:"right"},children:"118.64"})]})]})]}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.img,{alt:"Box plots of MPG grouped by vehicle origin",src:i(9268).A+"",width:"784",height:"434"})}),"\n",(0,s.jsx)(t.p,{children:"The box plots provide more context. American vehicles had the lowest median MPG and Jap
1anese vehicles the highest, although the distributions overlapped and there was variation within every group. In this sample, vehicles from Japan and Europe also tended to have lower average weight and horsepower. This was a useful example of how EDA methods work together: correlation gives a quantitative overview, while grouped summaries and distributions improve interpretability."}),"\n",(0,s.jsx)(t.h2,{id:"8-reflection-against-the-learning-outcomes",children:"8. Reflection against the learning outcomes"}),"\n",(0,s.jsxs)(t.p,{children:["At face value, Auto MPG appears straightforward, but the ",(0,s.jsx)(t.code,{children:"horsepower"})," issue demonstrated why EDA is essential before any model development. Hidden missingness in a nominally numeric feature can directly undermine model reliability."]}),"\n",(0,s.jsx)(t.p,{children:"The EDA highlighted several issues to address before selecting a model, including missing values, skewed feature distributions, multicollinearity among mechanical variables, and encoding decisions for categorical data. Each has implications for model validity, interpretability, and defensibility."}),"\n",(0,s.jsx)(t.p,{children:"Although this dataset is less sensitive than personal or clinical data, there are still professional and ethical considerations. It is historical data, so findings should not be overgeneralised to contemporary vehicle populations. Similarly, origin-based comparisons should be framed carefully to avoid simplistic conclusions, since origin may co-vary with broader engineering and market factors."}),"\n",(0,s.jsx)(t.p,{children:"I also treated reproducibility as part of professional practice by documenting cleaning decisions, preserving raw and transformed columns, and structuring the analysis so another team member could review the assumptions and continue the workflow into modelling."}),"\n",(0,s.jsx)(t.h2,{id:"conclusion",children:"Conclusion"}),"\n",(0,s.jsxs)(t.p,{children:["Overall, this EDA suggests that the Auto MPG dataset is suitable for introductory machine learning tasks, particularly MPG prediction, but only after data preprocessing. The hidden missing values in ",(0,s.jsx)(t.code,{children:"horsepower"}),", skew in engine-related variables, strong inter-feature correlations, and categorical encoding choices all require explicit handling."]}),"\n",(0,s.jsx)(t.p,{children:"The exercise reinforced the value of EDA as a way to reduce risk before modelling. It helps identify data quality problems early, supports transparent methodological decisions, and provides a stronger foundation for responsible model development."})]})}function c(e={}){const{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}},9568(e,t,i){i.d(t,{A:()=>n});const n=i.p+"assets/files/2026-05-09-auto-mpg-61e65526c75aad62768be169de32367c.ipynb"},7416(e,t,i){i.d(t,{A:()=>n});const n=i.p+"assets/images/correlation-heatmap-9b2570b1b7ef8c33c20504cdaceee02d.png"},890(e,t,i){i.d(t,{A:()=>n});const n=i.p+"assets/images/horsepower-distribution-cf1297d23b882bbc572e7ba1af932cc7.png"},8593(e,t,i){i.d(t,{A:()=>n});const n=i.p+"assets/images/missing-values-by-column-98b8f3307a5ebc79c88388e2427e9178.png"},9268(e,t,i){i.d(t,{A:()=>n});const n=i.p+"assets/images/mpg-by-origin-c8dfe5d835ca68db4d526b92ebd9a48b.png"},9164(e,t,i){i.d(t,{A:()=>n});const n=i.p+"assets/images/mpg-vs-weight-f1876fc357b102a98cc294f845b7183d.png"},8453(e,t,i){i.d(t,{R:()=>l,x:()=>a});var n=i(6540);const s={},r=n.createContext(s);function l(e){const t=n.useContext(r);return n.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:l(e.components),n.createElement(r.Provider,{value:t},e.children)}},2120(e){e.exports=JSON.parse('{"permalink":"/machine-learning/exploratory-data-analysis-auto-mpg","source":"@site/machine-learning/2026-05-09-auto-mpg.md","title":"Exploratory Data Analysis with Auto MPG Dataset","description":"Google Colab notebook Download .ipynb","date":"2026-05-09T00:00:00.000Z","tags":[{"inline":true,"label":"Machine Learning","permalink":"/machine-learning/tags/machine-learning"},{"inline":true,"label":"Introduction","permalink":"/machine-learning/tags/introduction"},{"inline":true,"label":"Unit 2","permalink":"/machine-learning/tags/unit-2"}],"readingTime":8.09,"hasTruncateMarker":true,"authors":[{"name":"Ross Bulat","title":"Full Stack Engineer","url":"https://github.com/rossbulat","page":{"permalink":"/machine-learning/authors/rossbulat"},"socials":{"x":"https://x.com/rossbulat","github":"https://github.com/rossbulat","linkedin":"https://www.linkedin.com/in/rossbulat/"}
1,"imageURL":"https://jkrb.io/img/rossBulat.webp","key":"rossbulat"}],"frontMatter":{"slug":"exploratory-data-analysis-auto-mpg","title":"Exploratory Data Analysis with Auto MPG Dataset","authors":["rossbulat"],"tags":["Machine Learning","Introduction","Unit 2"]},"unlisted":false,"prevItem":{"title":"Data Analysis of Correlation and Regression Notebooks","permalink":"/machine-learning/data-analysis-of-correlation-and-regression-notebooks"}}')}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.