<commit_before># Copyright 2016 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

"""Classifier class."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from tensorflow.contrib import metrics as metrics_lib
from tensorflow.contrib.framework import deprecated_arg_values
from tensorflow.contrib.learn.python.learn.estimators import estimator
from tensorflow.contrib.session_bundle import exporter
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import nn


def classification_signature_fn(examples, unused_features, predictions):
  """Creates classification signature from given examples and predictions.

  Args:
    examples: `Tensor`.
    unused_features: `dict` of `Tensor`s.
    predictions: `dict` of `Tensor`s.

  Returns:
    Tuple of default classification signature and empty named signatures.
  """
  signature = exporter.classification_signature(
      examples,
      classes_tensor=predictions[Classifier.CLASS_OUTPUT],
      scores_tensor=predictions[Classifier.PROBABILITY_OUTPUT])
  return signature, {}


def _get_classifier_metrics(unused_n_classes):
  return {
      ('accuracy', 'classes'): metrics_lib.streaming_accuracy
  }


class Classifier(estimator.Estimator):
  """Classifier single output Estimator.

  Given logits generating function, provides class / probabilities heads and
  functions to work with them.
  """

  CLASS_OUTPUT = 'classes'
  PROBABILITY_OUTPUT = 'probabilities'

  def __init__(self, model_fn, n_classes, model_dir=None, config=None,
               params=None, feature_engineering_fn=None):
    """Constructor for Classifier.<commit_msg>Deprecate Classifier. Use Estimator instead. Change: 137356790<commit_after># Copyright 2016 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

"""Classifier class."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from tensorflow.contrib import metrics as metrics_lib
from tensorflow.contrib.framework import deprecated
from tensorflow.contrib.framework import deprecated_arg_values
from tensorflow.contrib.learn.python.learn.estimators import estimator
from tensorflow.contrib.session_bundle import exporter
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import nn


@deprecated('2016-11-30', 'Please write an appropriate function for use with'
            ' your estimator.')
def classification_signature_fn(examples, unused_features, predictions):
  """Creates classification signature from given examples and predictions.

  Args:
    examples: `Tensor`.
    unused_features: `dict` of `Tensor`s.
    predictions: `dict` of `Tensor`s.

  Returns:
    Tuple of default classification signature and empty named signatures.
  """
  signature = exporter.classification_signature(
      examples,
      classes_tensor=predictions[Classifier.CLASS_OUTPUT],
      scores_tensor=predictions[Classifier.PROBABILITY_OUTPUT])
  return signature, {}


def _get_classifier_metrics(unused_n_classes):
  return {
      ('accuracy', 'classes'): metrics_lib.streaming_accuracy
  }


class Classifier(estimator.Estimator):
  """Classifier single output Estimator.

  Given logits generating function, provides class / probabilities heads and
  functions to work with them.
  """

  CLASS_OUTPUT = 'classes'
  PROBABILITY_OUTPUT = 'probabilities'

  @deprecated('2016-11-30', 'Please use Estimator directly.')
  def __init__(self, model_fn, n_classes, model_dir=None, config=None,
               params=None, feature_engineering_fn=None):
    """Constructor for Classifier.
{'fraction_non_alphanumeric': 0.10507916923709644, 'fraction_numerical': 0.008431009664815957, 'mean_word_length': 4.990147783251231, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3314577', 'n_tokens_mistral': 1290, 'n_tokens_neox': 1223, 'n_words': 441}