pdlearn.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:jamespy_py3 作者: jskDr 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号