Skip to content
Snippets Groups Projects
test_cumbo.py 47.3 KiB
Newer Older
Dominique Benielli's avatar
Dominique Benielli committed
    #     n_estimators = 5
    #     X_dense = iris.data
    #     y = iris.target
    #
    #     for sparse_format in [csc_matrix, csr_matrix, lil_matrix, coo_matrix,
    #                           dok_matrix]:
    #         for views_ind in (iris.views_ind, np.array([[0, 2], [1, 3]])):
    #             X_sparse = sparse_format(X_dense)
    #
    #             clf_sparse = MuCumboClassifier(
    #                 base_estimator=CustomSVC(),
    #                 random_state=seed,
    #                 n_estimators=n_estimators)
    #             clf_sparse.fit(X_sparse, y, views_ind)
    #
    #             clf_dense = MuCumboClassifier(
    #                 base_estimator=CustomSVC(),
    #                 random_state=seed,
    #                 n_estimators=n_estimators)
    #             clf_dense.fit(X_dense, y, views_ind)
    #
    #             assert_array_equal(clf_sparse.decision_function(X_sparse),
    #                                clf_dense.decision_function(X_dense))
    #
    #             assert_array_equal(clf_sparse.predict(X_sparse),
    #                                clf_dense.predict(X_dense))
    #
    #             assert_equal(clf_sparse.score(X_sparse, y),
    #                          clf_dense.score(X_dense, y))
    #
    #             for res_sparse, res_dense in \
    #                     zip(clf_sparse.staged_decision_function(X_sparse),
    #                         clf_dense.staged_decision_function(X_dense)):
    #                 assert_array_equal(res_sparse, res_dense)
    #
    #             for res_sparse, res_dense in \
    #                     zip(clf_sparse.staged_predict(X_sparse),
    #                         clf_dense.staged_predict(X_dense)):
    #                 assert_array_equal(res_sparse, res_dense)
    #
    #             for res_sparse, res_dense in \
    #                     zip(clf_sparse.staged_score(X_sparse, y),
    #                         clf_dense.staged_score(X_dense, y)):
    #                 assert_equal(res_sparse, res_dense)
    #
    #             # Check that sparsity of data is maintained during training
    #             types = [clf.data_type_ for clf in clf_sparse.estimators_]
    #             if sparse_format == csc_matrix:
    #                 assert_true(all([type_ == csc_matrix for type_ in types]))
    #             else:
    #                 assert_true(all([type_ == csr_matrix for type_ in types]))
    #
    # def test():
    #     cumbo = MuCumboClassifier()

if __name__ == '__main__':
    unittest.main()
    # suite = unittest.TestLoader().loadTestsFromTestCase
    # (TestMuCumboClassifier().test_class_variation())
    # unittest.TextTestRunner(verbosity=2).run(suite)