Python回归器库摘要函数为逻辑回归返回ValueError

Python回归器库摘要函数为逻辑回归返回ValueError,python,scikit-learn,logistic-regression,statsmodels,valueerror,Python,Scikit Learn,Logistic Regression,Statsmodels,Valueerror,我使用的是来自sklearn的python inbulit boston数据集,目标变量是CHAS 我从sklearn pkg建立了逻辑回归模型。我使用回归器库来获得模型输出的汇总统计数据,但我面临以下错误。请帮助我这一点,并请让我知道,如果你需要进一步的信息 在以下链接[1]中查找有关回归器库的更多信息: 请查找我用于模型构建的以下python代码: import numpy as np from sklearn import datasets import pandas as pd bo

我使用的是来自sklearn的python inbulit boston数据集,目标变量是CHAS

我从sklearn pkg建立了逻辑回归模型。我使用回归器库来获得模型输出的汇总统计数据,但我面临以下错误。请帮助我这一点,并请让我知道,如果你需要进一步的信息

在以下链接[1]中查找有关回归器库的更多信息:

请查找我用于模型构建的以下python代码:

import numpy as np
from sklearn import datasets
import pandas as pd

bostonn = datasets.load_boston()
boston = pd.DataFrame(bostonn.data , columns= bostonn['feature_names'])
print(boston.head())

X = boston.drop('CHAS' , axis =1)
y = boston.CHAS.astype('category')

from sklearn.linear_model import LogisticRegression
from regressors import stats
log_mod=LogisticRegression(random_state=123)
model=log_mod.fit(X,y)

stats.summary(model, X, y , xlabels=None)
我得到以下错误:

ValueErrorTraceback (most recent call last)
in ()
1 #xlabels = boston.feature_names[which_betas]
----> 2 stats.summary(model, X, y ,xlabels=None)

251     )
252     coef_df['Estimate'] = np.concatenate(
--> 253 (np.round(np.array([clf.intercept_]), 6), np.round((clf.coef_), 6)))
254 coef_df['Std. Error'] = np.round(coef_se(clf, X, y), 6)
255 coef_df['t value'] = np.round(coef_tval(clf, X, y), 4)

ValueError: all the input array dimensions except for the concatenation axis must match exactly
ValueError:除连接轴之外的所有输入数组维度必须完全匹配

还有其他帖子也有类似的错误,但这些解决方案没有帮助
我的问题。上面附加的链接提供了有关摘要功能实际工作方式的信息。如果您需要更多信息,请告诉我。

@James Z,你能帮我一下吗?对不起,我不知道这方面的任何信息。
logisticsregression
不是一个回归器。它是一个分类器。
print(X.shape,y.shape)
的输出是什么?@BlackBear它与
X,y
无关,而是当模型为
fit()
时学习到的
coef\uuuu>和
intercept\uuu
的形状。这与scikit学习中的回归器和分类器不同,还取决于其他因素。OP使用的库是关于回归模型的,其中as
LogisticRegression
(尽管其名称)是一个分类器。