matcha.sklearn.tabular.snn
Sklearn-compatible SNN wrappers for molecular property prediction from tabular descriptors.
Classes
Self-Normalizing Neural Network (SNN) for molecular property classification. |
|
Self-Normalizing Neural Network (SNN) for molecular property regression. |
Module Contents
- class matcha.sklearn.tabular.snn.SNNClassifier(hidden_dims: list[int] = [256, 256], num_parallel: int = 8, dropout: float = 0.05, num_endpoints: int = 1, deep_lasso_weight: float = 0.1, loss_fn: str = 'bce', loss_args: dict = {}, optimizer: str = 'adamw', optimizer_args: dict = {'lr': 0.005, 'weight_decay': 0.01, 'betas': (0.9, 0.95)}, scheduler: str = 'cosine_annealing_cyclic', scheduler_args: dict = {'min_lr': 1e-05, 'num_cycles': 5}, num_epochs: int = 100, batch_size: int = 64, stochastic_weight_averaging: bool = False, early_stopping: bool = True, patience: int = 20, devices: int = 1, accelerator: str = 'gpu', feature_list: list[str] = ['ECFP_count', 'rdkit_all_descriptors'], label_encoder_params: dict = {}, label_transform_map: str | list[str] | dict | None = None, augment_resonance: bool = False, seed: int = 0)[source]
Bases:
matcha.sklearn.tabular.base_sklearn_tabular.BaseScikitLearnTabular,matcha.sklearn.base_sklearn_model.ScikitLearnClassifierMixinSelf-Normalizing Neural Network (SNN) for molecular property classification.
Predicts molecular properties from molecular descriptors and fingerprints. Uses SELU activations and AlphaDropout to maintain self-normalizing properties, enabling training of deep networks without batch normalization. Uses MultiLn parallel head layers for improved capacity. Only compatible with classification datasets. Inherits from
BaseScikitLearnTabular.References:
Klambauer et al., NeurIPS (2017): https://arxiv.org/abs/1706.02515
Example usage:
model = SNNClassifier() model.fit(train_mols, train_y) predictions = model.predict(test_mols)
- Parameters:
hidden_dims (list[int]) – shape of hidden SNN layers, defaults to [256, 256]
num_parallel (int) – number of parallel heads in MultiLn layers, defaults to 8
dropout (float) – dropout rate (AlphaDropout), defaults to 0.05
num_endpoints (int) – number of endpoints (if multitasking) or classes (if classification) to predict, defaults to 1
deep_lasso_weight (float) – weight for deep lasso regularization, defaults to 0.1
loss_fn (str) – loss function to optimize, defaults to ‘bce’
loss_args (dict) – additional arguments for the loss function, defaults to {}
optimizer (str) – optimizer to use while training, defaults to ‘adamw’
optimizer_args (dict) – additional arguments for the optimizer, defaults to {‘lr’: 5e-3, ‘weight_decay’: 1e-2, ‘betas’: (0.9, 0.95)}
scheduler (str) – learning rate scheduler, defaults to ‘cosine_annealing_cyclic’.
total_stepsis auto-computed from dataset size and epochs when not explicitly provided.scheduler_args (dict) – additional arguments for the scheduler, defaults to {‘min_lr’: 1e-5, ‘num_cycles’: 5}
num_epochs (int) – number of epochs to train for, defaults to 100
batch_size (int) – batch size for training and prediction, defaults to 64
stochastic_weight_averaging (bool) – whether to add SWA epochs after regular training, defaults to False
early_stopping (bool) – whether to use early stopping, defaults to True
patience (int) – how many epochs to wait before early stopping, defaults to 20
devices (int) – number of devices for training, defaults to 1
accelerator (str) – hardware accelerator (‘cpu’, ‘gpu’, ‘tpu’, or ‘hpu’), defaults to ‘gpu’
feature_list (list[str]) – descriptor/fingerprint sets to use as input, defaults to [‘ECFP_count’, ‘rdkit_all_descriptors’]
label_encoder_params (dict) – parameters for the label encoder, defaults to {}
label_transform_map (str | list[str] | dict | None) – label transform configuration, defaults to None
augment_resonance (bool) – whether to augment with resonance structures, defaults to False
seed (int) – random seed for reproducibility, defaults to 0
- class matcha.sklearn.tabular.snn.SNNRegressor(hidden_dims: list[int] = [256, 256], num_parallel: int = 8, dropout: float = 0.05, num_endpoints: int = 1, deep_lasso_weight: float = 0.1, loss_fn: str = 'mse', loss_args: dict = {}, optimizer: str = 'adamw', optimizer_args: dict = {'lr': 0.005, 'weight_decay': 0.01, 'betas': (0.9, 0.95)}, scheduler: str = 'cosine_annealing_cyclic', scheduler_args: dict = {'min_lr': 1e-05, 'num_cycles': 5}, num_epochs: int = 100, batch_size: int = 64, stochastic_weight_averaging: bool = False, early_stopping: bool = True, patience: int = 20, devices: int = 1, accelerator: str = 'gpu', feature_list: list[str] = ['ECFP_count', 'rdkit_all_descriptors'], clip: bool = True, label_encoder_params: dict = {}, label_transform_map: str | list[str] | dict | None = None, scaler_type: str = 'standard', augment_resonance: bool = False, seed: int = 0)[source]
Bases:
matcha.sklearn.tabular.base_sklearn_tabular.BaseScikitLearnTabular,matcha.sklearn.base_sklearn_model.ScikitLearnRegressorMixinSelf-Normalizing Neural Network (SNN) for molecular property regression.
Predicts molecular properties from molecular descriptors and fingerprints. Uses SELU activations and AlphaDropout to maintain self-normalizing properties, enabling training of deep networks without batch normalization. Uses MultiLn parallel head layers for improved capacity. Only compatible with regression datasets. Inherits from
BaseScikitLearnTabular.References:
Klambauer et al., NeurIPS (2017): https://arxiv.org/abs/1706.02515
Example usage:
model = SNNRegressor() model.fit(train_mols, train_y) predictions = model.predict(test_mols)
- Parameters:
hidden_dims (list[int]) – shape of hidden SNN layers, defaults to [256, 256]
num_parallel (int) – number of parallel heads in MultiLn layers, defaults to 8
dropout (float) – dropout rate (AlphaDropout), defaults to 0.05
num_endpoints (int) – number of endpoints to predict (for multitasking), defaults to 1
deep_lasso_weight (float) – weight for deep lasso regularization, defaults to 0.1
loss_fn (str) – loss function to optimize, defaults to ‘mse’
loss_args (dict) – additional arguments for the loss function, defaults to {}
optimizer (str) – optimizer to use while training, defaults to ‘adamw’
optimizer_args (dict) – additional arguments for the optimizer, defaults to {‘lr’: 5e-3, ‘weight_decay’: 1e-2, ‘betas’: (0.9, 0.95)}
scheduler (str) – learning rate scheduler, defaults to ‘cosine_annealing_cyclic’.
total_stepsis auto-computed from dataset size and epochs when not explicitly provided.scheduler_args (dict) – additional arguments for the scheduler, defaults to {‘min_lr’: 1e-5, ‘num_cycles’: 5}
num_epochs (int) – number of epochs to train for, defaults to 100
batch_size (int) – batch size for training and prediction, defaults to 64
stochastic_weight_averaging (bool) – whether to add SWA epochs after regular training, defaults to False
early_stopping (bool) – whether to use early stopping, defaults to True
patience (int) – how many epochs to wait before early stopping, defaults to 20
devices (int) – number of devices for training, defaults to 1
accelerator (str) – hardware accelerator (‘cpu’, ‘gpu’, ‘tpu’, or ‘hpu’), defaults to ‘gpu’
feature_list (list[str]) – descriptor/fingerprint sets to use as input, defaults to [‘ECFP_count’, ‘rdkit_all_descriptors’]
clip (bool) – whether to clip predictions to the training label range, defaults to True
label_encoder_params (dict) – parameters for the label encoder, defaults to {}
label_transform_map (str | list[str] | dict | None) – label transform configuration, defaults to None
scaler_type (str) – type of feature scaler to use, defaults to ‘standard’
augment_resonance (bool) – whether to augment with resonance structures, defaults to False
seed (int) – random seed for reproducibility, defaults to 0