This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on Fri Dec 21 18:59:49 2018 | |
@author: Nhan Tran | |
""" | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import pandas as pd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on Mon Nov 12 18:19:23 2018 | |
@author: Nhan Tran | |
""" | |
""" | |
y = b0 + b1*x1 | |
y: dependent variable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Visualizing the Training set results | |
viz_train = plt | |
viz_train.scatter(X_train, y_train, color='red') | |
viz_train.plot(X_train, regressor.predict(X_train), color='blue') | |
viz_train.title('Salary VS Experience (Training set)') | |
viz_train.xlabel('Year of Experience') | |
viz_train.ylabel('Salary') | |
viz_train.show() | |
# Visualizing the Test set results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
# Importing the dataset | |
dataset = pd.read_csv('salary_data.csv') | |
X = dataset.iloc[:, :-1].values #get a copy of dataset exclude last column | |
y = dataset.iloc[:, 1].values #get array of dataset in column 1st |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Predicting the result of 5 Years Experience | |
y_pred = regressor.predict(5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fitting Polynomial Regression to the dataset | |
from sklearn.preprocessing import PolynomialFeatures | |
poly_reg = PolynomialFeatures(degree=4) | |
X_poly = poly_reg.fit_transform(X) | |
pol_reg = LinearRegression() | |
pol_reg.fit(X_poly, y) | |
# Visualizing the Polymonial Regression results | |
def viz_polymonial(): | |
plt.scatter(X, y, color='red') |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder