def test_if_dense_classification_works_on_non_dense_base_classifier( self): classifier = BinaryRelevance(classifier=Keras( create_model_single_class, False, KERAS_PARAMS), require_dense=[True, True]) self.assertClassifierWorksWithSparsity(classifier, 'dense')
def test_model_selection_works(self): for x, y in self.get_multilabel_data_for_tests('dense'): parameters = { 'classifier': [LabelPowerset(), BinaryRelevance()], 'clusterer': [RandomLabelSpaceClusterer(None, None, False)], 'clusterer__cluster_size': list(range(2, 3)), 'clusterer__cluster_count': [3], 'clusterer__allow_overlap': [False], 'classifier__classifier': [MultinomialNB()], 'classifier__classifier__alpha': [0.7, 1.0], } clf = GridSearchCV(LabelSpacePartitioningClassifier(), parameters, scoring='f1_macro') clf.fit(x, y) for p in list(parameters.keys()): self.assertIn(p, clf.best_params_) self.assertIsNotNone(clf.best_score_)
def test_if_works_with_cross_validation(self): classifier = BinaryRelevance( classifier=GaussianNB(), require_dense=[True, True]) self.assertClassifierWorksWithCV(classifier)
def test_if_dense_classification_works_on_dense_base_classifier(self): classifier = BinaryRelevance( classifier=GaussianNB(), require_dense=[True, True]) self.assertClassifierWorksWithSparsity(classifier, 'dense') self.assertClassifierPredictsProbabilities(classifier, 'dense')
def test_if_sparse_classification_works_on_non_dense_base_classifier(self): classifier = BinaryRelevance( classifier=SVC(probability=True), require_dense=[False, True]) self.assertClassifierWorksWithSparsity(classifier, 'sparse') self.assertClassifierPredictsProbabilities(classifier, 'sparse')