Created
October 15, 2019 06:57
-
-
Save MariaLavrovskaya/dbba8d400fc2d9df55edcafa05816080 to your computer and use it in GitHub Desktop.
airbnb_21
This file contains hidden or 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
from sklearn import linear_model | |
from sklearn.model_selection import train_test_split | |
X_train, X_test, Y_train, Y_test = train_test_split(X_2, y,test_size = 0.25, random_state = 0) | |
# Create linear regression object | |
regr = linear_model.LinearRegression(fit_intercept=True) # Do not use fit_intercept = False if you have removed 1 column after dummy encoding | |
# Train the model using the training sets | |
regr.fit(X_train, Y_train) | |
y_pred = regr.predict(X_test) | |
#Checking between observed and predicted data | |
df = pd.DataFrame({'Actual': Y_test.values.flatten(), 'Predicted': y_pred.flatten()}) | |
df.head(25) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment