kinactive.io module
Files and models’ IO operations.
- kinactive.io.load(path: Path) KinactiveClassifier | KinactiveRegressor | DFGClassifier[source]
Automatically determine which model to load based on bath and load this model.
- Parameters:
path – A path to the saved model.
- Returns:
The loaded model.
- kinactive.io.load_dfg(path: Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/kinactive/checkouts/stable/kinactive/resources/models/DFG_classifier')) DFGClassifier[source]
Load the
kinactive.model.DFGclassifier.- Parameters:
path – A path to the saved model. Must contain four directories, for in, out, other, and meta models.
- Returns:
- kinactive.io.load_json(path: Path) dict[str, Any][source]
- Parameters:
path – A path to a JSON file.
- Returns:
The parsed dictionary.
- kinactive.io.load_kinactive(path: Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/kinactive/checkouts/stable/kinactive/resources/models/kinactive_classifier')) KinactiveClassifier[source]
Load the
KinActivemodel classifying PKs into active/inactive conformations.- Parameters:
path – A path to the saved model.
- Returns:
A loaded model.
- kinactive.io.load_sklearn(path: Path) LogisticRegression[source]
- Parameters:
path – A path to an sklearn model saved via
joblib.save()- Returns:
A model loaded via
joblib.load().
- kinactive.io.load_txt_lines(path: Path) list[str][source]
- Parameters:
path – A path to a text file.
- Returns:
A list of non-empty lines.
- kinactive.io.load_xgb(path: Path, xgb_model: _X) _X[source]
- Parameters:
path – A path to an XGBoost model saved via
save_xgb()xgb_model – The model type.
- Returns:
The loaded model.
- kinactive.io.save(model: KinactiveClassifier | KinactiveRegressor | LogisticRegression | DFGClassifier, base: Path, name: str, overwrite: bool = False) Path[source]
- Parameters:
model – A model from
kinactive.model.base – Base dir to save to.
name – Model name. Will create
base / namedir if it doesn’t exist.overwrite – Overwrite existing model with the same name.
- Returns:
The
base / namepath after successful save.
- kinactive.io.save_dfg(model: DFGClassifier, base: Path, name: str, overwrite: bool = False) Path[source]
Save the DFGclassifier model into four different folders.
This will save each model separately using
save()under pathsbase / name / model_name.- Parameters:
model – The model to save.
base – Base path to write to.
name – A dir name within the
basedir.overwrite – Overwrite existing models.
- Returns:
base/namepath after successful save.
- kinactive.io.save_json(data: dict, path: Path) Path[source]
- Parameters:
data – Data dictionary.
path – A valid path to write to.
- Returns:
The
pathafter successful writing.
- kinactive.io.save_sklearn(model: LogisticRegression, path: Path) Path[source]
Save an sklearn model using
joblib.dump().- Parameters:
model – A scikit-learn model.
path – A valid path to write to.
- Returns:
The
pathafter successful writing.