tf.contrib.learn.LogisticRegressor(model_fn, thresholds=None, model_dir=None, config=None, feature_engineering_fn=None)

tf.contrib.learn.LogisticRegressor(model_fn, thresholds=None, model_dir=None, config=None, feature_engineering_fn=None)

See the guide: Learn (contrib) > Estimators

Builds a logistic regression Estimator for binary classification.

This method provides a basic Estimator with some additional metrics for custom binary classification models, including AUC, precision/recall and accuracy.

Example:

  # See tf.contrib.learn.Estimator(...) for details on model_fn structure
  def my_model_fn(...):
    pass

  estimator = LogisticRegressor(model_fn=my_model_fn)

  # Input builders
  def input_fn_train:
    pass

  estimator.fit(input_fn=input_fn_train)
  estimator.predict(x=x)

Args:

  • model_fn: Model function with the signature: (features, labels, mode) -> (predictions, loss, train_op). Expects the returned predictions to be probabilities in [0.0, 1.0].
  • thresholds: List of floating point thresholds to use for accuracy, precision, and recall metrics. If None, defaults to [0.5].
  • model_dir: Directory to save model parameters, graphs, etc. This can also be used to load checkpoints from the directory into a estimator to continue training a previously saved model.
  • config: A RunConfig configuration 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:

A tf.contrib.learn.Estimator instance.

Defined in tensorflow/contrib/learn/python/learn/estimators/logistic_regressor.py.