class_docstr: Intent classifier using the sklearn framework.
class_docstr_tok: ["Intent","classifier","using","the","sklearn","framework","."]
docstr: Return the most likely intent and its probability for a message.
docstr_tok: ["Return","the","most","likely","intent","and","its","probability","for","a","message","."]
code: def process(self, messages: List[Message]) -> List[Message]:
      """Return the most likely intent and its probability for a message."""
      for message in messages:
          if self.clf is None or not message.features_present(
              attribute=TEXT,
              featurizers=self.component_config.get(FEATURIZERS),
          ):
              # component is either not trained or didn't
              # receive enough training data or the input doesn't
              # have required features.
              intent = None
              intent_ranking = []
          else:
              X = self._get_sentence_features(message).reshape(1, -1)
  
              intent_ids, probabilities = self.predict(X)
              intents = self.transform_labels_num2str(
                  np.ravel(intent_ids)
              )
              # `predict` returns a matrix as it is supposed
              # to work for multiple examples as well, hence we need to flatten
              probabilities = probabilities.flatten()
  
              if intents.size > 0 and probabilities.size > 0:
                  ranking = list(
                      zip(list(intents), list(probabilities))
                  )[:LABEL_RANKING_LENGTH]
  
                  intent = {
                      "name": intents[0],
                      "confidence": probabilities[0],
                  }
  
                  intent_ranking = [
                      {"name": intent_name, "confidence": score}
                      for intent_name, score in ranking
                  ]
              else:
                  intent = {"name": None, "confidence": 0.0}
                  intent_ranking = []
  
          message.set("intent", intent, add_to_output=True)
          message.set(
              "intent_ranking", intent_ranking, add_to_output=True
          )
  
      return messages
  
imports: from __future__ import annotations
  import logging
  from rasa.nlu.featurizers.dense_featurizer.dense_featurizer import DenseFeaturizer
  import typing
  import warnings
  from typing import Any, Dict, List, Optional, Text, Tuple, Type
  import numpy
  import rasa.shared.utils.io
  import rasa.utils.io
  from rasa.engine.graph import GraphComponent, ExecutionContext
  from rasa.engine.recipes.default_recipe import DefaultV1Recipe
  from rasa.engine.storage.resource import Resource
  from rasa.engine.storage.storage import ModelStorage
  from rasa.shared.constants import DOCS_URL_TRAINING_DATA_NLU
  from rasa.nlu.classifiers import LABEL_RANKING_LENGTH
  from rasa.shared.exceptions import RasaException
  from rasa.shared.nlu.constants import TEXT
  from rasa.nlu.classifiers.classifier import IntentClassifier
  from rasa.shared.nlu.training_data.training_data import TrainingData
  from rasa.shared.nlu.training_data.message import Message
  from rasa.utils.tensorflow.constants import FEATURIZERS
label_desc: Use image node_id 12 for calling the SklearnIntentClassifier obj's underlying member method code with example usage: obj.process(messages) and returns: messages