Exemplo n.º 1
0
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))
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
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))
Exemplo n.º 4
0
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]}")
Exemplo n.º 5
0
 def test_extras(self, get_config):
     assert get_config(foo='bar')['foo'] == 'bar'
Exemplo n.º 6
0
 def __init__(self):
     from palladium.config import get_config
     self.cfg = get_config().copy()
Exemplo n.º 7
0
 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'
Exemplo n.º 8
0
 def get_me_config():
     cfg[threading.get_ident()] = get_config().copy()
Exemplo n.º 9
0
 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)
Exemplo n.º 10
0
 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
Exemplo n.º 11
0
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))