mindmeld.components.role_classifier module¶
This module contains the role classifier component of the MindMeld natural language processor.
-
class
mindmeld.components.role_classifier.
RoleClassifier
(resource_loader, domain, intent, entity_type)[source]¶ Bases:
mindmeld.components.classifier.Classifier
A role classifier is used to determine the target role for entities in a given query. It is trained using all the labeled queries for a particular intent. The labels are the role names associated with each entity within each query.
-
domain
¶ str -- The domain that this role classifier belongs to
-
intent
¶ str -- The intent that this role classifier belongs to
-
entity_type
¶ str -- The entity type that this role classifier is for
-
roles
¶ set -- A set containing the roles which can be classified
-
dump
(model_path, incremental_model_path=None)[source]¶ Persists the trained role classification model to disk.
Parameters:
-
fit
(queries=None, label_set=None, incremental_timestamp=None, load_cached=True, **kwargs)[source]¶ Trains a statistical model for role classification using the provided training examples.
Parameters:
-
load
(model_path)[source]¶ Loads the trained role classification model from disk.
Parameters: model_path (str) -- The location on disk where the model is stored
-
predict
(query, entities, entity_index)[source]¶ Predicts a role for the given entity using the trained role classification model.
Parameters: Returns: The predicted role for the provided entity
Return type:
-
predict_proba
(query, entities, entity_index)[source]¶ Runs prediction on a given entity and generates multiple role hypotheses and associated probabilities using the trained role classification model.
Parameters: Returns: a list of tuples of the form (str, float) grouping roles and their probabilities
Return type:
-
unload
()[source]¶ Unloads the model from memory. This helps reduce memory requirements while training other models.
-
view_extracted_features
(query, entities, entity_index)[source]¶ Extracts features for a given entity for role classification.
Parameters: Returns: The extracted features from the given input
Return type:
-
CLF_TYPE
= 'role'¶
-