def streams(): # Variables distributions = [[0.1, 0.9], [0.2, 0.8], [0.3, 0.7], [0.4, 0.6]] label_noises = [0.0, 0.1, 0.2, 0.3] drift_types = ["incremental", "sudden"] random_states = [1337, 666, 42] # Prepare streams streams = {} for drift_type in drift_types: for distribution in distributions: for random_state in random_states: for flip_y in label_noises: stream = csm.StreamGenerator( drift_type=drift_type, distribution=distribution, random_state=random_state, flip_y=flip_y, ) streams.update({str(stream): stream}) return streams
import csm import numpy as np from tqdm import tqdm drift_types = ("sudden", "incremental") ensemble_sizes = (2, 3, 4, 5, 10, 15, 20) alphas = (0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3) results = np.zeros((len(drift_types), len(ensemble_sizes), len(alphas), 199)) for i, drift_type in tqdm(enumerate(drift_types), ascii=True, total=len(drift_types)): stream = csm.StreamGenerator(drift_type=drift_type, distribution=[0.1, 0.9], random_state=844, flip_y=0.1) for j, ensemble_size in tqdm(enumerate(ensemble_sizes), ascii=True, total=len(ensemble_sizes)): for k, alpha in tqdm(enumerate(alphas), ascii=True, total=len(alphas)): clf = csm.MDE(alpha=alpha, ensemble_size=ensemble_size) learner = csm.TestAndTrain(stream, clf) learner.run() stream.reset() results[i, j, k, :] = np.array(learner.scores) np.save("results/experiment_1", results)
a = np.swapaxes(results_hypercube, 1, 0) res = np.reshape(a, (5, -1)) return h.tabrow(what, res) # Compare drift types print("Drift types") for e in [2, 3]: for drift_type in drift_types: for distribution in ldistributions: for random_state in random_states: for flip_y in label_noises: stream = csm.StreamGenerator( drift_type=drift_type, distribution=distribution, random_state=random_state, flip_y=flip_y, ) streams = [stream] title = stream filename = "figures/run/%s_%i" % (stream, e) what = drift_type tabrow = gather_and_present(title, filename, streams, what, e) print(stream) print(tabrow)