Example #1
0
    def test_prepared_data_for_threshold_prediction(
        self,
        trained_policy: UnexpecTEDIntentPolicy,
        default_domain: Domain,
        stories_path: Path,
    ):
        training_trackers = train_trackers(default_domain,
                                           stories_path,
                                           augmentation_factor=0)
        training_model_data, _ = trained_policy._prepare_for_training(
            training_trackers, default_domain, precomputations=None)

        data_for_prediction = trained_policy._prepare_data_for_prediction(
            training_model_data)

        assert set(
            data_for_prediction.data.keys()).issubset(PREDICTION_FEATURES)
Example #2
0
    def test_post_training_threshold_computation(
        self,
        trained_policy: UnexpecTEDIntentPolicy,
        default_domain: Domain,
        stories_path: Path,
    ):
        training_trackers = train_trackers(default_domain,
                                           stories_path,
                                           augmentation_factor=0)
        training_model_data, label_ids = trained_policy._prepare_for_training(
            training_trackers, default_domain, precomputations=None)

        trained_policy.compute_label_quantiles_post_training(
            training_model_data, label_ids)

        computed_thresholds = trained_policy.label_quantiles

        # -1 is used for padding and hence is not expected in the keys
        expected_keys = list(np.unique(label_ids))
        expected_keys.remove(-1)

        assert sorted(list(
            computed_thresholds.keys())) == sorted(expected_keys)