Exemple #1
0
    def test_rf_algorithm(self):

        my_alg = RandomForestClassifier()
        response = my_alg.compute_prediction(self.input_data)
        self.assertEqual('OK', response['status'])
        self.assertTrue('label' in response)
        self.assertEqual('<=50K', response['label'])
Exemple #2
0
 def test_rf_algorithm(self):
     input_data = {
         "gender": "male",
         "race/ethnicity": "group A",
         "parental level of education": "bachelor's degree",
         "lunch": "standard",
         "math score": 99,
         "reading score": 99,
         "writing score": 99
     }
     my_alg = RandomForestClassifier()
     response = my_alg.compute_prediction(input_data)
     self.assertNotEqual('OK', response['status'])
     self.assertFalse('label' in response)
 def test_rf_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 = RandomForestClassifier()
     response = my_alg.compute_prediction(input_data)
     self.assertEqual("OK", response["status"])
     self.assertTrue("label" in response)
     self.assertEqual("Approved", response["label"])
Exemple #4
0
 def test_rf_algorithm(self):
     input_data = {
         "Age": 37,
         "Workclass": "Private",
         "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,
         "Country": "United-States"
     }
     my_alg = RandomForestClassifier()
     response = my_alg.compute_prediction(input_data)
     self.assertEqual('OK', response['status'])
     self.assertTrue('label' in response)
     self.assertEqual(False, response['label'])
Exemple #5
0
	def test_rf_algorithm(self):
		input_data = {"age": 37,
            "workclass": "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 = RandomForestClassifier()
		response = my_alg.compute_prediction(input_data)
		self.assertEqual("OK", response['status'])
		self.assertTrue("label" in response)
		self.assertEqual("<=50k", response["label"])
Exemple #6
0
    def test_rf_algorithm(self):
        input_data = {
            "age": 37,
            "workclass": "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 = RandomForestClassifier()
        response = my_alg.compute_prediction(input_data)
        self.assertEqual('OK', response['status'])
        self.assertTrue('label' in response)
        self.assertEqual('<=50K', response['label'])

        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 = "Piotr"
            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)
Exemple #7
0
 def test_rf_algorithm(self):
     input_data = {
         "age": 48,
         "workclass": "Private",
         "fnlwgt": 171095,
         "education": "Assoc-acdm",
         "education-num": 12,
         "marital-status": "Divorced",
         "occupation": "Exec-managerial",
         "relationship": "Unmarried",
         "race": "White",
         "sex": "Female",
         "capital-gain": 0,
         "capital-loss": 0,
         "hours-per-week": 40,
         "native-country": "England"
     }
     my_alg = RandomForestClassifier()
     response = my_alg.compute_prediction(input_data)
     print(response)
     self.assertEqual('OK', response['status'])
     self.assertTrue('label' in response)
     self.assertEqual('<=50K', response['label'])