Version: 3.x

rasa.nlu.classifiers._sklearn_intent_classifier

SklearnIntentClassifier Objects

class SklearnIntentClassifier(IntentClassifier)

Intent classifier using the sklearn framework

__init__

| __init__(component_config: Optional[Dict[Text, Any]] = None, clf: "sklearn.model_selection.GridSearchCV" = None, le: Optional["sklearn.preprocessing.LabelEncoder"] = None) -> None

Construct a new intent classifier using the sklearn framework.

transform_labels_str2num

| transform_labels_str2num(labels: List[Text]) -> np.ndarray

Transforms a list of strings into numeric label representation.

Arguments:

  • labels: List of labels to convert to numeric representation

transform_labels_num2str

| transform_labels_num2str(y: np.ndarray) -> np.ndarray

Transforms a list of strings into numeric label representation.

Arguments:

  • y: List of labels to convert to numeric representation

train

| train(training_data: TrainingData, config: Optional[RasaNLUModelConfig] = None, **kwargs: Any, ,) -> None

Train the intent classifier on a data set.

process

| process(message: Message, **kwargs: Any) -> None

Return the most likely intent and its probability for a message.

predict_prob

| predict_prob(X: np.ndarray) -> np.ndarray

Given a bow vector of an input text, predict the intent label.

Return probabilities for all labels.

Arguments:

  • X: bow of input text

Returns:

vector of probabilities containing one entry for each label

predict

| predict(X: np.ndarray) -> Tuple[np.ndarray, np.ndarray]

Given a bow vector of an input text, predict most probable label.

Return only the most likely label.

Arguments:

  • X: bow of input text

Returns:

tuple of first, the most probable label and second,

persist

| persist(file_name: Text, model_dir: Text) -> Optional[Dict[Text, Any]]

Persist this model into the passed directory.

load

| @classmethod
| load(cls, meta: Dict[Text, Any], model_dir: Text, model_metadata: Optional[Metadata] = None, cached_component: Optional["SklearnIntentClassifier"] = None, **kwargs: Any, ,) -> "SklearnIntentClassifier"

Loads trained component (see parent class for full docstring).