2016-12-28 4 views
0

私はPythonにはかなり新しいです。私はx_train変数とy_trainを作成していると私はロジスティック回帰を取得しようとしていますR.のように私は、ロジスティック回帰の概要を取得したいと思いPythonでの回帰の概要

import numpy as np 
import matplotlib.pyplot as plt 
from sklearn import linear_model 

clf = linear_model.LogisticRegression(C=1e5) 
clf.fit(x_train, y_train) 

私は何を得る:

LogisticRegression(C=100000.0, class_weight=None, dual=False, 
    fit_intercept=True, intercept_scaling=1, max_iter=100, 
    multi_class='ovr', n_jobs=1, penalty='l2', random_state=None, 
    solver='liblinear', tol=0.0001, verbose=0, warm_start=False) 

私は重要なレベルの要約、R2 eccを持っていたいと思います。

答えて

0

に電話すると、R となります。

意味はsklearnによって直接提供されていませんが、答えはhereであり、これはcodeです。

1

を使用することができR2を得るために

  • 私はstatsmodels図書館でご覧になることをお勧めします。 Sk-learnはすばらしいです(他の回答はR2やその他の指標を得る方法を提供します)。statsmodelsは、おそらくRで慣れ親しんだものに似た回帰の概要を提供します。

    例:

    import statsmodels.api as sm 
    from sklearn.datasets import make_blobs 
    
    x, y = make_blobs(n_samples=50, n_features=2, cluster_std=5.0, 
            centers=[(0,0), (2,2)], shuffle=False, random_state=12) 
    
    logit_model = sm.Logit(y, sm.add_constant(x)).fit() 
    print logit_model.summary() 
    
    Optimization terminated successfully. 
         Current function value: 0.620237 
         Iterations 5 
              Logit Regression Results       
    ============================================================================== 
    Dep. Variable:      y No. Observations:     50 
    Model:       Logit Df Residuals:      47 
    Method:       MLE Df Model:       2 
    Date:    Wed, 28 Dec 2016 Pseudo R-squ.:     0.1052 
    Time:      12:58:10 Log-Likelihood:    -31.012 
    converged:      True LL-Null:      -34.657 
                 LLR p-value:     0.02611 
    ============================================================================== 
           coef std err   z  P>|z|  [95.0% Conf. Int.] 
    ------------------------------------------------------------------------------ 
    const   -0.0813  0.308  -0.264  0.792  -0.684  0.522 
    x1    0.1230  0.065  1.888  0.059  -0.005  0.251 
    x2    0.1104  0.060  1.827  0.068  -0.008  0.229 
    ============================================================================== 
    

    あなたの代わりにあなたが.fit_regularized()を呼び出すとアルファパラメータ(正則強度)に渡すことができますロジット初期化後.fit()を呼び出すのでは、正則を追加したい場合。これを行うと、sk-learnのCパラメータは実際にはの正則化強度であることに注意してください。