如何将附加功能与tfidf向量结合

时间:2018-12-14 08:29:01

标签: python pandas machine-learning scikit-learn

我正在使用以下方法来训练线性回归器,以预测推文的转发。我正在使用“文本”作为功能,并使用“ retweet_count”作为要预测的目标。但是,我的数据还具有其他一些功能,例如 hasMedia,hasHashtag,followers_count,情感(它们是数字功能)。如何将这些功能与转换为tfidf向量的“ 文本”结合使用?

我已经尝试串联熊猫数据帧。然后,当我提供新的测试数据时,功能不匹配。请在Attributes mismatch between training and testing data in sklearn - linear regression

中查看我的问题
    id     product   date           price
0   220    6647     2014-09-01      100   #group 1
1   220    6647     2014-09-03      120   #group 1   --> pick this
2   220    6647     2014-09-05      0     #group 1
3   826    3380     2014-11-11      150   #group 2   --> pick this
4   826    3380     2014-12-09      23    #group 3   --> pick this
5   826    3380     2015-05-12      88    #group 4   --> pick this
6   901    4555     2015-05-15      32    #group 4   
7   901    4555     2015-10-05      542   #group 5   --> pick this
8   901    4555     2015-11-01      98    #group 6   --> pick this
  

数据样本

enter image description here

0 个答案:

没有答案
相关问题