Regressor

This module presents the regressor_obj class, which is related to machine learning regression. This class does not implement any supervised learning regression algorithm. Instead, it serves as an interface between a regressor object implemented elsewhere and the ESCAPE model and data objects. In other words, this class allows the use of any 3rd party or self-implemented regressor class.

One well-known 3rd party regressor is the Multilayer Perceptron Regressor from the scikit-learn package [1] or another good example is the torch based regressor from skorch package [2].

After training, machine learning regressors can predict a solution for a model based on a given experimental dataset. This solution can then be further optimized using any optimizer from ESCAPE.

Regressors can be quite useful for predicting solutions for a large number of experimental data, also known as batch processing. They provide initial solutions that are quite close to the actual ones for further optimization.

class escape.core.regressor.regressor_obj

Wrapper class for regressor that provides an interface between ESCAPE and machine learning regressors.

This class allows integration of any 3rd party or custom regressor implementation with ESCAPE’s model and data objects. It handles training data generation, parameter management, and prediction.

c_test

Test coordinates.

c_train

Training coordinates.

data_length

Length of training data.

dumps()
fit(X: ndarray[Any, dtype[_ScalarType_co]], y: ndarray[Any, dtype[_ScalarType_co]]) None

Fit the regressor to training data.

Must be implemented by subclasses.

is_stopped

Check if training process is stopped.

load_train_data(filename: str) None

Load training data from file.

filenamestr

Path to load the training data from

loads(data)
modelstack

Modelstack used to generate training data.

name

Name of the regressor object.

noisify_coords(c: ndarray[Any, dtype[_ScalarType_co]], reset: bool = True) ndarray[Any, dtype[_ScalarType_co]]

Add noise to coordinates.

Must be implemented by subclasses.

noisify_data(X: ndarray[Any, dtype[_ScalarType_co]], reset: bool = True) ndarray[Any, dtype[_ScalarType_co]]

Add noise to data.

Must be implemented by subclasses.

normalize_data(X: ndarray[Any, dtype[_ScalarType_co]], c: ndarray[Any, dtype[_ScalarType_co]], reset: bool = True) ndarray[Any, dtype[_ScalarType_co]]

Normalize input data.

Must be implemented by subclasses.

nsamples

Number of training samples.

ntests

Number of test samples.

num_train_params

Number of trainable parameters.

parameters

List of model parameters.

predict(X: ndarray[Any, dtype[_ScalarType_co]]) ndarray[Any, dtype[_ScalarType_co]]

Make predictions for input data.

Must be implemented by subclasses.

reset() None

Reset parameter values to defaults.

save_train_data(filename: str) None

Save generated training data to file.

filenamestr

Path to save the training data

score(X: ndarray[Any, dtype[_ScalarType_co]], y: ndarray[Any, dtype[_ScalarType_co]]) float

Calculate score for predictions.

Must be implemented by subclasses.

shake() None

Randomly set parameter values.

show(model_configs: Optional[Union[Any, List[Any], tuple[Any, ...]]] = None, config: Optional[Any] = None, **kwargs) Any

Show regressor object in a widget.

Args:

model_configs: Model configurations to display config: Layout configuration **kwargs: Additional keyword arguments

Returns:

RegressorObjectLayout instance

stop() None

Stop the training process.

stop_trainer() None

Stop the trainer.

test() datastack_obj

Create random test data using the current model configuration.

datastack_obj

Test datastack containing generated test data

train(reset_data: bool = True, fit: bool = True) Optional[float]

Train the regressor.

reset_databool, optional

If True, reset previously generated training set, by default True

fitbool, optional

If True, fit the model to the training data, by default True

Optional[float]

Score of trained regressor on validation dataset if available, None otherwise

x_test

Test input data.

x_train

Training input data.

y_test

Test target data.

y_train

Training target data.