Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- from sklearn import linear_model
- xmin,xmax=-7,7 #Test set; straight line with Gaussian noise
- n_samples=77
- np.random.seed(0)
- x=np.random.normal(size=n_samples)
- y=(x>0).astype(np.float)
- #Import Library
- from sklearn.linear_model import LogisticRegression
- #Assumed you have, X (predictor) and Y (target) for training data set and x_test(predictor) of test_dataset
- # Create logistic regression object
- model = LogisticRegression()
- # Train the model using the training sets and check score
- model.fit(X, y)
- model.score(X, y)
- #Equation coefficient and Intercept
- print('Coefficient: \n', model.coef_)
- print('Intercept: \n', model.intercept_)
- #Predict Output
- predicted= model.predict(x_test)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement