## How to train a Logistic Regression model?

Question

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

It will take less than 1 minute to register for lifetime. Bonus Tip - We don't send OTP to your email id Make Sure to use your own email id for free books and giveaways

## Answers ( 2 )

You have to demonstrate an understanding of what the typical goals of a logistic regression are (classification, prediction, etc. and bring up a few examples and use cases.

from sklearn.linear_model import LogisticRegression

model = LogisticRegression(random_state=1) # using default parameters

model.fit(train_data, target_var)

y_pred = model.predict(test_data) # will give you the class

y_pred_prob = model.predict_proba(test_data) # will give class probabilities