Beispiel #1
0
                               select_binary, validate_select_binary)
from runtime.tensorflow.explain import explain
from runtime.tensorflow.predict import pred
from runtime.tensorflow.train import train

if __name__ == "__main__":
    # Train and explain BoostedTreesClassifier
    train(datasource=datasource,
          estimator_string="tf.estimator.BoostedTreesClassifier",
          select="SELECT * FROM iris.train where class!=2",
          validation_select="SELECT * FROM iris.test where class!=2",
          feature_columns=feature_columns,
          feature_column_names=feature_column_names,
          feature_metas=feature_metas,
          label_meta=label_meta,
          model_params={
              "n_batches_per_layer": 1,
              "n_classes": 2,
              "n_trees": 50,
              "center_bias": True
          },
          save="btmodel",
          batch_size=100,
          epoch=20,
          verbose=0)

    explain(datasource=datasource,
            estimator_string="tf.estimator.BoostedTreesClassifier",
            select="SELECT * FROM iris.test where class!=2",
            feature_columns=feature_columns,
            feature_column_names=feature_column_names,
            feature_metas=feature_metas,
Beispiel #2
0
label_meta = {
    "feature_name": "target",
    "dtype": "float32",
    "delimiter": "",
    "shape": [],
    "is_sparse": "false" == "true"
}

if __name__ == "__main__":
    train(datasource=datasource,
          estimator_string="sqlflow_models.DNNRegressor",
          select=select,
          validation_select=validation_select,
          feature_columns=feature_columns,
          feature_column_names=feature_column_names,
          feature_metas=feature_metas,
          label_meta=label_meta,
          model_params={"hidden_units": [10, 20]},
          validation_metrics=["CategoricalAccuracy"],
          save="myregmodel_keras",
          batch_size=1,
          epoch=3,
          verbose=0)
    pred(datasource=datasource,
         estimator_string="sqlflow_models.DNNRegressor",
         select=validation_select,
         result_table="housing.predict",
         feature_columns=feature_columns,
         feature_column_names=feature_column_names,
         feature_column_names_map=feature_column_names_map,
         train_label_name=label_meta["feature_name"],
         result_col_name=label_meta["feature_name"],
Beispiel #3
0
from estimator_example import (datasource, feature_column_names,
                               feature_columns, feature_metas, label_meta)
from runtime.tensorflow.evaluate import evaluate
from runtime.tensorflow.train import train

if __name__ == "__main__":
    # Test evaluation on an estimator model
    train(datasource=datasource,
          estimator_string="tf.estimator.DNNClassifier",
          select="SELECT * FROM iris.train where class!=2",
          validation_select="SELECT * FROM iris.test where class!=2",
          feature_columns=feature_columns,
          feature_column_names=feature_column_names,
          feature_metas=feature_metas,
          label_meta=label_meta,
          model_params={
              "n_classes": 2,
              "hidden_units": [128, 32]
          },
          save="bin_model",
          batch_size=10,
          epoch=20,
          verbose=0)
    # FIXME(typhoonzero): need to re-create result table: iris.evaluate_result?
    evaluate(
        datasource=datasource,
        estimator_string="tf.estimator.DNNClassifier",
        select="SELECT * FROM iris.test where class!=2",
        result_table="",
        feature_columns=feature_columns,
        feature_column_names=feature_column_names,
Beispiel #4
0
    "delimiter": "",
    "shape": [],
    "is_sparse": "false" == "true"
}

if __name__ == "__main__":
    # tf.python.training.basic_session_run_hooks.LoggingTensorHook
    # = runtime.tensorflow.train.PrintTensorsHook
    train(datasource=datasource,
          estimator_string="DNNClassifier",
          select=select,
          validation_select=validate_select,
          feature_columns=feature_columns,
          feature_column_names=feature_column_names,
          feature_metas=feature_metas,
          label_meta=label_meta,
          model_params={
              "n_classes": 3,
              "hidden_units": [10, 20]
          },
          save="mymodel",
          batch_size=1,
          epoch=3,
          verbose=0)
    train(datasource=datasource,
          estimator_string="DNNClassifier",
          select=select_binary,
          validation_select=validate_select_binary,
          feature_columns=feature_columns,
          feature_column_names=feature_column_names,
          feature_metas=feature_metas,
          label_meta=label_meta,
Beispiel #5
0
                                                  feature_columns,
                                                  feature_metas, label_meta,
                                                  select, validate_select)
from runtime.tensorflow.predict import pred
from runtime.tensorflow.train import train

if __name__ == "__main__":
    train(datasource=datasource,
          estimator_string="sqlflow_models.DNNClassifier",
          select=select,
          validation_select=validate_select,
          feature_columns=feature_columns,
          feature_column_names=feature_column_names,
          feature_metas=feature_metas,
          label_meta=label_meta,
          model_params={
              "n_classes": 3,
              "hidden_units": [10, 20]
          },
          validation_metrics=["CategoricalAccuracy"],
          save="mymodel_keras",
          batch_size=1,
          epoch=3,
          verbose=0)
    pred(datasource=datasource,
         estimator_string="sqlflow_models.DNNClassifier",
         select=select,
         result_table="iris.predict",
         feature_columns=feature_columns,
         feature_column_names=feature_column_names,
         feature_column_names_map=feature_column_names_map,
Beispiel #6
0
def do_train(params):
    train.train(params["datasource"], params["estimator_string"],
                params["select"], params["validation_select"],
                params["feature_columns"], params["feature_column_names"],
                **params)