在使用psm倾向匹配法的时候,运行到:m.fit_scores(balance=True, nmodels=100) Python报错:
Fitting Models on Balanced Samples: 1\100Error: Unable to coerce to Series, length must be 1: given 45310
Fitting Models on Balanced Samples: 1\100Error: Unable to coerce to Series, length must be 1: given 45310
Fitting Models on Balanced Samples: 1\100Error: Unable to coerce to Series, length must be 1: given 45310
Fitting Models on Balanced Samples: 1\100Error: Unable to coerce to Series, length must be 1: given 45310
Fitting Models on Balanced Samples: 1\100Error: Unable to coerce to Series, length must be 1: given 45310
Average Accuracy: nan%
想实现:
Fitting Models on Balanced Samples: 100\100
Average Accuracy: 66.06%
这样的结果
相关代码:
data.head()
test = data[data.if_follow == 1]
control = data[data.if_follow ==0]
m = Matcher(test,control,yvar="if_follow",exclude=["device_uuid","day_follow_pv","bros_user","bros_pv","dura","preserve_users","interact_user","interact_times","day","last_actday"])
np.random.seed(20170925)
m.fit_scores(balance=True, nmodels=100)
多谢~
你给的数据太多了,你的模型数据报错为
Unable to coerce to Series, length must be 1: given 45310
无法强制为系列,长度必须为1:得到45310
你看看是否是数据问题还是顺序问题
想问下楼主解决了吗,遇到一样的问题