LostTech.TensorFlow : API Documentation

Type LinearEstimator

Namespace tensorflow.contrib.learn

Parent Estimator

Interfaces ILinearEstimator

Linear model with user specified head.

THIS CLASS IS DEPRECATED. See [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md) for general migration instructions.

Train a generalized linear model to predict label value given observation of feature values.

Example: To do poisson regression, Input of `fit` and `evaluate` should have following features, otherwise there will be a KeyError:

* if `weight_column_name` is not `None`: key=weight_column_name, value=a `Tensor` * for column in `feature_columns`: - if isinstance(column, `SparseColumn`): key=column.name, value=a `SparseTensor` - if isinstance(column, `WeightedSparseColumn`): {key=id column name, value=a `SparseTensor`, key=weight column name, value=a `SparseTensor`} - if isinstance(column, `RealValuedColumn`): key=column.name, value=a `Tensor`
Show Example
sparse_column_a = sparse_column_with_hash_bucket(...)
            sparse_column_b = sparse_column_with_hash_bucket(...) 

sparse_feature_a_x_sparse_feature_b = crossed_column(...)

estimator = LinearEstimator( feature_columns=[sparse_column_a, sparse_feature_a_x_sparse_feature_b], head=head_lib.poisson_regression_head())

# Input builders def input_fn_train: # returns x, y ... def input_fn_eval: # returns x, y ... estimator.fit(input_fn=input_fn_train) estimator.evaluate(input_fn=input_fn_eval) estimator.predict(x=x)

Methods

Properties

Public static methods

LinearEstimator NewDyn(object feature_columns, object head, object model_dir, object weight_column_name, object optimizer, object gradient_clip_norm, ImplicitContainer<T> _joint_weights, object config, object feature_engineering_fn)

Construct a `LinearEstimator` object.
Parameters
object feature_columns
An iterable containing all the feature columns used by the model. All items in the set should be instances of classes derived from `FeatureColumn`.
object head
An instance of _Head class.
object model_dir
Directory to save model parameters, graph, etc. This can also be used to load checkpoints from the directory into a estimator to continue training a previously saved model.
object weight_column_name
A string defining feature column name representing weights. It is used to down weight or boost examples during training. It will be multiplied by the loss of the example.
object optimizer
An instance of `tf.Optimizer` used to train the model. If `None`, will use an Ftrl optimizer.
object gradient_clip_norm
A `float` > 0. If provided, gradients are clipped to their global norm with this clipping ratio. See tf.clip_by_global_norm for more details.
ImplicitContainer<T> _joint_weights
If True use a single (possibly partitioned) variable to store the weights. It's faster, but requires all feature columns are sparse and have the 'sum' combiner. Incompatible with SDCAOptimizer.
object config
`RunConfig` object to configure the runtime settings.
object feature_engineering_fn
Feature engineering function. Takes features and labels which are the output of `input_fn` and returns features and labels which will be fed into the model.
Returns
LinearEstimator
A `LinearEstimator` estimator.

Public properties

object config get;

object config_dyn get;

string model_dir get;

object model_dir_dyn get;

object model_fn get;

object model_fn_dyn get;

object PythonObject get;