def load_model_predict(self): ''' This method validates the supplied parameters, before generating a prediction, using a chosen stored model from the NoSQL cache. ''' # instantiate class session = ModelPredict(self.data) # implement class methods if not session.validate_arg_none(): session.validate_premodel_settings() session.check() my_prediction = session.predict() if my_prediction['error']: response = { 'status': 1, 'result': my_prediction['error'], 'type': 'model-predict' } else: response = { 'status': 0, 'result': my_prediction, 'type': 'model-predict' } return json.dumps(response)
def load_data_new(self): ''' This method validates the supplied parameters, before being stored as new entries, into corresponding tables in the SQL database. ''' # instantiate class session = DataNew(self.data, self.uid) # implement class methods if not session.validate_arg_none(): session.validate_premodel_settings() session.convert_dataset() session.save_premodel_dataset() session.save_entity('data_new') session.check() response = { 'status': 0, 'msg': 'Dataset(s) properly uploaded into database', 'type': 'data-new' } else: print session.get_errors() response = { 'status': 1, 'msg': 'Dataset(s) not uploaded into database', 'type': 'data-new' } return json.dumps(response)
def load_model_generate(self): ''' This method validates the supplied parameters, before generating a model into a NoSQL cache, using a chosen stored dataset from the SQL database. ''' # instantiate class session = ModelGenerate(self.data) # generate model if not session.validate_arg_none(): session.validate_premodel_settings() session.check() session.generate_model() # return if session.return_error(): response = { 'status': 1, 'msg': 'Model not generated', 'type': 'model-generate' } else: response = { 'status': 0, 'msg': 'Model properly generated', 'type': 'model-generate' } return json.dumps(response)
def load_data_append(self): ''' This method validates the supplied parameters, before being appended to existing entries, from corresponding tables in the SQL database. ''' # instantiate class session = DataAppend(self.data, self.uid) # define current session id collection = self.data['properties']['collection'] session_id = Session().get_session_id(collection)['result'] session.validate_id(session_id) # implement class methods if not session.validate_arg_none() and not session.get_errors(): session.validate_premodel_settings() session.convert_dataset() session.save_premodel_dataset() session.save_entity('data_append', session_id) session.check() response = { 'status': 0, 'msg': 'Dataset(s) properly appended into database', 'type': 'data-append' } else: print session.get_errors() response = { 'status': 1, 'msg': 'Dataset(s) not uploaded into database', 'type': 'data-append' } return json.dumps(response)