qsprpred package

Subpackages

Submodules

qsprpred.data_CLI module

qsprpred.data_CLI.QSPRArgParser(txt=None)[source]

Define and read command line arguments.

qsprpred.data_CLI.QSPR_dataprep(args)[source]

Optimize, evaluate and train estimators.

qsprpred.model_CLI module

qsprpred.model_CLI.QSPRArgParser(txt=None)[source]

Define and read command line arguments.

qsprpred.model_CLI.QSPR_modelling(args)[source]

Optimize, evaluate and train estimators.

qsprpred.predict_CLI module

qsprpred.predict_CLI.QSPRArgParser(txt=None)[source]

Define and read command line arguments.

qsprpred.predict_CLI.QSPR_predict(args)[source]

Make predictions with pre-trained QSPR models for a set of smiles.

qsprpred.tasks module

class qsprpred.tasks.ModelTasks(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Enum representing the general type of task the model is supposed to perform for all target properties.

MULTICLASS = 'MULTICLASS'
MULTITASK_MIXED = 'MULTITASK_MIXED'
MULTITASK_MULTICLASS = 'MULTITASK_MULTICLASS'
MULTITASK_REGRESSION = 'MULTITASK_REGRESSION'
MULTITASK_SINGLECLASS = 'MULTITASK_SINGLECLASS'
REGRESSION = 'REGRESSION'
SINGLECLASS = 'SINGLECLASS'
static getModelTask(target_properties: list)[source]

Return the model type for a given list of target properties.

isClassification()[source]

Check if the task is a classification task.

isMixed()[source]

Check if the task is a mixed task.

isMultiTask()[source]

Check if the task is a multitask task.

isRegression()[source]

Check if the task is a regression task.

class qsprpred.tasks.TargetProperty(name: str, task: ~typing.Literal[<TargetTasks.REGRESSION: 'REGRESSION'>, <TargetTasks.SINGLECLASS: 'SINGLECLASS'>, <TargetTasks.MULTICLASS: 'MULTICLASS'>], th: list[float] | str | None = None, n_classes: int | None = None, transformer: ~typing.Callable | None = None, imputer: ~typing.Callable | None = None)[source]

Bases: JSONSerializable

Target property for QSPRmodelling class.

Variables:
  • name (str) – name of the target property

  • (Literal[TargetTasks.REGRESSION, (task) – TargetTasks.SINGLECLASS, TargetTasks.MULTICLASS]): task type for the target property

  • th (int) – threshold for the target property, only used for classification tasks

  • nClasses (int) – number of classes for the target property, only used for classification tasks

  • transformer (Callable) – function to transform the target property

  • imputer (Callable) – function to impute the target property

Initialize a TargetProperty object.

Parameters:
  • name (str) – name of the target property

  • (Literal[TargetTasks.REGRESSION (task) – TargetTasks.SINGLECLASS, TargetTasks.MULTICLASS]): task type for the target property

:paramTargetTasks.SINGLECLASS,

TargetTasks.MULTICLASS]): task type for the target property

Parameters:
  • th (list[float] | str) – threshold for the target property, only used for classification tasks. If th is precomputed, set it to “precomputed”. If th is precomputed, n_classes must be specified.

  • n_classes (int) – number of classes for the target property. Must be specified if th is precomputed, otherwise it is inferred from th.

  • transformer (Callable) – function to transform the target property

  • imputer (Callable) – function to impute the target property

classmethod fromDict(d: dict)[source]

Create a TargetProperty object from a dictionary.

task can be specified as a string or as a TargetTasks object.

Parameters:

d (dict) – dictionary containing the target property information

Example

>>> TargetProperty.fromDict({"name": "property_name", "task": "regression"})
TargetProperty(name=property_name, task=REGRESSION)
Returns:

TargetProperty object

Return type:

TargetProperty

classmethod fromFile(filename: str) Any

Initialize a new instance from a JSON file.

Parameters:

filename (str) – path to the JSON file

Returns:

new instance of the class

Return type:

instance (object)

classmethod fromJSON(json: str) Any

Reconstruct object from a JSON string.

Parameters:

json (str) – JSON string of the object

Returns:

reconstructed object

Return type:

obj (object)

classmethod fromList(_list: list[dict])[source]

Create a list of TargetProperty objects from a list of dictionaries.

Parameters:

_list (list) – list of dictionaries containing the target property information

Returns:

list of TargetProperty objects

Return type:

list[TargetProperty]

static getNames(_list: list)[source]

Get the names of the target properties from a list of TargetProperty objects.

Parameters:

_list (list) – list of TargetProperty objects

Returns:

list of names of the target properties

Return type:

list[str]

property nClasses

Get the number of classes for the target property.

Returns:

number of classes

Return type:

nClasses (int)

static selectFromList(_list: list, names: list)[source]

Select a subset of TargetProperty objects from a list of TargetProperty objects.

Parameters:
  • _list (list) – list of TargetProperty objects

  • names (list) – list of names of the target properties to be selected

  • original_names (bool) – whether to use the original names of the target properties

Returns:

list of TargetProperty objects

Return type:

list[TargetProperty]

property th

Set the threshold for the target property.

Returns:

threshold for the target property

Return type:

th ([list[int] | str])

toFile(filename: str) str

Serialize object to a JSON file. This JSON file should contain all data necessary to reconstruct the object.

Parameters:

filename (str) – filename to save object to

Returns:

absolute path to the saved JSON file of the object

Return type:

filename (str)

toJSON() str
Serialize object to a JSON string. This JSON string should

contain all data necessary to reconstruct the object.

Returns:

JSON string of the object

Return type:

json (str)

static toList(_list: list, task_as_str: bool = False, drop_transformer: bool = True)[source]

Convert a list of TargetProperty objects to a list of dictionaries.

Parameters:
  • _list (list) – list of TargetProperty objects

  • task_as_str (bool) – whether to convert the task to a string

Returns:

list of dictionaries containing the target property information

Return type:

list[dict]

class qsprpred.tasks.TargetTasks(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Enum representing the type of task the model is supposed to perform for a single target property.

MULTICLASS = 'MULTICLASS'
REGRESSION = 'REGRESSION'
SINGLECLASS = 'SINGLECLASS'
isClassification()[source]

Check if the task is a classification task.

isRegression()[source]

Check if the task is a regression task.

Module contents