Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/351.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
statsmodel中的MNLogit在Python中返回NaN_Python_Machine Learning_Logistic Regression_Statsmodels - Fatal编程技术网

statsmodel中的MNLogit在Python中返回NaN

statsmodel中的MNLogit在Python中返回NaN,python,machine-learning,logistic-regression,statsmodels,Python,Machine Learning,Logistic Regression,Statsmodels,我试图在数据集上使用statsmodels的MNLogit函数。当我尝试拟合模型时,我得到:“当前函数值:nan”。我还得到了所有系数的NaN值,标准误差,t值,P>| t |值。以下是我正在使用的代码: import statsmodels.api as sm import sklearn x1 = df.drop('Modes of travel preferred', axis=1) y1 = df['Modes of travel preferred'] x1_train, x1

我试图在数据集上使用statsmodels的MNLogit函数。当我尝试拟合模型时,我得到:“当前函数值:nan”。我还得到了所有系数的NaN值,标准误差,t值,P>| t |值。以下是我正在使用的代码:

import statsmodels.api as sm
import sklearn    
x1 = df.drop('Modes of travel preferred', axis=1)
y1 = df['Modes of travel preferred']
x1_train, x1_test, y1_train, y1_test = sklearn.model_selection.train_test_split(x1, y1, test_size = 0.20, random_state = 5)    
    
    logit_model=sm.MNLogit(y1_train, sm.add_constant(x1_train))
    logit_model
    result=logit_model.fit()
    stats1=result.summary()
    stats2=result.summary2()
    print(stats1)
    print(stats2)
我还得到以下输出:

/usr/local/lib/python3.6/dist-packages/statsmodels/discrete/discrete_model.py:2195: RuntimeWarning: overflow encountered in exp
  eXB = np.column_stack((np.ones(len(X)), np.exp(X)))
/usr/local/lib/python3.6/dist-packages/statsmodels/discrete/discrete_model.py:2196: RuntimeWarning: invalid value encountered in true_divide
  return eXB/eXB.sum(1)[:,None]
/usr/local/lib/python3.6/dist-packages/statsmodels/base/optimizer.py:299: RuntimeWarning: invalid value encountered in greater
  oldparams) > tol)):
/usr/local/lib/python3.6/dist-packages/scipy/stats/_distn_infrastructure.py:903: RuntimeWarning: invalid value encountered in greater
  return (a < x) & (x < b)
/usr/local/lib/python3.6/dist-packages/scipy/stats/_distn_infrastructure.py:903: RuntimeWarning: invalid value encountered in less
  return (a < x) & (x < b)
/usr/local/lib/python3.6/dist-packages/scipy/stats/_distn_infrastructure.py:1912: RuntimeWarning: invalid value encountered in less_equal
  cond2 = cond0 & (x <= _a)
/usr/local/lib/python3.6/dist packages/statsmodels/discrete/discrete_model.py:2195:RuntimeWarning:exp中遇到溢出
eXB=np.column\u堆栈((np.one(len(X)),np.exp(X)))
/usr/local/lib/python3.6/dist-packages/statsmodels/discrete/discrete\u-model.py:2196:RuntimeWarning:true\u-divide中遇到无效值
返回eXB/eXB.sum(1)[:,无]
/usr/local/lib/python3.6/dist-packages/statsmodels/base/optimizer.py:299:RuntimeWarning:在更高版本中遇到无效值
oldparams)>tol]:
/usr/local/lib/python3.6/dist-packages/scipy/stats/_-distn_-infrastructure.py:903:RuntimeWarning:在更大版本中遇到无效值
返回(a