mindmeld.components.domain_classifier module

This module contains the domain classifier component of the MindMeld natural language processor.

class mindmeld.components.domain_classifier.DomainClassifier(resource_loader)[source]

Bases: mindmeld.components.classifier.Classifier

A domain classifier is used to determine the target domain for a given query. It is trained using all of the labeled queries across all intents for all domains in an application. The labels for the training data are the domain names associated with each query.

dump(*args, **kwargs)[source]

Persists the trained domain classification model to disk.

Parameters:model_path (str) -- The location on disk where the model should be stored
fit(*args, **kwargs)[source]

Trains the domain classification model using the provided training queries

Parameters:
  • model_type (str) -- The type of machine learning model to use. If omitted, the default model type will be used.
  • features (dict) -- Features to extract from each example instance to form the feature vector used for model training. If omitted, the default feature set for the model type will be used.
  • params_grid (dict) -- The grid of hyper-parameters to search, for finding the optimal hyper-parameter settings for the model. If omitted, the default hyper-parameter search grid will be used.
  • cv (None, optional) -- Cross-validation settings
  • queries (list of ProcessedQuery) -- The labeled queries to use as training data
inspect(query, domain=None, dynamic_resource=None)[source]

Inspects the query.

Parameters:
  • query (Query) -- The query to be predicted.
  • domain (str) -- The expected domain label for this query.
  • dynamic_resource (dict, optional) -- A dynamic resource to aid NLP inference.
Returns:

2D list that includes every feature, their value, weight and probability.

Return type:

(list of lists)

load(*args, **kwargs)[source]

Loads the trained domain classification model from disk

Parameters:model_path (str) -- The location on disk where the model is stored
unload()[source]

Unloads the model from memory. This helps reduce memory requirements while training other models.

CLF_TYPE = 'domain'

The classifier type.