How to build a basic machine learning model from scratch

Tanu N Prabhu
Analytics Vidhya
Published in
14 min readSep 4, 2019

--

In this tutorial, we will learn how to build a machine learning model using python from scratch.

Credits: Yale School of Management

1) Getting the data

I chose a data-set titled “Cars” data from Kaggle the author of this data set is Lilit Janughazyan [1]. This data set has 428 instances and 15 features also called as rows and columns. Since the data set was already in a CSV format. All I had to do is just format the data into a pandas data frame. The data set can be found here: Cars dataset

# Importing the required librariesimport pandas as pd 
import numpy as np
import seaborn as sns #visualisation
import matplotlib.pyplot as plt #visualisation
%matplotlib inline
sns.set(color_codes=True)
# Loading the CSV file into a pandas dataframe.df = pd.read_csv(“CARS.csv”)
df.head(5)

Removing irrelevant features.

I will remove some features such as Drive Train, Model, Invoice, Type, and Origin from this dataset. Because these features do not contribute to the prediction of price.

# Removing irrelevant

--

--

Tanu N Prabhu
Analytics Vidhya

MSc in Computer Science | He/Him | Tech and pet enthusiast | Don’t believe me, read a couple of my writings | Writing since June 19, 2019 |