def main(): config = get_config() persister = config['model_persister'] model = persister.read() dataset = fetch_openml('wine-quality-red') for x, y in zip(dataset.feature_names, model.feature_importances_): print(x + ': ' + str(y))
def test_multiple_files(self, get_config, config1_fname, config2_fname, monkeypatch): monkeypatch.setitem(os.environ, 'PALLADIUM_CONFIG', ','.join([config1_fname, config2_fname])) monkeypatch.setitem(os.environ, 'ENV1', 'one') monkeypatch.setitem(os.environ, 'ENV2', 'two') config = get_config() assert config['env'] == 'two' assert config['here'] == os.path.dirname(config1_fname)
def predict(features): # Get hold of the Palladium configuration in config.py: config = get_config() # Use the model_persister to load the trained model: model = config['model_persister'].read() # From here on, it's plain scikit-learn: result = model.predict_proba([features])[0] for class_, proba in zip(model.classes_, result): print("{}: {:.1f}%".format(class_, proba * 100))
def predict(features): # Get hold of the Palladium configuration in config.py: config = get_config() # Use the model_persister to load the trained model: model = config['model_persister'].read() # From here on, it's plain scikit-learn: importances = model.feature_importances_ indices = np.argsort(importances)[::-1] dataset = fetch_openml("wine-quality-red") # Print the feature ranking print("Feature ranking:") for i in indices: print(f"{dataset.feature_names[i]} {importances[i]}")
def test_extras(self, get_config): assert get_config(foo='bar')['foo'] == 'bar'
def __init__(self): from palladium.config import get_config self.cfg = get_config().copy()
def test_pld_config_key(self, get_config, config1_fname, monkeypatch): monkeypatch.setitem(os.environ, 'PALLADIUM_CONFIG', config1_fname) monkeypatch.setitem(os.environ, 'ENV1', 'one') config = get_config() assert config['blocking'].__pld_config_key__ == 'blocking'
def get_me_config(): cfg[threading.get_ident()] = get_config().copy()
def test_variables(self, get_config, config1_fname, monkeypatch): monkeypatch.setitem(os.environ, 'PALLADIUM_CONFIG', config1_fname) monkeypatch.setitem(os.environ, 'ENV1', 'one') config = get_config() assert config['env'] == 'one' assert config['here'] == os.path.dirname(config1_fname)
def test_default_config(self, get_config, config1_fname, monkeypatch): here = os.path.dirname(config1_fname) monkeypatch.setitem(os.environ, 'ENV1', 'one') with cwd(here): config = get_config() assert config['here'] == here
def predict(features): model = get_config()['model_persister'].read() result = model.predict_proba([features])[0] for class_, proba in zip(model.classes_, result): print("{}: {:.1f}%".format(class_, proba*100))