From a8a34af0d2e36497ad5172c55b9d2ff92fd7c31c Mon Sep 17 00:00:00 2001 From: luponzo86 Date: Sat, 2 Nov 2019 19:25:14 -0700 Subject: [PATCH] add importDefaultClassifier() --- rhapsody/utils/settings.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/rhapsody/utils/settings.py b/rhapsody/utils/settings.py index 1e9a2c0..3df3632 100644 --- a/rhapsody/utils/settings.py +++ b/rhapsody/utils/settings.py @@ -4,6 +4,7 @@ import os import tarfile +import pickle import urllib.request import shutil import sklearn @@ -13,7 +14,7 @@ __all__ = ['DEFAULT_FEATSETS', 'initialSetup', 'getDefaultTrainingDataset', 'getDefaultClassifiers', - 'delSettings', 'getSettings'] + 'importDefaultClassifier', 'delSettings', 'getSettings'] USERHOME = os.getenv('USERPROFILE') or os.getenv('HOME') or './' DEFAULT_WORKING_DIR = os.path.join(USERHOME, 'rhapsody') @@ -232,6 +233,18 @@ def getDefaultClassifiers(): return def_clsfs +def importDefaultClassifier(version): + """Imports the specified classifier and its summary + + :arg version: either 'full', 'reduced' or 'EVmut' + :type version: str + """ + assert version in ['full', 'reduced', 'EVmut'] + with open(getDefaultClassifiers()[version], 'rb') as p: + clsf = pickle.load(p) + return clsf + + def delSettings(): for entry in ['rhapsody_local_folder', 'rhapsody_training_dataset', 'EVmutation_local_folder', 'EVmutation_metrics']: