Training & validation (PLSR)

Various utilities function to train and evaluate the Partial Least Squares Regression baseline model

Train & evaluate


source

Learner

 Learner (data, model)

Initialize self. See help(type(self)) for accurate signature.


source

PLS_model

 PLS_model (X_names, pipeline_kwargs={})

Partial Least Squares model runner


source

Learners

 Learners (tax_lookup, seeds=range(0, 20), split_ratio=0.1)

Initialize self. See help(type(self)) for accurate signature.

Example of use

src_dir = 'test'
fnames = ['spectra-features-smp.npy', 'spectra-wavenumbers-smp.npy', 
          'depth-order-smp.npy', 'target-smp.npy', 
          'tax-order-lu-smp.pkl', 'spectra-id-smp.npy']

X, X_names, depth_order, y, tax_lookup, X_id = load_kssl(src_dir, fnames=fnames)
dest_dir_model = Path('test/dumps-test/plsr/train_eval/all/models')
seeds = range(2)
learners = Learners(tax_lookup, seeds=seeds)
learners.train((X, y, depth_order[:, -1]), 
               n_cpts_range=range(40, 70, 2),
               delta=2e-3,
               dest_dir_model=dest_dir_model)
--------------------------------------------------------------------------------
Seed: 0
--------------------------------------------------------------------------------
# of components chosen: 44
--------------------------------------------------------------------------------
Seed: 1
--------------------------------------------------------------------------------
# of components chosen: 48