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

Method test_on_transformed

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

Source from the content-addressed store, hash-verified

1122 learner.teach(X_pool[query_idx], y_pool[query_idx])
1123
1124 def test_on_transformed(self):
1125 n_samples = 10
1126 n_features = 5
1127 query_strategies = [
1128 modAL.batch.uncertainty_batch_sampling
1129 # add further strategies which work with instance representations
1130 # no further ones as of 25.09.2020
1131 ]
1132 X_pool = np.random.rand(n_samples, n_features)
1133
1134 # use pandas data frame as X_pool, which will be transformed back to numpy with sklearn pipeline
1135 X_pool = pd.DataFrame(X_pool)
1136
1137 y_pool = np.random.randint(0, 2, size=(n_samples,))
1138 train_idx = np.random.choice(range(n_samples), size=2, replace=False)
1139
1140 for query_strategy in query_strategies:
1141 learner = modAL.models.learners.ActiveLearner(
1142 estimator=make_pipeline(
1143 FunctionTransformer(func=pd.DataFrame.to_numpy),
1144 RandomForestClassifier(n_estimators=10)
1145 ),
1146 query_strategy=query_strategy,
1147 X_training=X_pool.iloc[train_idx],
1148 y_training=y_pool[train_idx],
1149 on_transformed=True
1150 )
1151 query_idx, query_inst = learner.query(X_pool)
1152 learner.teach(X_pool.iloc[query_idx], y_pool[query_idx])
1153
1154 def test_on_transformed_with_variable_transformation(self):
1155 """

Callers

nothing calls this directly

Calls 2

teachMethod · 0.95
queryMethod · 0.45

Tested by

no test coverage detected