| 1335 | learner.teach(X, y, bootstrap=bootstrap, only_new=only_new) |
| 1336 | |
| 1337 | def test_on_transformed(self): |
| 1338 | n_samples = 10 |
| 1339 | n_features = 5 |
| 1340 | query_strategies = [ |
| 1341 | # TODO remove, added just to make sure on_transformed doesn't break anything |
| 1342 | # but it has no influence on this strategy, nothing special tested here |
| 1343 | mock.MockFunction(return_val=[np.random.randint(0, n_samples)]) |
| 1344 | |
| 1345 | # add further strategies which work with instance representations |
| 1346 | # no further ones as of 25.09.2020 |
| 1347 | ] |
| 1348 | X_pool = np.random.rand(n_samples, n_features) |
| 1349 | |
| 1350 | # use pandas data frame as X_pool, which will be transformed back to numpy with sklearn pipeline |
| 1351 | X_pool = pd.DataFrame(X_pool) |
| 1352 | |
| 1353 | y_pool = np.random.rand(n_samples) |
| 1354 | train_idx = np.random.choice(range(n_samples), size=2, replace=False) |
| 1355 | |
| 1356 | for query_strategy in query_strategies: |
| 1357 | learner = modAL.models.learners.BayesianOptimizer( |
| 1358 | estimator=make_pipeline( |
| 1359 | FunctionTransformer(func=pd.DataFrame.to_numpy), |
| 1360 | GaussianProcessRegressor() |
| 1361 | ), |
| 1362 | query_strategy=query_strategy, |
| 1363 | X_training=X_pool.iloc[train_idx], |
| 1364 | y_training=y_pool[train_idx], |
| 1365 | on_transformed=True |
| 1366 | ) |
| 1367 | query_idx, query_inst = learner.query(X_pool) |
| 1368 | learner.teach(X_pool.iloc[query_idx], y_pool[query_idx]) |
| 1369 | |
| 1370 | |
| 1371 | class TestCommittee(unittest.TestCase): |