Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. from sklearn import linear_model
  4. xmin,xmax=-7,7 #Test set; straight line with Gaussian noise
  5. n_samples=77
  6. np.random.seed(0)
  7. x=np.random.normal(size=n_samples)
  8. y=(x>0).astype(np.float)
  9. #Import Library
  10. from sklearn.linear_model import LogisticRegression
  11. #Assumed you have, X (predictor) and Y (target) for training data set and x_test(predictor) of test_dataset
  12. # Create logistic regression object
  13. model = LogisticRegression()
  14. # Train the model using the training sets and check score
  15. model.fit(X, y)
  16. model.score(X, y)
  17. #Equation coefficient and Intercept
  18. print('Coefficient: \n', model.coef_)
  19. print('Intercept: \n', model.intercept_)
  20. #Predict Output
  21. predicted= model.predict(x_test)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement