below is the code used for building logistic regression. please help in in understanding the code.
from sklearn.linear_model import LogisticRegression # ----importing libraries
log.fit(X_train_scale,Y_train) #----------building the model
we are not predicting with test data with the above model and then comparing the accuracy in next line bit confused pls need your inputs
Checking the model’s accuracy
Out : 0.75
To define a machine learning model with scikit-learn, you have to follow specific steps
- STEP 1: Import the algorithm you want to run
- STEP 2: Define parameters that you want your machine learning model to have
- STEP 3: Train the model
- STEP 4: Test the model
# step 1
from sklearn.linear_model import LogisticRegression
# step 2
# step 3
# step 4
Hope this helps!
log.predict(X_test) here we are not calling the model log.fit which we have created in step 3
What is penalty=‘l2’,C=.01)#--------kindly explain.
In the step 3rd, we have fit the model(log) on train so after training this model, we can refer this trained model again with the name log.
Here is the link for parameters in sklearn LogisticRegression.