【发布时间】:2019-09-03 12:00:53
【问题描述】:
我正在尝试使用 pymatch 构建分数匹配。不幸的是,我收到以下错误
Fitting Models on Balanced Samples: 1\200Error: Unable to coerce to Series, length must be 1: given 1898
这是我的代码
from sklearn.datasets.samples_generator import make_blobs
from pymatch.Matcher import Matcher
import pandas as pd
import numpy as np
X, y = make_blobs(n_samples=5000, centers=2, n_features=2, cluster_std=3.5)
df = pd.DataFrame(dict(x=X[:,0], y=X[:,1], label=y))
df['population'] = np.random.choice([1, 0], size=len(df), p=[0.8, 0.2])
control = df[df.label == 1]
test = df[df.label == 0]
m = Matcher(test, control, yvar="population", exclude=['label'])
m.fit_scores(balance=True, nmodels=200)
如果我运行此代码,我将收到错误消息。我很确定我之前能够运行它,但是在更改了一些版本之后,它就不再起作用了。不幸的是,我无法通过回到以前的版本来修复它,所以不确定这里发生了什么......
【问题讨论】:
标签: python