Contributing emulators#
This guide explains how to contribute new emulator models to AutoEmulate
.
Emulator structure#
All emulators in AutoEmulate are implemented as scikit-learn
estimators, making them compatible with scikit-learn’s cross-validation, grid-search, and pipeline functionality. Have a look at the scikit-learn estimator developer guide for more details on how to implement a new emulator.
Note: Keep in mind when contributing emuulators that AutoEmulate doesn’t currently support time-series or spatial data.
Core Requirements#
Each emulator class must:
Live in
autoemulate/emulators/
Inherit from
sklearn.base
’sBaseEstimator
andRegressorMixin
Implement the
fit
andpredict
methodsInclude these additional methods/properties:
get_grid_params()
: Returns a dictionary of parameter values for grid search over hyperparametersmodel_name
: Property that returns the emulator name (usuallyself.__class__.__name__
)_more_tags()
: Defines emulator properties like multioutput support
Getting Started#
The easiest way to create a new emulator is to:
Look at existing emulators in
autoemulate/emulators/
as templatesRun the scikit-learn estimator tests
tests/test_estimators.py
early to catch any implementation issuesAdd your own tests in
tests/models/
Naming Conventions#
The model_name
property allows the emulator to be accessed with both long and short names:
Long name: The class name (e.g., “RadialBasisFunctions”)
Short name: Uppercase letters from long name (e.g., “rbf”)
Make sure your chosen class name:
Doesn’t conflict with existing emulators
Contains some uppercase letters for the short name
Is descriptive of the emulation technique
Testing emulators#
We use two types of tests:
Scikit-learn Test Suite: Add your emulator to
tests/test_estimators.py
to verify scikit-learn compatibility. Not all tests need to pass - use_more_tags()
to skip incompatible tests. See the estimator tags overview for details.Custom Tests: Add specific tests for your emulator in
tests/models/
to verify its core functionality (e.g., validating end-to-end functionality of components such as parameter search etc).
Registering an emulator#
After your emulator passes tests:
Add it to
model_registry
inautoemulate/emulators/__init__.py
Set
is_core=False
to make it available but not a default model
PyTorch emulators#
PyTorch emulators require special handling:
Put the model architecture in
autoemulate/emulators/neural_networks/
Put the main emulator class in
autoemulate/emulators/
Use skorch for scikit-learn compatibility:
Create
self.model_
asNeuralNetRegressor
instancePass model architecture as first argument
Use
self.model_
infit
andpredict
methods
See existing PyTorch emulators like conditional_neural_process.py
for examples.