Skip to content

Instantly share code, notes, and snippets.

@MariaLavrovskaya
Created June 14, 2019 12:06
Show Gist options
  • Save MariaLavrovskaya/6943b82f6be100dce5e2873628c151f0 to your computer and use it in GitHub Desktop.
Save MariaLavrovskaya/6943b82f6be100dce5e2873628c151f0 to your computer and use it in GitHub Desktop.
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=False) # 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment