import numpy as np
import sklearn
from sklearn.preprocessing import StandardScaler
#example data for X and y
y = np.random.randint(0,2,1000)
X = np.random.rand(y.size, 3)
#common practice to normalize X so no variable is carrying more weight in loss calculation
scaler = StandardScaler()
scaler.fit(X)
X_scaled = scaler.transform(X)
#default to L2 regularization, C defaults to 1 (the strenght of regularization)
lr = sklearn.linear_model.LogisticRegression()
#user cross validation to select the best hyper parameters
lr = sklearn.linear_model.LogisticRegressionCV(cv=5)
#fit the lr model and print coefficients and intercept
lr.fit(X_scaled, y)
print(lr.coef_)
print(lr.intercept_)
#use the model to predict new data
X_pred = np.random.rand(10, 3)
X_pred = scaler.transform(X_pred)
y_pred = lr.predict_proba(X_pred)
print(y_pred)