Beispiel #1
0
 def test_registry(self):
     registry = MLRegistry()
     self.assertEqual(len(registry.endpoints), 0)
     endpoint_name = "income_classifier"
     algorithm_object = RandomForestClassifier()
     algorithm_name = "random forest"
     algorithm_status = "production"
     algorithm_version = "0.0.1"
     algorithm_owner = "Alex"
     algorithm_description = "Random Forest with simple pre- and post-processing"
     algorithm_code = inspect.getsource(RandomForestClassifier)
     # add to registry
     registry.add_algorithm(endpoint_name, algorithm_object, algorithm_name,
                            algorithm_status, algorithm_version,
                            algorithm_owner, algorithm_description,
                            algorithm_code)
     # there should be one endpoint available
     self.assertEqual(len(registry.endpoints), 1)
     endpoint_name = "income_classifier"
     algorithm_object = ExtraTreesClassifier()
     algorithm_name = "extra trees"
     algorithm_status = "production"
     algorithm_version = "0.0.1"
     algorithm_owner = "Alex"
     algorithm_description = "Extra Trees with simple pre- and post-processing"
     algorithm_code = inspect.getsource(ExtraTreesClassifier)
     # add to registry
     registry.add_algorithm(endpoint_name, algorithm_object, algorithm_name,
                            algorithm_status, algorithm_version,
                            algorithm_owner, algorithm_description,
                            algorithm_code)
     # there should be one endpoint available
     self.assertEqual(len(registry.endpoints), 2)
 def test_et_algorithm(self):
     input_data = {
         "Gender": "Male",
         "Married": "Yes",
         "Dependents": 2,
         "Education": "Graduate",
         "Self_Employed": "Yes",
         "ApplicantIncome": 5849,
         "CoapplicantIncome": 6000,
         "LoanAmount": 120,
         "Loan_Amount_Term": 360,
         "Credit_History": 1,
         "Property_Area": "Urban",
     }
     my_alg = ExtraTreesClassifier()
     response = my_alg.compute_prediction(input_data)
     self.assertEqual("OK", response["status"])
     self.assertTrue("label" in response)
     self.assertEqual("Approved", response["label"])
Beispiel #3
0
 def test_et_algorithm(self):
     input_data = {
         "age": 37,
         "workplace": "Private",
         "fnlwgt": 34146,
         "education": "HS-grad",
         "education-num": 9,
         "marital-status": "Married-civ-spouse",
         "occupation": "Craft-repair",
         "relationship": "Husband",
         "race": "White",
         "sex": "Male",
         "capital-gain": 0,
         "capital-loss": 0,
         "hours-per-week": 68,
         "native-country": "United-States"
     }
     my_alg = ExtraTreesClassifier()
     response = my_alg.compute_prediction(input_data)
     self.assertEqual('OK', response['status'])
     self.assertTrue('label' in response)
     self.assertEqual('<=50K', response['label'])
 registry = MLRegistry()  # create ML registry
 # Random Forest classifier
 rf = RandomForestClassifier()
 # add to ML registry
 registry.add_algorithm(
     endpoint_name="income_classifier",
     algorithm_object=rf,
     algorithm_name="random forest",
     algorithm_status="ab_testing",
     algorithm_version="0.0.1",
     owner="Bilal Fourka",
     algorithm_description=
     "Random Forest with simple pre- and post-processing",
     algorithm_code=inspect.getsource(RandomForestClassifier))
 # Extra Trees classifier
 et = ExtraTreesClassifier()
 # add to ML registry
 registry.add_algorithm(
     endpoint_name="income_classifier",
     algorithm_object=et,
     algorithm_name="extra trees",
     algorithm_status="ab_testing",
     algorithm_version="0.0.1",
     owner="Bilal Fourka",
     algorithm_description=
     "Extra Trees with simple pre- and post-processing",
     algorithm_code=inspect.getsource(RandomForestClassifier))
 rfN = RandomForestClassifierN()
 # add to ML registry
 registry.add_algorithm(
     endpoint_name="profile_classifier",
Beispiel #5
0
 def test_et_algorithm(self):
     my_alg = ExtraTreesClassifier()
     response = my_alg.compute_prediction(self.input_data)
     self.assertEqual('OK', response['status'])
     self.assertTrue('label' in response)
     self.assertEqual('<=50K', response['label'])