def cross_val_predict(self, fname_out = None):
"""
This function is added to save the result of the predicted values.
"""
yp = cross_validation.cross_val_predict( self.best_estimator_, self.X, self.y)
idx = pd.MultiIndex.from_product([['yp'], self.df['y'].columns])
yp_df = pd.DataFrame( yp, index = self.df.index, columns=idx)
df_out_org = self.df.merge( yp_df, left_index = True, right_index = True)
self.df_out = DataFrame( df_out_org[["X", "y", "yp", "param"]])
# df_out = pd.concat([self.df, yp_df], axis = 1)
self.df_out.to_csv_excel( '_out', self.fname, fname_out)
return yp
评论列表
文章目录