# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# + [markdown] heading_collapsed=true
# # Import

# + hidden=true
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

# + [markdown] heading_collapsed=true
# # Preparing Data

# + hidden=true
dataset = pd.read_csv('Position_Salaries.csv')
dataset

# + hidden=true
dataset.plot(kind='Scatter', x='Level', y='Salary')

# + hidden=true
X = dataset.iloc[:, 1:-1].values
y = dataset.iloc[:, -1].values

# + [markdown] hidden=true
# In this particular situation, **X_train = X** and **y_train = y**

# + [markdown] heading_collapsed=true
# # Regression

# + [markdown] heading_collapsed=true hidden=true
# ## Building Model

# + hidden=true
from sklearn.linear_model import LinearRegression

# + hidden=true
from sklearn.preprocessing import PolynomialFeatures

# + hidden=true
poly_reg = PolynomialFeatures(degree=5)

# + hidden=true
X_poly = poly_reg.fit_transform(X)

# + hidden=true
X_poly

# + hidden=true
regressor = LinearRegression()
regressor.fit(X_poly, y)

# + [markdown] heading_collapsed=true hidden=true
# ## Visualization

# + hidden=true
plt.scatter(X,y,color='red')
plt.plot(X, regressor.predict(poly_reg.fit_transform(X)), color='blue')
plt.show()

StarcoderdataJupyterScriptsDedupFiltered