def fit(self, xy_file, fname_out):
"""
All grid results will be saved later,
although only the best result is saved.
"""
df = read_csv( xy_file)
X = df['X'].values
y = df['y'].values
super().fit( X, y)
yp = cross_validation.cross_val_predict( self.best_estimator_, X, y)
m_idx = pd.MultiIndex.from_product([['yp'], df['y'].columns])
yp_df = pd.DataFrame( yp, index = df.index, columns=m_idx)
df_out = pd.concat([df, yp_df], axis = 1)
df_out.to_csv( fname_out)
return self
评论列表
文章目录