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.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# Predicting a new result with Linear Regression | |
lin_reg.predict([[5.5]]) | |
#output should be 249500 | |
# Predicting a new result with Polymonial Regression | |
pol_reg.predict(poly_reg.fit_transform([[5.5]])) | |
#output should be 132148.43750003 |
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') |
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 Linear Regression to the dataset | |
from sklearn.linear_model import LinearRegression | |
lin_reg = LinearRegression() | |
lin_reg.fit(X, y) | |
# Visualizing the Linear Regression results | |
def viz_linear(): | |
plt.scatter(X, y, color='red') | |
plt.plot(X, lin_reg.predict(X), color='blue') | |
plt.title('Truth or Bluff (Linear Regression)') |
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
# Splitting the dataset into the Training set and Test set | |
from sklearn.model_selection import train_test_split | |
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0) |
NewerOlder