class_docstr: Intent classifier which uses a Logistic Regression underneath
class_docstr_tok: ["Intent","classifier","which","uses","a","Logistic","Regression","underneath"]
docstr: Fits the intent classifier with a valid Snips dataset
  
  Returns:
      :class:`LogRegIntentClassifier`: The same instance, trained
docstr_tok: ["Fits","the","intent","classifier","with","a","valid","Snips","dataset","Returns",":",":","class",":","`","LogRegIntentClassifier","`",":","The","same","instance",",","trained"]
code: def fit(self, dataset):
      """Fits the intent classifier with a valid Snips dataset
  
      Returns:
          :class:`LogRegIntentClassifier`: The same instance, trained
      """
      from sklearn.linear_model import SGDClassifier
      from sklearn.utils import compute_class_weight
  
      logger.info("Fitting LogRegIntentClassifier...")
      dataset = validate_and_format_dataset(dataset)
      self.load_resources_if_needed(dataset[LANGUAGE])
      self.fit_builtin_entity_parser_if_needed(dataset)
      self.fit_custom_entity_parser_if_needed(dataset)
      language = dataset[LANGUAGE]
  
      data_augmentation_config = self.config.data_augmentation_config
      utterances, classes, intent_list = build_training_data(
          dataset,
          language,
          data_augmentation_config,
          self.resources,
          self.random_state,
      )
  
      self.intent_list = intent_list
      if len(self.intent_list) <= 1:
          return self
  
      self.featurizer = Featurizer(
          config=self.config.featurizer_config,
          builtin_entity_parser=self.builtin_entity_parser,
          custom_entity_parser=self.custom_entity_parser,
          resources=self.resources,
          random_state=self.random_state,
      )
      self.featurizer.language = language
  
      none_class = max(classes)
      try:
          x = self.featurizer.fit_transform(
              dataset, utterances, classes, none_class
          )
      except _EmptyDatasetUtterancesError:
          logger.warning("No (non-empty) utterances found in dataset")
          self.featurizer = None
          return self
  
      alpha = get_regularization_factor(dataset)
  
      class_weights_arr = compute_class_weight(
          "balanced", range(none_class + 1), classes
      )
      # Re-weight the noise class
      class_weights_arr[-1] *= self.config.noise_reweight_factor
      class_weight = {idx: w for idx, w in enumerate(class_weights_arr)}
  
      self.classifier = SGDClassifier(
          random_state=self.random_state,
          alpha=alpha,
          class_weight=class_weight,
          **LOG_REG_ARGS,
      )
      self.classifier.fit(x, classes)
      logger.debug("%s", DifferedLoggingMessage(self.log_best_features))
      return self
  
imports: from __future__ import unicode_literals
  import json
  import logging
  from builtins import range, str, zip
  from pathlib import Path
  from snips_nlu.common.log_utils import DifferedLoggingMessage, log_elapsed_time
  from snips_nlu.common.utils import check_persisted_path, fitted_required, json_string
  from snips_nlu.constants import LANGUAGE, RES_PROBA
  from snips_nlu.dataset import validate_and_format_dataset
  from snips_nlu.exceptions import LoadingError, _EmptyDatasetUtterancesError
  from snips_nlu.intent_classifier.featurizer import Featurizer
  from snips_nlu.intent_classifier.intent_classifier import IntentClassifier
  from snips_nlu.intent_classifier.log_reg_classifier_utils import build_training_data, get_regularization_factor, text_to_utterance
  from snips_nlu.pipeline.configs import LogRegIntentClassifierConfig
  from snips_nlu.result import intent_classification_result
label_desc: Use image node_id 3 for calling the LogRegIntentClassifier obj's underlying member method code with example usage: obj.fit(dataset) and returns: self, self, self