Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #splitting data
  2. from sklearn.cross_validation import train_test_split
  3. X_train, X_test, Y_train, Y_test= train_test_split(X, Y, test_size=0.33,
  4. random_state=0)
  5.  
  6. #fitting simple linear regression to the training set
  7. from sklearn.linear_model import LinearRegression
  8. regressor=LinearRegression()
  9. regressor.fit(X_train,Y_train)
  10. #predicting the test set results
  11. Y_pred=regressor.predict(X_test)
  12.  
  13. #plotting the training set
  14. plt.plot(X_train,Y_train, color = 'red')
  15. plt.plot(X_train,regressor.predict(X_train), color = 'blue')
  16. plt.title('exp vs salary(training set)')
  17. plt.xlabel('exp')
  18. plt.ylabel('salary')
  19. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement