Example #1
0
    def test_score_sklearn(self):
        from sasctl.services import microanalytic_score as mas

        m = mas.get_module(SCIKIT_MODEL_NAME.replace(' ', ''))
        m = mas.define_steps(m)
        r = m.predict(sepalwidth=1, sepallength=2, petallength=3, petalwidth=4)
        assert r == 'virginica'
    def test_score_mas(self, iris_dataset, request):
        from sasctl.services import microanalytic_score as mas

        module_name = request.config.cache.get('MAS_MODULE_NAME', None)
        assert module_name is not None

        # Retrieve the module from MAS
        module = mas.get_module(module_name)
        assert module.name == module_name

        # Create Python methods for the model steps
        module = mas.define_steps(module)

        # Call .predict()
        x = iris_dataset.iloc[0, :]
        assert hasattr(module, 'predict')
        result = module.predict(x)
        assert isinstance(result, six.string_types)
        assert result in ('setosa', 'virginica', 'versicolor')

        # Call .predict_proba()
        assert hasattr(module, 'predict_proba')
        probs = module.predict_proba(x)
        assert len(probs) == 3
        assert all(isinstance(p, float) for p in probs)
        assert round(sum(probs), 5) == 1.0
Example #3
0
    def test_score_sklearn(self):
        from sasctl.services import microanalytic_score as mas

        m = mas.get_module(SCIKIT_MODEL_NAME.replace(' ', ''))
        m = mas.define_steps(m)
        r = m.score(sepalwidth=1, sepallength=2, petallength=3, petalwidth=4)
        assert isinstance(r, tuple)
        pytest.xfail('PyMAS integration not yet working.')
        assert r['rc'] is None
    def test_score_mas(self, boston_dataset, request):
        from sasctl.services import microanalytic_score as mas

        module_name = request.config.cache.get('MAS_MODULE_NAME', None)
        assert module_name is not None

        # Retrieve the module from MAS
        module = mas.get_module(module_name)
        assert module.name == module_name

        # Create Python methods for the model steps
        module = mas.define_steps(module)

        assert hasattr(module, 'score')
        result = module.score(boston_dataset.iloc[0, :])

        assert round(result, 4) == 30.0038
Example #5
0
def run_inference_for_base64(base64img):
    host = os.getenv('OPENMM_HOST', '')
    user = os.getenv('OPENMM_USER', '')
    password = os.getenv('OPENMM_PASSWORD', '')
    model = os.getenv('OPENMM_MODEL', '')
    try:
        img = np.array(
            Image.open(BytesIO(base64.decodebytes(base64img.encode()))))

        with Session(host, user, password, verify_ssl=False, protocol='http'):
            mod = mas.get_module(model)
            response = mas.execute_module_step(mod,
                                               'score',
                                               image_names='test_image',
                                               image_strings=base64img)
            return transform_openmm_detections(response, img=img)
    except:
        e = sys.exc_info()[0]
        print(e)
    def test_score_mas(self, boston_dataset, request):
        from sasctl.services import microanalytic_score as mas

        module_name = request.config.cache.get('MAS_MODULE_NAME', None)
        assert module_name is not None

        # Retrieve the module from MAS
        module = mas.get_module(module_name)
        assert module.name == module_name

        # Create Python methods for the model steps
        module = mas.define_steps(module)

        assert hasattr(module, 'predict')
        result = module.predict(boston_dataset.iloc[0, :])

        # Don't think order of rows is guaranteed.
        assert isinstance(result, float)
        assert result > 1
Example #7
0
project = 'iris_os'

user = '******'

password = '******'

#astore_table = 'gb_astore'
#astore_caslib = 'public'

###################################
####### Getting astore table ######

s = Session(host, user, password, verify_ssl=False)

module = mas.get_module(modelname)

module = mas.define_steps(module)
steps = mas.list_module_steps(module)

steps[0]['id']

steps[0]['links']

print(help(module.predict))

res = module.predict(5.0, 2.0, 3.5, 1.0)
res2 = module.predict_proba(5.0, 2.0, 3.5, 1.0)

print(res, res2)
"""
    def test_delete_module(self):
        assert mas.get_module(self.MODULE_NAME) is not None

        mas.delete_module(self.MODULE_NAME)

        assert mas.get_module(self.MODULE_NAME) is None
    def test_get_module(self):
        module = mas.get_module(self.MODULE_NAME)

        assert module.id == self.MODULE_NAME