forked from enviPath/enviPy
Fixes #90 Fixes #91 Fixes #115 Fixes #104 Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#116
45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
from django.test import TestCase
|
|
|
|
from django.test import TestCase
|
|
|
|
from epdb.logic import PackageManager
|
|
from epdb.models import User, MLRelativeReasoning, Package
|
|
|
|
|
|
class ModelTest(TestCase):
|
|
fixtures = ["test_fixtures.json.gz"]
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
super(ModelTest, cls).setUpClass()
|
|
cls.user = User.objects.get(username='anonymous')
|
|
cls.package = PackageManager.create_package(cls.user, 'Anon Test Package', 'No Desc')
|
|
cls.BBD_SUBSET = Package.objects.get(name='Fixtures')
|
|
|
|
def test_smoke(self):
|
|
threshold = float(0.5)
|
|
|
|
# get Package objects from urls
|
|
rule_package_objs = [self.BBD_SUBSET]
|
|
data_package_objs = [self.BBD_SUBSET]
|
|
eval_packages_objs = []
|
|
|
|
mod = MLRelativeReasoning.create(
|
|
self.package,
|
|
rule_package_objs,
|
|
data_package_objs,
|
|
eval_packages_objs,
|
|
threshold,
|
|
'ECC - BBD - 0.5',
|
|
'Created MLRelativeReasoning in Testcase',
|
|
)
|
|
|
|
mod.build_dataset()
|
|
mod.build_model()
|
|
print("Model built!")
|
|
mod.evaluate_model()
|
|
print("Model Evaluated")
|
|
|
|
results = mod.predict('CCN(CC)C(=O)C1=CC(=CC=C1)C')
|
|
print(results)
|