qstack.regression.regression

Learning curve computation.

qstack.regression.regression.main()[source]

Command-line entry point for computing learning curves.

qstack.regression.regression.regression(X, y, read_kernel=False, sigma=32.0, eta=1e-05, akernel='L', gkernel=None, gdict={'alpha': 1.0, 'normalize': 1, 'verbose': 0}, test_size=0.2, train_size=[0.125, 0.25, 0.5, 0.75, 1.0], n_rep=5, random_state=0, idx_test=None, idx_train=None, sparse=None, debug=False, save_pred=False)[source]

Produce learning curves (LC) data using kernel ridge regression.

Parameters:
  • X (numpy.ndarray[Nsamples,...]) – Array containing the representations of all Nsamples.

  • y (numpy.1darray[Nsamples]) – Array containing the target property of all Nsamples.

  • read_kernel (bool) – If ‘X’ is a kernel and not an array of representations.

  • sigma (float) – Width of the kernel.

  • eta (float) – Regularization strength for matrix inversion.

  • akernel (str) – Local kernel (‘L’ for Laplacian, ‘G’ for Gaussian, ‘dot’, ‘cosine’).

  • gkernel (str) – Global kernel (None, ‘REM’, ‘avg’).

  • gdict (dict) – Parameters of the global kernels.

  • test_size (float or int) – Test set fraction (or number of samples).

  • train_size (list) – List of training set size fractions used to evaluate the points on the LC.

  • n_rep (int) – The number of repetition for each point (using random sampling).

  • random_state (int) – The seed used for random number generator (controls train/test splitting).

  • idx_test (numpy.1darray) – List of indices for the test set (based on the sequence in X).

  • idx_train (numpy.1darray) – List of indices for the training set (based on the sequence in X).

  • sparse (int) – The number of reference environnments to consider for sparse regression.

  • debug (bool) – To use a fixed seed for partial training set selection (for reproducibility).

  • save_pred (bool) – To return all predicted targets.

Returns:

The computed LC, as a list containing all its points (train size, MAE, std) If save_pres is True, a tuple with (results, (target values, predicted values))

Raises:

RuntimeError – If ‘X’ is a kernel and sparse regression is chosen.

Command-line use

This program computes the learning curve.

usage: python3 -m qstack.regression.regression [-h] --x REPR --y PROP
                                               [--eta ETA] [--sigma SIGMA]
                                               [--akernel {G,L,dot,cosine,G_sklearn,G_custom_c,L_sklearn,L_custom_c,L_custom_py,myG,myL,myLfast}]
                                               [--gkernel {avg,rem}]
                                               [--gdict [GDICT ...]]
                                               [--test TEST_SIZE]
                                               [--train TRAIN_SIZE [TRAIN_SIZE ...]]
                                               [--ll] [--readkernel]
                                               [--sparse SPARSE]
                                               [--random_state RANDOM_STATE]
                                               [--splits SPLITS]
                                               [--name NAMEOUT] [--debug]

Named Arguments

--x

path to the representations file

--y

path to the properties file

--eta

eta hyperparameter

Default: 1e-05

--sigma

sigma hyperparameter

Default: 32.0

--akernel

Possible choices: G, L, dot, cosine, G_sklearn, G_custom_c, L_sklearn, L_custom_c, L_custom_py, myG, myL, myLfast

local kernel type: “G” for Gaussian, “L” for Laplacian, “dot” for dot products, “cosine” for cosine similarity. “G_{sklearn,custom_c}”, “L_{sklearn,custom_c,custom_py}” for specific implementations. “L_custompy” is suited to open-shell systems

Default: 'L'

--gkernel

Possible choices: avg, rem

global kernel type: “avg” for average, “rem” for REMatch

--gdict

dictionary like input string to initialize global kernel parameters, e.g. “–gdict alpha=2 normalize=0”

Default: {'alpha': 1.0, 'normalize': 1, 'verbose': 0}

--test

test set fraction

Default: 0.2

--train

training set fractions

Default: [0.125, 0.25, 0.5, 0.75, 1.0]

--ll

if correct for the numper of threads

Default: False

--readkernel

if X is kernel

Default: False

--sparse

regression basis size for sparse learning

--random_state

seed for test / train splitting

Default: 0

--splits

number of splits

Default: 5

--name

the name of the output file containting the LC data (.txt)

--debug

enable debug

Default: False

Note

If you built those docs yourself and the command-line section is empty, please make sure you have installed the right components of qstack.