Logistic Regression with Sklearn
Here we initialise and train a Logistic Regression model before using the model to make predictions. Finally we find the intercept and cofficients of the model along with analysing the models performance on test data using the Classification Report.
#Import Library from sklearn.linear_model import LogisticRegression #Initialise & Train Model model = LogisticRegression() model.fit(X_train, y_train) #Use Model to Make Predictions y_pred = model.predict(X_test) #Get the Model Intercept & Coefficients print('Intercept:',model.intercept_) coef = pd.DataFrame(model.coef_.reshape(30,1), cols, columns=['Coefficients']) print(coef) #Get the Classification Report from sklearn.metrics import classification_report print(classification_report(y_test, y_pred))
By analyseup - Last Updated Jan. 10, 2022, 11:27 p.m.