for seed in seeds:
perfs_by_size = OrderedDict({'seed' : [], 'n_samples' : [], 'test_score' : [], 'n_cpts' : []})
for size in training_size:
print (80 * '-' )
print (f'Seed: { seed} | Size: { size} ' )
print (80 * '-' )
idx = np.random.choice(len (X), size, replace= False )
# train/test
X_train, X_test, y_train, y_test = train_test_split(X[idx, :],
y[idx],
test_size= split_ratio,
random_state= seed)
# Further train/valid
X_train, X_valid, y_train, y_valid = train_test_split(X_train,
y_train,
test_size= split_ratio,
random_state= seed)
model = Pipeline([
('snv' , SNV()),
('derivative' , TakeDerivative(window_length= 11 , polyorder= 1 , deriv= 1 )),
('dropper' , DropSpectralRegions(X_names, regions= CO2_REGION)),
('model' , PLSRegression())])
learner = Learner((X_train, X_valid, y_train, y_valid), model)
learner.find_hp(n_cpts_range= n_cpts_range(size), delta= 1e-2 , verbose= False )
learner.fit()
perfs_by_size['seed' ].append(seed)
perfs_by_size['n_samples' ].append(size)
perfs_by_size['n_cpts' ].append(learner.n_cpts_best)
perfs_by_size['test_score' ].append(learner.evaluate(X_test, y_test))
with open (dest_dir/ f'plsr-lc-seed- { seed} .pickle' , 'wb' ) as f:
pickle.dump(perfs_by_size, f)
--------------------------------------------------------------------------------
Seed: 0 | Size: 500
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 0 | Size: 1000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 0 | Size: 2000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 0 | Size: 5000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 0 | Size: 10000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 0 | Size: 20000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 0 | Size: 30000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 0 | Size: 40132
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 1 | Size: 500
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 1 | Size: 1000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 1 | Size: 2000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 1 | Size: 5000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 1 | Size: 10000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 1 | Size: 20000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 1 | Size: 30000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 1 | Size: 40132
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 2 | Size: 500
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 2 | Size: 1000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 2 | Size: 2000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 2 | Size: 5000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 2 | Size: 10000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 2 | Size: 20000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 2 | Size: 30000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 2 | Size: 40132
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 3 | Size: 500
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 3 | Size: 1000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 3 | Size: 2000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 3 | Size: 5000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 3 | Size: 10000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 3 | Size: 20000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 3 | Size: 30000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 3 | Size: 40132
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 4 | Size: 500
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 4 | Size: 1000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 4 | Size: 2000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 4 | Size: 5000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 4 | Size: 10000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 4 | Size: 20000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 4 | Size: 30000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 4 | Size: 40132
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 5 | Size: 500
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 5 | Size: 1000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 5 | Size: 2000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 5 | Size: 5000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 5 | Size: 10000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 5 | Size: 20000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 5 | Size: 30000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 5 | Size: 40132
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 6 | Size: 500
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 6 | Size: 1000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 6 | Size: 2000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 6 | Size: 5000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 6 | Size: 10000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 6 | Size: 20000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 6 | Size: 30000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 6 | Size: 40132
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 7 | Size: 500
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 7 | Size: 1000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 7 | Size: 2000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 7 | Size: 5000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 7 | Size: 10000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 7 | Size: 20000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 7 | Size: 30000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 7 | Size: 40132
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 8 | Size: 500
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 8 | Size: 1000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 8 | Size: 2000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 8 | Size: 5000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 8 | Size: 10000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 8 | Size: 20000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 8 | Size: 30000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 8 | Size: 40132
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 9 | Size: 500
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 9 | Size: 1000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 9 | Size: 2000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 9 | Size: 5000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 9 | Size: 10000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 9 | Size: 20000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 9 | Size: 30000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 9 | Size: 40132
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 10 | Size: 500
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 10 | Size: 1000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 10 | Size: 2000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 10 | Size: 5000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 10 | Size: 10000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 10 | Size: 20000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 10 | Size: 30000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 10 | Size: 40132
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 11 | Size: 500
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 11 | Size: 1000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 11 | Size: 2000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 11 | Size: 5000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 11 | Size: 10000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 11 | Size: 20000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 11 | Size: 30000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 11 | Size: 40132
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 12 | Size: 500
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 12 | Size: 1000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 12 | Size: 2000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 12 | Size: 5000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 12 | Size: 10000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 12 | Size: 20000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 12 | Size: 30000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 12 | Size: 40132
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 13 | Size: 500
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 13 | Size: 1000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 13 | Size: 2000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 13 | Size: 5000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 13 | Size: 10000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 13 | Size: 20000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 13 | Size: 30000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 13 | Size: 40132
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 14 | Size: 500
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 14 | Size: 1000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 14 | Size: 2000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 14 | Size: 5000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 14 | Size: 10000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 14 | Size: 20000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 14 | Size: 30000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 14 | Size: 40132
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 15 | Size: 500
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 15 | Size: 1000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 15 | Size: 2000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 15 | Size: 5000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 15 | Size: 10000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 15 | Size: 20000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 15 | Size: 30000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 15 | Size: 40132
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 16 | Size: 500
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 16 | Size: 1000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 16 | Size: 2000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 16 | Size: 5000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 16 | Size: 10000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 16 | Size: 20000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 16 | Size: 30000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 16 | Size: 40132
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 17 | Size: 500
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 17 | Size: 1000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 17 | Size: 2000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 17 | Size: 5000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 17 | Size: 10000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 17 | Size: 20000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 17 | Size: 30000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 17 | Size: 40132
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 18 | Size: 500
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 18 | Size: 1000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 18 | Size: 2000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 18 | Size: 5000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 18 | Size: 10000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 18 | Size: 20000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 18 | Size: 30000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 18 | Size: 40132
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 19 | Size: 500
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 19 | Size: 1000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 19 | Size: 2000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 19 | Size: 5000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 19 | Size: 10000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 19 | Size: 20000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 19 | Size: 30000
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Seed: 19 | Size: 40132
--------------------------------------------------------------------------------