我有一个数据集,它缺少一些我想预测的Y值。因此,为了首先创建一个模型,我放弃了Na,使用下面的代码->;RBall.dropna公司(subset=['nexthpr'],inplace=True)
import statsmodels.api as sm
from sklearn import linear_model
RBall.dropna(subset=['NextHPPR'], inplace = True)
X = RBall[['ReceivingTargets_x','SnapsPlayedPercentage','RushingAttempts_x', 'RushingAttempts_y']]
Y = RBall['NextHPPR']
lm = linear_model.LinearRegression()
model = lm.fit(X,Y)
这是我删除NAs之前的数据截图。 Note the NA's in NextHPPR, my Y variable in the regression
现在,我想用我的模型回去预测缺失的Na,我知道这是一个基本的问题,但这是我第一天使用python。非常感谢。你知道吗
我会用NumPy找到nan的索引,然后调用predict。你知道吗
相关问题 更多 >
编程相关推荐