长话短说我开始学习scikit learn,现在正在清理我的住房数据。问题是,有些功能有很多0值(例如,由于许多房屋没有2楼,所以2楼的值)。我尝试了一些想到的方法,比如合并所有的区域特征或者将它们转换成二进制(比如有或者没有第二层)。 我在sci工具包学习文档中遇到了power\u转换函数,我不想深入研究,只想尝试一下。像这样:
heterosc_features = ['MasVnrArea','BsmtFinSF1','2ndFlrSF','WoodDeckSF','OpenPorchSF']#features #that need to be transformed
def power_power_transform(features):
for feature in features:
#assigning current feature for simplicity
cur_feature = modified_prepared_data[feature]
#converting it to numpy so the function accepts it
cur_feature = cur_feature.to_numpy()
#reshaping it, otherwise it would spit an error
cur_feature = cur_feature.reshape(-1,1)
#initializing the function
power_transform(cur_feature, method='yeo-johnson')
#assigning transformed numpy array back to pandas column
modified_prepared_data[feature] = cur_feature
power_power_transform(heterosc_features)
线性回归RMSE变差,CV后平均RMSE变化不大。我错过什么了吗
目前没有回答
相关问题 更多 >
编程相关推荐