def get(self, requests, id_for_task): return Training.statusOfModel(id_for_task)
def test_5_AutoMLTrain(self): logging.info( "Test Case : Perform preprocessing and train AutoML model.") filePath = os.path.abspath( 'testUseCase/supportdata/mpg_data_example2.csv') result = Training.autoMLdataprocess(filePath) tempa = json.loads(result.__dict__['_container'][0]) newPMMLFileName = 'xyz.pmml' target_variable = 'mpg' true = True false = False dataPreprocessingsteps = { "data": [{ "position": 1, "variable": "mpg", "dtype": "float64", "missing_val": 0, "changedataType": "Continuous", "imputation_method": "None", "data_transformation_step": "None", "use_for_model": true }, { "position": 2, "variable": "cylinders", "dtype": "int64", "missing_val": 0, "changedataType": "Continuous", "imputation_method": "None", "data_transformation_step": "None", "use_for_model": true }, { "position": 3, "variable": "displacement", "dtype": "float64", "missing_val": 0, "changedataType": "Continuous", "imputation_method": "None", "data_transformation_step": "None", "use_for_model": true }, { "position": 4, "variable": "horsepower", "dtype": "float64", "missing_val": 6, "changedataType": "Continuous", "imputation_method": "Mean", "data_transformation_step": "None", "use_for_model": true }, { "position": 5, "variable": "weight", "dtype": "int64", "missing_val": 0, "changedataType": "Continuous", "imputation_method": "None", "data_transformation_step": "None", "use_for_model": true }, { "position": 6, "variable": "acceleration", "dtype": "float64", "missing_val": 0, "changedataType": "Continuous", "imputation_method": "None", "data_transformation_step": "None", "use_for_model": true }, { "position": 7, "variable": "model year", "dtype": "int64", "missing_val": 0, "changedataType": "Categorical", "imputation_method": "None", "data_transformation_step": "None", "use_for_model": true }, { "position": 8, "variable": "origin", "dtype": "int64", "missing_val": 0, "changedataType": "Categorical", "imputation_method": "None", "data_transformation_step": "One Hot Encoding", "use_for_model": true }, { "position": 9, "variable": "car name", "dtype": "object", "missing_val": 0, "changedataType": "Categorical", "imputation_method": "None", "data_transformation_step": "None", "use_for_model": false }], "problem_type": "Regression", "target_variable": target_variable, "idforData": tempa['idforData'], 'newPMMLFileName': newPMMLFileName, 'filePath': filePath, "parameters": [] } result2 = Training.autoMLtrainModel(dataPreprocessingsteps) result2 = json.loads(result2.__dict__['_container'][0]) self.assertEqual('pID' in result2, True) self.assertEqual('status' in result2, True) self.assertEqual('newPMMLFileName' in result2, True) self.assertEqual('targetVar' in result2, True) self.assertEqual('problem_type' in result2, True) self.assertEqual('idforData' in result2, True) self.assertEqual(result2['status'], 'In Progress') self.assertEqual(result2['newPMMLFileName'], newPMMLFileName) self.assertEqual(result2['targetVar'], target_variable) self.assertEqual(result2['idforData'], tempa['idforData']) result = Utility.runningTaskList() self.assertEqual(result.status_code, 200) self.assertEqual( 'runningTask' in json.loads(result.__dict__['_container'][0]), True) self.assertEqual( len(json.loads(result.__dict__['_container'][0])['runningTask']), 1) idforData = tempa['idforData'] result = Training.statusOfModel(idforData) self.assertEqual(result.status_code, 200) result = json.loads(result.__dict__['_container'][0]) self.assertEqual('pID' in result, True) self.assertEqual('status' in result, True) self.assertEqual('idforData' in result, True) idforData = tempa['idforData'] result = Utility.deleteTaskfromMemory(idforData) self.assertEqual( 'idforData' in json.loads(result.__dict__['_container'][0]), True) self.assertEqual( 'message' in json.loads(result.__dict__['_container'][0]), True) self.assertEqual( json.loads(result.__dict__['_container'][0])['idforData'], tempa['idforData']) self.assertEqual( json.loads(result.__dict__['_container'][0])['message'], 'Deleted successfully') result = Utility.runningTaskList() self.assertEqual(result.status_code, 200) self.assertEqual( 'runningTask' in json.loads(result.__dict__['_container'][0]), True) self.assertEqual( len(json.loads(result.__dict__['_container'][0])['runningTask']), 0) logging.info("PASSED")