Trained the logistic regression

%%time logit = LogisticRegression(n_jobs=1, random_state=17) logit.fit (X_train_sparse, y_train) 

Answer:

 Wall time: 8.54 s 

After calling logit

 logit или logit.predict(X_test,_sparse[0, :]) 

I have an error:

 NameError Traceback (most recent call last) <ipython-input-113-cefa38cc2297> in <module> ----> 1 logit NameError: name 'logit' is not defined 

Why can't I call logit if the training has passed without errors?

    1 answer 1

    Something you do not agree. Try the following block:

     from sklearn.datasets import load_iris from sklearn.linear_model import LogisticRegression X, y = load_iris(return_X_y=True) %%time logit = LogisticRegression(n_jobs=1, random_state=17) logit.fit (X, y) Wall time: 998 µs logit Out[46]: LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True, intercept_scaling=1, max_iter=100, multi_class='warn', n_jobs=1, penalty='l2', random_state=17, solver='warn', tol=0.0001, verbose=0, warm_start=False) 
    • I executed this code, but now after the block: %% time ... logit.fit (X, y), I’m getting warnings: C: \ Users \ ivan1 \ Anaconda3 \ lib \ site-packages \ sklearn \ linear_model \ logistic. py: 433: FutureWarning: Default solver will be changed to 'lbfgs' in 0.22. Specify a solver to silence this warning. FutureWarning) C: \ Users \ ivan1 \ Anaconda3 \ lib \ site-packages \ sklearn \ linear_model \ logistic.py: 460: FutureWarning: Default multi_class will change to 'auto' in 0.22. Specify the multi_class option to silence this warning. "this warning.", FutureWarning). The error associated with the "logit" is not lost - ivan100096