def train_and_cv_error(self, features, hyper_params):
self.train_for_cv(features, hyper_params)
target = self.train_and_cv[self.target]
prediction = self.train_and_cv['cv_prediction']
if prediction.isnull().any():
Exception('Some predictions where N/A.')
self._truncate_predictions(self.train_and_cv, 'cv_prediction')
loss = self.eval_metric.error(target, prediction)
loss_variance = self.bootstrap_errors_(target, prediction).var()
if loss is None or np.isnan(loss) or loss_variance is None or np.isnan(loss_variance):
raise Exception('Could not calculate cv error.')
return {
'status': STATUS_OK,
'loss': loss,
'loss_variance': loss_variance
}
评论列表
文章目录