Base Model

The BaselineModel leverages the Optuna library for hyperparameter optimization, facilitating an automated and efficient search for the best model parameters based on the provided data. This approach allows for the rapid development and comparison of different QSAR modeling strategies, enhancing the flexibility and robustness of the modeling process.

class qsar.models.baseline_model.BaselineModel

Bases: ABC

An abstract base class used to represent a QSAR model. It serves as a template for all QSAR models and uses the Optuna library for hyperparameter optimization. Child classes should implement the specific model logic and hyperparameter optimization.

DEFAULT_MAX_ITER = 100000
DEFAULT_RANDOM_STATE = 0
fit(x_train, y_train)

Fits the model to the training data.

Parameters:
  • x_train (pd.DataFrame or np.ndarray) – the training data

  • y_train (pd.Series or np.ndarray) – the target values for the training data

abstract optimize_hyperparameters(trial: Trial, df: DataFrame) float

An abstract method that should be overridden in child classes to optimize the hyperparameters of the model.

Parameters:
  • trial (optuna.Trial) – The trial instance for hyperparameter optimization.

  • df (pd.DataFrame) – The DataFrame used for training the model.

Returns:

The cross-validation score of the model.

Return type:

float

predict(x)

Predicts the target values for the given data.

Parameters:

x (pd.DataFrame or np.ndarray) – the data to predict the target values for

Returns:

the predicted target values

Return type:

np.ndarray

set_hyperparameters(**kwargs)

Sets the hyperparameters of the model.

Parameters:

kwargs (dict) – the hyperparameters to set