Version: 3.x

rasa.nlu.classifiers.sklearn_intent_classifier

SklearnIntentClassifier Objects

@DefaultV1Recipe.register(
DefaultV1Recipe.ComponentType.INTENT_CLASSIFIER, is_trainable=True
)
class SklearnIntentClassifier(GraphComponent, IntentClassifier)

Intent classifier using the sklearn framework.

required_components

| @classmethod
| required_components(cls) -> List[Type]

Components that should be included in the pipeline before this component.

get_default_config

| @staticmethod
| get_default_config() -> Dict[Text, Any]

The component's default config (see parent class for full docstring).

__init__

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

Construct a new intent classifier using the sklearn framework.

create

| @classmethod
| create(cls, config: Dict[Text, Any], model_storage: ModelStorage, resource: Resource, execution_context: ExecutionContext) -> SklearnIntentClassifier

Creates a new untrained component (see parent class for full docstring).

required_packages

| @classmethod
| required_packages(cls) -> List[Text]

Any extra python dependencies required for this component to run.

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) -> Resource

Train the intent classifier on a data set.

process

| process(messages: List[Message]) -> List[Message]

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() -> None

Persist this model into the passed directory.

load

| @classmethod
| load(cls, config: Dict[Text, Any], model_storage: ModelStorage, resource: Resource, execution_context: ExecutionContext, **kwargs: Any, ,) -> SklearnIntentClassifier

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