qstack.regression.final_error¶
Final error computation on test sets.
- qstack.regression.final_error.final_error(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, idx_test=None, idx_train=None, sparse=None, random_state=0, return_pred=False, return_alpha=False)[source]¶
Perform prediction on the test set using the full training set.
- 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).
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.
return_pred (bool) – Return predictions.
return_alpha (bool) – Return regression weights.
- Returns:
prediction absolute errors on the test set np.1darray(Ntest) : (if return_pred is True) predictions on the test set np.1darray(Ntrain or sparse) : (if return_alpha is True) regression weights
- Return type:
np.1darray(Ntest)
- Raises:
RuntimeError – If ‘X’ is a kernel and sparse regression is chosen.
- qstack.regression.final_error.main()[source]¶
Command-line entry point for computing final prediction errors.
Command-line use¶
This program computes the full-training error for each molecule.
usage: python3 -m qstack.regression.final_error [-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] [--ll]
[--readkernel]
[--sparse SPARSE]
[--random_state RANDOM_STATE]
[--save-alpha SAVE_ALPHA]
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- --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- --save-alpha
file to write the regression coefficients to
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.