Esempio n. 1
0
def evaluate(data_conf, model_conf, **kwargs):
    """Python evaluate method called by AOA framework

    Parameters:
    data_conf (dict): The dataset metadata
    model_conf (dict): The model configuration to use

    Returns:
    None:No return

    """

    predict_df = pd.read_csv(data_conf['location'])
    _, test = train_test_split(predict_df, test_size=0.5, random_state=42)
    X_predict = test.drop("species", 1)
    y_test = test['species']

    jnius_configure_classpath()
    backend = PyJNIusBackend()

    evaluator = make_evaluator(backend, "models/model.pmml") \
    .verify()

    y_predict = evaluator.evaluateAll(X_predict)

    scores = {}
    scores['accuracy'] = metrics.accuracy_score(y_test, y_predict['y'])
    print("model accuracy is ", scores['accuracy'])

    # dump results as json file evaluation.json to models/ folder
    with open("models/evaluation.json", "w+") as f:
        json.dump(scores, f)
    print("Evaluation complete...")
Esempio n. 2
0
    def __init__(self, path):
        if not HAS_PMML:
            raise ImportError("You need `jpmml_evaluator` to load pmml models."
                              "Use pip install -U aict-tools[pmml] or [all]")
        self.backend = PyJNIusBackend()
        self.evaluator = jpmml_evaluator.make_evaluator(self.backend,
                                                        path).verify()
        self.feature_names = sorted(
            [i.getName() for i in self.evaluator.getInputFields()])

        names = [o.getName() for o in self.evaluator.getTargetFields()]
        if len(names) > 1:
            raise ValueError("Model has more than one output")
        self.target_name = names[0]
Esempio n. 3
0
import os
import unittest

import numpy as np
import pandas as pd
import xgboost
from jpmml_evaluator import make_evaluator
from jpmml_evaluator.pyjnius import PyJNIusBackend, jnius_configure_classpath
from sqlflow_submitter.xgboost.train import save_model_to_local_file

# Configure JVM
jnius_configure_classpath()

# Construct a PyJNIus backend
PMML_BACKEND = PyJNIusBackend()


# TODO(sneaxiy): Add XGBRanker unittest. XGBRanker requires group information
# but we do not support group now.
class TestXGBoostModelSavingBase(unittest.TestCase):
    def tearDown(self):
        filename = self.filename()
        if filename is not None and os.path.exists(filename):
            os.remove(filename)
            os.remove(self.pmml_filename())

    def filename(self):
        pass

    def pmml_filename(self):
Esempio n. 4
0
 def test_pyjnius(self):
     backend = PyJNIusBackend()
     super(PyJNIusEvaluatorTest, self).workflow(backend, lax=True)