Case Study (Salary & Position) :

SKLearrn (Polynomial Linear Regression)

Overview

- Importing the Relevant Libraries

- Loading the Data

- Declaring the Dependent and the Independent variables

- Splitting the dataset into the Training set and Test set

- Simple Linear Regression 

    - Creating a Linear Regression 
    - Fitting The Model
    - Predicting the Results
    - Making a Single Observation Prediction


- Visualising the Simple Linear Regression

- Result

Importing the Relevant Libraries

Loading the Data

Declaring the Dependent and the Independent variables

- Exclude Position (Index 0)
- Position & Level are the same

Splitting the Dataset into the Training Set and Test Set

- Dataset is small, so we will not split it into training set & test set

Simple Linear Regression

Creating a Linear Regression

- LinearRegression Class from linear_model Module of sklearn Library

- model -> Object of LinearRegression Class

Fitting The Model

- fit method -> training the model

Predicting the Results

- y_pred -> the predicted salaries

Making a Single Observation Prediction

- level: 6.5 

Visualising the Simple Linear Regression

Result:

- Considering the scatter plot:

    - A Simple Linear Regression doesn't fit quite well to the data 

    - Let's try Polynomial Linear Regression