def build_estimator(model_dir): params = tf.contrib.tensor_forest.python.tensor_forest.ForestHParams( num_classes=15, num_features=3, num_trees=FLAGS.num_trees, max_nodes=FLAGS.max_nodes) return random_forest.TensorForestEstimator(params, model_dir=model_dir)
def build_estimator(model_dir): """Build an estimator.""" params = tensor_forest.ForestHParams( num_classes=1, regression=True, num_features=392, num_trees=FLAGS.num_trees, max_nodes=FLAGS.max_nodes, ).fill() return random_forest.TensorForestEstimator(params, model_dir=model_dir)
def build_estimator(model_dir): """Build an estimator.""" params = tf.contrib.tensor_forest.python.tensor_forest.ForestHParams( num_classes=10, num_features=784, num_trees=FLAGS.num_trees, max_nodes=FLAGS.max_nodes) graph_builder_class = tensor_forest.RandomForestGraphs if FLAGS.use_training_loss: graph_builder_class = tensor_forest.TrainingLossForest return random_forest.TensorForestEstimator( params, graph_builder_class=graph_builder_class, model_dir=model_dir)
def testClassification(self): """Tests multi-class classification using matrix data as input.""" hparams = tensor_forest.ForestHParams(num_trees=3, max_nodes=1000, num_classes=3, num_features=4, split_after_samples=20) classifier = random_forest.TensorForestEstimator(hparams.fill()) iris = base.load_iris() data = iris.data.astype(np.float32) labels = iris.target.astype(np.float32) classifier.fit(x=data, y=labels, steps=100, batch_size=50) classifier.evaluate(x=data, y=labels, steps=10)
def testClassificationTrainingLoss(self): """Tests multi-class classification using matrix data as input.""" hparams = tensor_forest.ForestHParams(num_trees=3, max_nodes=1000, num_classes=3, num_features=4) classifier = random_forest.TensorForestEstimator( hparams, graph_builder_class=(tensor_forest.TrainingLossForest)) iris = base.load_iris() data = iris.data.astype(np.float32) labels = iris.target.astype(np.float32) monitors = [random_forest.TensorForestLossHook(10)] classifier.fit(x=data, y=labels, steps=100, monitors=monitors) classifier.evaluate(x=data, y=labels, steps=10)
def testRegression(self): """Tests multi-class classification using matrix data as input.""" hparams = tensor_forest.ForestHParams(num_trees=3, max_nodes=1000, num_classes=1, num_features=13, regression=True, split_after_samples=20) regressor = random_forest.TensorForestEstimator(hparams.fill()) boston = base.load_boston() data = boston.data.astype(np.float32) labels = boston.target.astype(np.float32) regressor.fit(x=data, y=labels, steps=100, batch_size=50) regressor.evaluate(x=data, y=labels, steps=10)