奇怪,Python居然不能用一个变量跑逻辑回归?
做为初学python的菜鸟,我怎么发现python不能用一个预测变量跑逻辑回归?这个是什么道理?import numpy as np
import pandas as pd
from sklearn.linear_model import LogisticRegression
sample_set = pd.DataFrame({'Target': np.random.randint(0,2,30),
'd1':np.random.randn(30)
}
)
modelLR=LogisticRegression()
modelLR = modelLR.fit(sample_set['d1'],sample_set['Target'])
居然报错如下:Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
哪位大神解释一下?非常感谢!