Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/288.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
Python 按行分组整数并将其放入逻辑回归模型序列误差_Python_Machine Learning_Encoding_Logistic Regression - Fatal编程技术网

Python 按行分组整数并将其放入逻辑回归模型序列误差

Python 按行分组整数并将其放入逻辑回归模型序列误差,python,machine-learning,encoding,logistic-regression,Python,Machine Learning,Encoding,Logistic Regression,我是一个模型制作的初学者,我有一个关于逻辑回归模型的问题 我想预测客户转化率,我想根据用户id对客户的旅程进行分组,然后将旅程作为X值,将转化率作为y。但是,当我这样做时,我会得到错误: ValueError:使用序列设置数组元素 就我所知,逻辑模型不可能将序列作为输入正确吗 为了澄清,接触点是不同接触点的字符串,例如谷歌、付费搜索、活动1和有机搜索。我标记了编码,因为模型不能接受字符串,然后按照上面所示进行分组 from sklearn.preprocessing import LabelEn

我是一个模型制作的初学者,我有一个关于逻辑回归模型的问题

我想预测客户转化率,我想根据用户id对客户的旅程进行分组,然后将旅程作为X值,将转化率作为y。但是,当我这样做时,我会得到错误:

ValueError:使用序列设置数组元素

就我所知,逻辑模型不可能将序列作为输入正确吗

为了澄清,接触点是不同接触点的字符串,例如谷歌、付费搜索、活动1和有机搜索。我标记了编码,因为模型不能接受字符串,然后按照上面所示进行分组

from sklearn.preprocessing import LabelEncoder
# integer encode
le = LabelEncoder()
df['touchpoints_id'] = le.fit_transform(df['touchpoints'])

google,organic,winkel,Organic Search           1
Unknown,email,automation,E-mail - Automation    2

df=df.groupby('jid').agg({'conversion':'sum', 'path': lambda 
x:`x.str.strip().tolist()}).reset_index()`

User ID   Touchpoints   Conversion
    1           87, 87       1
    2            31          0
    3           1             1
那么,我的理解是否正确呢。我不应该把它们分组,而是把它们单独当作int

像这样:

User id   Touchpoints  Conversion
1           87          0
1           87           0
2           37           0
3           1           1

X= np.array(df['touchpoints'])
y= np.array(df['conversion'])
提前谢谢