Checking if the scikit-learn logistic regression works
Scikit-learn logistic regression is actually a black box. So I would like to check if it is actually working as expected.
Here is a model.
import numpy as np
from sklearn.linear_model import LogisticRegression
lr_model = LogisticRegression()
Sample data:
X = np.array([[0.0, 1.0], [1,0.0], [0.5, 0.5], [3, 0.5], [2, 2], [2, 2.5]])
y = np.array([0, 0, 0, 1, 1, 1])
The first three records' features are small and have outputs of 0. On the other hand, the second half's features are relatively big and have outputs of 1.
Prediction
I would like to have it predict the outputs.
X = np.array([[5.0, 1.0], [3,0.0], [0.5, 0.5], [0.5, 0.5], [2, 0.5], [2, 0.5]])
y_pred = lr_model.predict(X)
print("Prediction on training set:", y_pred)
The third and fourth data are small. Therefore, you can expect outputs of 0 for those two.
Here is the prediction.
Prediction on training set: [1 1 0 0 1 1]
It seems like working properly.