dialoguekit.nlu.models.intent_classifier_cosine¶
Implements intent classification based on cosine similarity.
Classes¶
Cosine Intent classifier. |
Module Contents¶
- class dialoguekit.nlu.models.intent_classifier_cosine.IntentClassifierCosine(intents: List[dialoguekit.core.intent.Intent])¶
Bases:
dialoguekit.nlu.intent_classifier.IntentClassifier
Cosine Intent classifier.
- Parameters:
intents – Allowed intents.
- train_model(utterances: List[dialoguekit.core.utterance.Utterance], labels: List[dialoguekit.core.intent.Intent]) None ¶
Trains a model based on a set of labeled utterances.
- Parameters:
utterances – List of Utterance instances.
labels – List of associated intent labels.
- classify_intent(utterance: dialoguekit.core.utterance.Utterance) dialoguekit.core.intent.Intent ¶
Classifies the utterance’s intent.
Classifies the intent of an utterance based on cosine similarity of TF-IDF-weighted term vectors.
- Parameters:
utterance – An utterance.
- Returns:
Predicted intent.
- save_model(file_path: str) None ¶
Saves the trained model to a file.
This method uses the joblib library to save the model.
- Parameters:
file_path – File path.
- load_model(file_path: str) None ¶
Loads a model from a file.
This method uses the joblib library to load the model.
- Parameters:
file_path – File path.