Beispiel #1
0
    def test_plot_comparision(self):
        mg = MatrixGenerator()
        X, y, costs = mg.generate(n_basic_cols=10, noise_sigmas=[0.1, 1])
        lamb = 1

        dvs = DiffVariableSelector()
        dvs.fit(data=X,
                target_variable=y,
                costs=costs,
                lamb=lamb,
                j_criterion_func='mim')

        model = LogisticRegression()
        dvs.score(model, scoring_function=roc_auc_score)
        dvs.plot_scores(compare_no_cost_method=True, budget=1, model=model)
Beispiel #2
0
    def test_plot_without_comparision(self):
        integer_matrix = np.random.randint(0, 10, (100, 10))
        diverse_target = np.random.randint(0, 2, (100))
        costs = [1.76, 0.19, 0.36, 0.96, 0.41, 0.17, 0.36, 0.75, 0.79, 1.38]
        lamb = 1

        dvs = DiffVariableSelector()
        dvs.fit(data=integer_matrix,
                target_variable=diverse_target,
                costs=costs,
                lamb=lamb,
                j_criterion_func='mim')

        model = LogisticRegression()
        dvs.score(model, scoring_function=roc_auc_score)
        dvs.plot_scores(budget=1)
Beispiel #3
0
    def test_score(self):
        integer_matrix = np.random.randint(0, 10, (100, 10))
        diverse_target = np.random.randint(0, 2, (100))
        costs = [1.76, 0.19, -0.36, 0.96, 0.41, 0.17, -0.36, 0.75, 0.79, -1.38]
        lamb = 1

        dvs = DiffVariableSelector()
        dvs.fit(data=integer_matrix,
                target_variable=diverse_target,
                costs=costs,
                lamb=lamb,
                j_criterion_func='mim')

        model = LogisticRegression()
        dvs.score(model, scoring_function=roc_auc_score)

        self.assertEqual(len(dvs.total_scores), len(costs))
Beispiel #4
0
 def test_run_score_before_fit(self):
     dvs = DiffVariableSelector()
     model = LogisticRegression()
     with self.assertRaises(AssertionError):
         dvs.score(model, scoring_function=roc_auc_score)