def testRegressorTrainInMemoryWithDataset(self): train_input_fn = _make_train_input_fn_dataset(is_classification=False) predict_input_fn = numpy_io.numpy_input_fn(x=FEATURES_DICT, y=None, batch_size=1, num_epochs=1, shuffle=False) est = boosted_trees.boosted_trees_regressor_train_in_memory( train_input_fn=train_input_fn, feature_columns=self._feature_columns, n_trees=1, max_depth=5) # It will stop after 5 steps because of the max depth and num trees. self._assert_checkpoint(est.model_dir, global_step=5, finalized_trees=1, attempted_layers=5) # Check evaluate and predict. eval_res = est.evaluate(input_fn=train_input_fn, steps=1) self.assertAllClose(eval_res['average_loss'], 2.478283) predictions = list(est.predict(input_fn=predict_input_fn)) self.assertAllClose( [[0.571619], [0.262821], [0.124549], [0.956801], [1.769801]], [pred['predictions'] for pred in predictions])
def DISABLED_testRegressorTrainInMemoryWithFloatColumns(self): train_input_fn = _make_train_input_fn(is_classification=False) predict_input_fn = numpy_io.numpy_input_fn(x=FEATURES_DICT, y=None, batch_size=1, num_epochs=1, shuffle=False) est = boosted_trees.boosted_trees_regressor_train_in_memory( train_input_fn=train_input_fn, feature_columns=self._numeric_feature_columns, n_trees=1, max_depth=5, quantile_sketch_epsilon=0.33) # It will stop after 5 steps because of the max depth and num trees. self._assert_checkpoint(est.model_dir, global_step=5, finalized_trees=1, attempted_layers=5, bucket_boundaries=[[-2.001, -1.999, 12.5], [-3., 0.4995, 2.], [-100., 20., 102.75]]) # Check evaluate and predict. eval_res = est.evaluate(input_fn=train_input_fn, steps=1) self.assertAllClose(eval_res['average_loss'], 2.4182191) predictions = list(est.predict(input_fn=predict_input_fn)) self.assertAllClose( [[0.663432], [0.31798199], [0.081902], [0.75843203], [1.86384201]], [pred['predictions'] for pred in predictions])