def get_model_types(): """ Route for getting all supported models' types, currently only CNN, FullGP, SparseGP :return: JSON """ model_types = ModelApi.get_model_types() if not isinstance(model_types, list): return response_failure(Errors.NO_DATA.value) return response_success(model_types)
def get_all_models(): """ Route for getting all models' names and types only from the DB :return: JSON """ models = ModelApi.get_all_models() if models is None: return response_failure(models) return response_success(models)
def get_models(model_type): """ Route for getting models that are of given model type (CNN, GP, SparseGP up to date) :param model_type: :return: JSON """ models, err = ModelApi.get_models_by_type(model_type) if models is not None: return response_success(models) return response_failure(err)
def get_model_params(name): """ Route for getting model parameters of a given model :param name: str - name of the model :return: JSON """ model = ModelApi.get_model_params(name) if model is not None: return response_success(model) return response_failure(Errors.NO_SUCH_MODEL.value)
def predict_single_instance(): """ Route for creating a new arbitrary instance and making prediction on its :return: JSON """ REQUIRED_PARAMS = [ 'name', 'date_time', 'longitude', 'latitude', 'pollutant' ] body = request.json missing_param = Helpers.are_params_missing(body, REQUIRED_PARAMS) if missing_param: return response_failure(Errors.MISSING_PARAM.value) is_successful, predictions = ModelApi.make_single_prediction(body) if not is_successful: # TODO update error message return response_failure('Something went wrong') return response_success(predictions)
def concurrent_train_model(model_name, body): return ModelApi.train_model(model_name, body)
def concurrent_make_predictions(body): return ModelApi.make_predictions(body)
def concurrent_create_model(model_name, body): return ModelApi.create_model(model_name, body)