Polynomial Regression in Python – Step 1.) Import Libraries and Import Dataset

with No Comments

Importing Libraries

Just like other machine learning model, we always have to import the libraries.

  • We are going to use numpy, matplotlib and pandas.
  • numpy is going to handle the scientific calculations.
  • matplotlib is for visualizing the results
  • pandas is going to import the dataset for us.

Importing the CSV Data

  • The name of our dataset is “Poly_Data.csv.”
  • In our code, pd stands for pandas.
  • “dataset” is the variable that stores the data from our csv file.
  • We use iloc to separate the independent variables and dependent variables.
  • x is set as the independent variables, y is set as the dependent variables.

# Import the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

# Import the CSV Data
dataset = pd.read_csv(‘Poly_Data.csv’)
X = dataset.iloc[:, 1:2].values
y = dataset.iloc[:, 2].values

Leave a Reply