Exemplo n.º 1
0
class ProblemTest(unittest.TestCase):
    def setUp(self):
        self.problem = Problem("BinaryClassification", "../../../examples/data/iris.csv")
        self.problem.set_label("Name")

    def tearDown(self):
        self.problem = None

    def test_data_read(self):
        self.assertEqual(len(self.problem.data), 100)

    def test_problem_reload(self):
        self.problem.save("test_problem.json", "test_data.json")
        self.problem.load("test_problem.json", "test_data.json")
        self.test_problem_descriptions()

    def test_problem_descriptions(self):
        self.assertEqual(self.problem.label, "Name")
        self.assertEqual(self.problem.problem_type, "BinaryClassification")
        self.assertEqual(self.problem.file_path, "../../../examples/data/iris.csv")
Exemplo n.º 2
0
__author__ = 'Jiarui Xu'

from learnpy.Problem import Problem

# create a problem with training data
pro = Problem("BinaryClassification", "./data/iris_training.csv")

# set the predictor variable
pro.set_label('Name')

# save the problem
pro.save("problem.json", "data.json")
# load the problem
pro.load("problem.json", "data.json")

pro.set_model("SVM")
pro.model.fit(None)

# set testing data
pro.set_testing("./data/iris_testing.csv")
pro.predict()


# new problem for 242 demo

# create a problem
pro2 = Problem("BinaryClassification", "./data/lin_training.csv")

# set the predictor variable
pro2.set_label('Name')