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

Method test_sparse_matrices

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

Source from the content-addressed store, hash-verified

1099 confusion_matrix(pred, np.random.randint(0, 2, size=(10,)))
1100
1101 def test_sparse_matrices(self):
1102 query_strategies = [
1103 modAL.uncertainty.uncertainty_sampling,
1104 modAL.uncertainty.entropy_sampling,
1105 modAL.uncertainty.margin_sampling
1106 ]
1107 formats = ['lil', 'csc', 'csr']
1108 sample_count = range(10, 20)
1109 feature_count = range(1, 5)
1110
1111 for query_strategy, format, n_samples, n_features in product(query_strategies, formats, sample_count, feature_count):
1112 X_pool = sp.random(n_samples, n_features, format=format)
1113 y_pool = np.random.randint(0, 2, size=(n_samples, ))
1114 initial_idx = np.random.choice(
1115 range(n_samples), size=5, replace=False)
1116
1117 learner = modAL.models.learners.ActiveLearner(
1118 estimator=RandomForestClassifier(n_estimators=10), query_strategy=query_strategy,
1119 X_training=X_pool[initial_idx], y_training=y_pool[initial_idx]
1120 )
1121 query_idx, query_inst = learner.query(X_pool)
1122 learner.teach(X_pool[query_idx], y_pool[query_idx])
1123
1124 def test_on_transformed(self):
1125 n_samples = 10

Callers

nothing calls this directly

Calls 2

teachMethod · 0.95
queryMethod · 0.45

Tested by

no test coverage detected