| 1626 | self.assertEqual(mcc_loss.shape, (len(X_pool),)) |
| 1627 | |
| 1628 | def test_strategies(self): |
| 1629 | for n_classes in range(3, 10): |
| 1630 | for n_pool_instances in range(1, 10): |
| 1631 | for n_query_instances in range(1, min(n_pool_instances, 3)): |
| 1632 | X_training = np.random.rand(n_pool_instances, 5) |
| 1633 | y_training = np.random.randint( |
| 1634 | 0, 2, size=(n_pool_instances, n_classes)) |
| 1635 | X_pool = np.random.rand(n_pool_instances, 5) |
| 1636 | classifier = OneVsRestClassifier( |
| 1637 | SVC(probability=True, gamma='auto')) |
| 1638 | classifier.fit(X_training, y_training) |
| 1639 | |
| 1640 | active_learner = modAL.models.ActiveLearner(classifier) |
| 1641 | # no random tie break |
| 1642 | modAL.multilabel.SVM_binary_minimum(active_learner, X_pool) |
| 1643 | modAL.multilabel.mean_max_loss( |
| 1644 | classifier, X_pool, n_query_instances) |
| 1645 | modAL.multilabel.max_loss( |
| 1646 | classifier, X_pool, n_query_instances) |
| 1647 | modAL.multilabel.min_confidence( |
| 1648 | classifier, X_pool, n_query_instances) |
| 1649 | modAL.multilabel.avg_confidence( |
| 1650 | classifier, X_pool, n_query_instances) |
| 1651 | modAL.multilabel.max_score( |
| 1652 | classifier, X_pool, n_query_instances) |
| 1653 | modAL.multilabel.avg_score( |
| 1654 | classifier, X_pool, n_query_instances) |
| 1655 | # random tie break |
| 1656 | modAL.multilabel.SVM_binary_minimum( |
| 1657 | active_learner, X_pool, random_tie_break=True) |
| 1658 | modAL.multilabel.mean_max_loss( |
| 1659 | classifier, X_pool, n_query_instances, random_tie_break=True) |
| 1660 | modAL.multilabel.max_loss( |
| 1661 | classifier, X_pool, n_query_instances, random_tie_break=True) |
| 1662 | modAL.multilabel.min_confidence( |
| 1663 | classifier, X_pool, n_query_instances, random_tie_break=True) |
| 1664 | modAL.multilabel.avg_confidence( |
| 1665 | classifier, X_pool, n_query_instances, random_tie_break=True) |
| 1666 | modAL.multilabel.max_score( |
| 1667 | classifier, X_pool, n_query_instances, random_tie_break=True) |
| 1668 | modAL.multilabel.avg_score( |
| 1669 | classifier, X_pool, n_query_instances, random_tie_break=True) |
| 1670 | |
| 1671 | |
| 1672 | class TestExamples(unittest.TestCase): |