def _create_dummy_lr_model(self, path, encoded_data, label):
        # dummy logistic regression with 100 observations with 3 features belonging to 2 classes
        dummy_lr = LogisticRegression()
        dummy_lr.fit_by_cross_validation(encoded_data,
                                         number_of_splits=2, label_name=label)

        return dummy_lr
Beispiel #2
0
    def _create_dummy_lr_model(self):
        dummy_lr = LogisticRegression()
        encoded_tr = EncodedData(np.random.rand(100, 20),
                                 {"l1": [i % 2 for i in range(0, 100)]})

        dummy_lr.fit_by_cross_validation(encoded_tr, number_of_splits=2,
                                         label=Label("l1", values=[0, 1]))
        return dummy_lr, encoded_tr
Beispiel #3
0
    def test_fit_by_cross_validation(self):
        x = EncodedData(
            np.array([[1, 0, 0], [0, 1, 1], [1, 1, 1], [0, 1, 1], [1, 0, 0],
                      [0, 1, 1], [1, 1, 1], [0, 1, 1]]), {
                          "test1": [1, 0, 2, 0, 1, 0, 2, 0],
                          "test2": [1, 0, 2, 0, 1, 0, 2, 0]
                      })

        lr = LogisticRegression()
        lr.fit_by_cross_validation(x, number_of_splits=2, label=Label("test2"))
    def _create_dummy_lr_model(self, path):
        # dummy logistic regression with 100 observations with 20 features belonging to 2 classes
        dummy_lr = LogisticRegression()
        dummy_lr.fit_by_cross_validation(EncodedData(np.random.rand(100, 5), {"l1": [i % 2 for i in range(0, 100)]}), number_of_splits=2,
                                         label=Label("l1"))

        # Change coefficients to values 1-20
        dummy_lr.model.coef_ = np.array(list(range(0, 5))).reshape(1, -1)

        with open(path / "ml_details.yaml", "w") as file:
            yaml.dump({"l1": {"feature_names": ["AAA", "AAC", "CKJ", "KSA", "AKJ"]}},
                      file)

        return dummy_lr
Beispiel #5
0
    def _create_dummy_lr_model(self, path):
        # dummy logistic regression with 100 observations with 20 features belonging to 2 classes
        dummy_lr = LogisticRegression()
        dummy_lr.fit_by_cross_validation(EncodedData(np.random.rand(
            100, 20), {"l1": [i % 2 for i in range(0, 100)]}),
                                         number_of_splits=2,
                                         label_name="l1")

        # Change coefficients to values 1-20
        dummy_lr.models["l1"].coef_ = np.array(list(range(0,
                                                          20))).reshape(1, -1)

        file_path = path / "ml_details.yaml"
        with file_path.open("w") as file:
            yaml.dump(
                {"l1": {
                    "feature_names": [f"feature{i}" for i in range(20)]
                }}, file)

        return dummy_lr