rasa.core.policies.sklearn_policy
SklearnPolicy Objects
classSklearnPolicy(Policy)
Use an sklearn classifier to train a policy.
__init__
__init__(featurizer: Optional[MaxHistoryTrackerFeaturizer]=None, priority:int= DEFAULT_POLICY_PRIORITY, max_history:int= DEFAULT_MAX_HISTORY, model: Optional["sklearn.base.BaseEstimator"]=None, param_grid: Optional[Union[Dict[Text, List], List[Dict]]]=None, cv: Optional[int]=None, scoring: Optional[Union[Text, List, Dict, Callable]]="accuracy", label_encoder: LabelEncoder = LabelEncoder(), shuffle:bool=True, zero_state_features: Optional[Dict[Text, List["Features"]]]=None, **kwargs: Any) -> None
Create a new sklearn policy.
Arguments:
featurizer- Featurizer used to convert the training data into vector format.priority- Policy prioritymax_history- Maximum history of the dialogs.model- The sklearn model or model pipeline.param_grid- Ifparam_gridis not None andcvis given, a grid search on the givenparam_gridis performed (e.g.param_grid={'n_estimators': [50, 100]}).cv- Ifcvis not None, perform a cross validation on the training data.cvshould then conform to the sklearn standard (e.g.cv=5for a 5-fold cross-validation).scoring- Scoring strategy, using the sklearn standard.label_encoder- Encoder for the labels. Must implement an_inverse_transform_method.shuffle- Whether to shuffle training data.zero_state_features- Contains default feature values for attributes.
model_architecture
model_architecture(**kwargs: Any) -> Any
Sets model parameters for training.
predict_action_probabilities
predict_action_probabilities(tracker: DialogueStateTracker, domain: Domain, interpreter: NaturalLanguageInterpreter, **kwargs: Any) -> PolicyPrediction
Predicts the next action the bot should take after seeing the tracker.
Arguments:
tracker- therasa.core.trackers.DialogueStateTrackerdomain- therasa.shared.core.domain.Domaininterpreter- Interpreter which may be used by the policies to create additional features.
Returns:
The policy's prediction (e.g. the probabilities for the actions).
persist
persist(path: Union[Text, Path]) -> None
Persists the policy properties (see parent class for more information).
load
@classmethod
load(cls, path: Union[Text, Path], should_finetune: bool=False, **kwargs: Any) -> Policy
See the docstring for Policy.load.