MCPcopy Create free account
hub / github.com/modAL-python/modAL / test_SVM_loss

Method test_SVM_loss

tests/core_tests.py:1611–1626  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1609
1610class TestMultilabel(unittest.TestCase):
1611 def test_SVM_loss(self):
1612 for n_classes in range(2, 10):
1613 for n_instances in range(1, 10):
1614 X_training = np.random.rand(n_instances, 5)
1615 y_training = np.random.randint(
1616 0, 2, size=(n_instances, n_classes))
1617 X_pool = np.random.rand(n_instances, 5)
1618 y_pool = np.random.randint(0, 2, size=(n_instances, n_classes))
1619 classifier = OneVsRestClassifier(
1620 SVC(probability=True, gamma='auto'))
1621 classifier.fit(X_training, y_training)
1622 avg_loss = modAL.multilabel._SVM_loss(classifier, X_pool)
1623 mcc_loss = modAL.multilabel._SVM_loss(classifier, X_pool,
1624 most_certain_classes=np.random.randint(0, n_classes, size=(n_instances)))
1625 self.assertEqual(avg_loss.shape, (len(X_pool), ))
1626 self.assertEqual(mcc_loss.shape, (len(X_pool),))
1627
1628 def test_strategies(self):
1629 for n_classes in range(3, 10):

Callers

nothing calls this directly

Calls 1

fitMethod · 0.45

Tested by

no test coverage detected