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'])
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_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)
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 = "v1" algorithm_description = ( "A random forest is a meta estimator that fits a number of decision tree classifiers " "on various sub-samples of the dataset and uses averaging to improve the predictive " "accuracy and control over-fitting. ") algorithm_code = inspect.getsource(RandomForestClassifier) # add to registry registry.add_algorithm( endpoint_name, algorithm_object, algorithm_name, algorithm_status, algorithm_version, algorithm_description, algorithm_code, ) # there should be one endpoint available self.assertEqual(len(registry.endpoints), 1)
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"])
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'])
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_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)
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'])
def test_registry(self): registry = MLRegistry() self.assertEqual(len(registry.endpoint), 0) endpoint_name = "income_classifier" algorithm_object = RandomForestClassifier() algorithm_name = "Random Forest" algorithm_status = "production" algorithm_version = "1.0" owner = "admin" description = "Adding Random Forest Income Classifier" algorithm_code = inspect.getsource(RandomForestClassifier) registry.add_algorithm(endpoint_name, algorithm_object, algorithm_name, algorithm_status, algorithm_version, owner, description, algorithm_code) self.assertEqual(len(registry.endpoint), 1)
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 = "Islambek" algorithm_description = "RF al with pre post proc" algorithm_code = inspect.getsource(RandomForestClassifier) registry.add_algorithm(endpoint_name, algorithm_object, algorithm_name, algorithm_status, algorithm_version, algorithm_owner, algorithm_description, algorithm_code) self.assertEqual(len(registry.endpoints), 1)
def test_registry(self): registry = MLRegistry() self.assertEqual(len(registry.newsite), 0) newsite_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) registry.add_algorithm(newsite_name, algorithm_object, algorithm_name, algorithm_status, algorithm_version, algorithm_owner, algorithm_description, algorithm_code) self.assertEqual(len(registry.newsite), 1)
import os from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') application = get_wsgi_application() # ML registry import inspect from apps.ml.registry import MLRegistry from apps.ml.income_classifier.random_forest import RandomForestClassifier from apps.ml.income_classifier.extra_trees import ExtraTreesClassifier # import ExtraTrees ML algorithm from apps.ml.profile_classifier.random_forestN import RandomForestClassifierN from apps.ml.profile_classifier.extra_treesN import ExtraTreesClassifierN # import ExtraTrees ML algorithm try: 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(