Exemplo n.º 1
0
 def test_roc_curve_fails_correctly_without_predict_proba(self):
     dataset = load_demo_dataset("iris")
     svc = Model(SVC(gamma="scale"))
     result = svc.score_estimator(dataset)
     with pytest.raises(VizError):
         result.plot.roc_curve()
     plt.close()
Exemplo n.º 2
0
 def test_dataset_y_from_fetchopenml_with_two_target_columns_works(self):
     dataset = load_demo_dataset(
         "openml",
         name="blood-transfusion-service-center",
         target_column=["V1", "V2"],
     )
     features_y = dataset.y
     assert features_y.shape == (748, 2)
Exemplo n.º 3
0
    def test_load_prediction_data_works_as_expected(self):
        dataset = load_demo_dataset("iris")
        dataset.create_train_test(stratify=True)
        feature_pipeline = Pipeline([("scale", DFStandardScaler())])
        model = Model(LogisticRegression(), feature_pipeline=feature_pipeline)
        model.train_estimator(dataset)
        result = model.make_prediction(dataset, 5)

        expected = pd.DataFrame({"Prediction": [0]})
        pd.testing.assert_frame_equal(result, expected, check_dtype=False)
 def test_pr_curve_fails_correctly_without_predict_proba(self):
     """
     Expect that the plot will raise an exception if the estimator
     does not have a predict_proba method
     """
     dataset = load_demo_dataset("iris")
     svc = Model(SVC(gamma="scale"))
     result = svc.score_estimator(dataset)
     with pytest.raises(VizError):
         result.plot.precision_recall_curve()
     plt.close()
 def classifier_result(self) -> Result:
     """Setup a classiifer Result"""
     dataset = load_demo_dataset("iris")
     model = Model(LogisticRegression())
     return model.score_estimator(dataset)
Exemplo n.º 6
0
 def result_cv(self, model: Model) -> Result:
     """Setup a Result from a cross-validated scoring"""
     dataset = load_demo_dataset("boston")
     return model.score_estimator(dataset, cv=2)
Exemplo n.º 7
0
 def result(self, model: Model) -> Result:
     """Setup a Result from a score_estimator without cv"""
     dataset = load_demo_dataset("boston")
     return model.score_estimator(dataset)
Exemplo n.º 8
0
 def regression_result(self) -> Result:
     """Setup a regression Result"""
     dataset = load_demo_dataset("boston")
     model = Model(LinearRegression())
     return model.score_estimator(dataset)
Exemplo n.º 9
0
 def dataset(self):
     return load_demo_dataset("iris")
Exemplo n.º 10
0
 def classification_result(self) -> Result:
     """Setup a classification Result"""
     dataset = load_demo_dataset("breast_cancer")
     model = Model(LogisticRegression())
     return model.score_estimator(dataset)
 def iris_result(self) -> Result:
     dataset = load_demo_dataset("iris")
     model = Model(LogisticRegression())
     return model.score_estimator(dataset)
Exemplo n.º 12
0
 def test_dataset_x_from_fetchopenml_with_parameters_works(self):
     dataset = load_demo_dataset("openml",
                                 name="blood-transfusion-service-center",
                                 target_column="V1")
     features_x = dataset.x
     assert features_x.shape == (748, 4)
Exemplo n.º 13
0
 def test_dataset_from_fetchopenml_works(self):
     dataset = load_demo_dataset("openml", name="miceprotein")
     assert len(dataset.x) == 1080
Exemplo n.º 14
0
 def load_dataset_iris(self) -> Dataset:
     return load_demo_dataset("iris")
Exemplo n.º 15
0
 def dataset(self):
     """Setup a Dataset"""
     return load_demo_dataset("iris")