def test_next_activity_kmeans(self):
     self.max_diff = None
     job = create_test_job(
         clustering=create_test_clustering(
             clustering_type=ClusteringMethods.KMEANS.value),
         split=repair_example(),
         encoding=create_test_encoding(prefix_length=8, padding=True),
         labelling=create_test_labelling(
             label_type=LabelTypes.NEXT_ACTIVITY.value),
         predictive_model=create_test_predictive_model(
             predictive_model=PredictiveModels.CLASSIFICATION.value,
             prediction_method=ClassificationMethods.RANDOM_FOREST.value))
     result, _ = calculate(job)
     del result['elapsed_time']
     self.assertDictEqual(
         result, {
             'f1score': 0.54239884582595577,
             'acc': 0.80995475113122173,
             'true_positive': '--',
             'true_negative': '--',
             'false_negative': '--',
             'false_positive': '--',
             'precision': 0.62344720496894401,
             'recall': 0.5224945442336747,
             'auc': 0.4730604801339352
         })
 def test_class_no_cluster(self):
     self.max_diff = None
     job = create_test_job(
         clustering=create_test_clustering(
             clustering_type=ClusteringMethods.NO_CLUSTER.value),
         split=repair_example(),
         encoding=create_test_encoding(prefix_length=5,
                                       padding=True,
                                       add_elapsed_time=True),
         predictive_model=create_test_predictive_model(
             predictive_model=PredictiveModels.CLASSIFICATION.value,
             prediction_method=ClassificationMethods.RANDOM_FOREST.value))
     result, _ = calculate(job)
     del result['elapsed_time']
     self.assertDictEqual(
         result, {
             'f1score': 1.0,
             'acc': 1.0,
             'true_positive': '--',
             'true_negative': '--',
             'false_negative': '--',
             'false_positive': '--',
             'precision': 1.0,
             'recall': 1.0,
             'auc': 0.0
         })
 def test_regression_no_cluster(self):
     self.max_diff = None
     job = create_test_job(
         clustering=create_test_clustering(clustering_type=ClusteringMethods.NO_CLUSTER.value),
         split=repair_example(),
         encoding=create_test_encoding(prefix_length=5, padding=True),
         labelling=create_test_labelling(label_type=LabelTypes.DURATION.value),
         predictive_model=create_test_predictive_model(predictive_model=PredictiveModels.REGRESSION.value,
                                                       prediction_method=RegressionMethods.RANDOM_FOREST.value)
     )
     result, _ = calculate(job)
     self.assertAlmostEqual(result['rmse'], 0.4868515876868242)
     self.assertAlmostEqual(result['mae'], 0.44340838774645464)
     self.assertAlmostEqual(result['rscore'], 0.02142755175443678)
     self.assertAlmostEqual(result['mape'], -1)
 def test_regression_kmeans(self):
     self.max_diff = None
     job = create_test_job(
         clustering=create_test_clustering(clustering_type=ClusteringMethods.KMEANS.value),
         split=repair_example(),
         encoding=create_test_encoding(prefix_length=5, padding=True),
         labelling=create_test_labelling(label_type=LabelTypes.DURATION.value),
         predictive_model=create_test_predictive_model(predictive_model=PredictiveModels.REGRESSION.value,
                                                       prediction_method=RegressionMethods.RANDOM_FOREST.value)
     )
     result, _ = calculate(job)
     self.assertAlmostEqual(result['rmse'], 0.48841552839653984)
     self.assertAlmostEqual(result['mae'], 0.44282462605873457)
     self.assertAlmostEqual(result['rscore'], 0.015130407121517586)
     self.assertAlmostEqual(result['mape'], -1)
    def test_next_activity_no_cluster(self):
        self.max_diff = None
        job = create_test_job(
            clustering=create_test_clustering(clustering_type=ClusteringMethods.NO_CLUSTER.value),
            split=repair_example(),
            encoding=create_test_encoding(prefix_length=8, padding=True),
            labelling=create_test_labelling(label_type=LabelTypes.NEXT_ACTIVITY.value),
            predictive_model=create_test_predictive_model(predictive_model=PredictiveModels.CLASSIFICATION.value,
                                                          prediction_method=ClassificationMethods.RANDOM_FOREST.value)
        )
        result, _ = calculate(job)

        self.assertAlmostEqual(result['f1score'], 0.542398845)
        self.assertAlmostEqual(result['acc'], 0.809954751)
        self.assertAlmostEqual(result['precision'], 0.623447204)
        self.assertAlmostEqual(result['recall'], 0.52249454423)
        self.assertAlmostEqual(result['auc'], 0)
 def get_job():
     return create_test_job(split=repair_example(),
                            encoding=create_test_encoding(prefix_length=5,
                                                          padding=True),
                            job_type=JobTypes.LABELLING.value)