예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
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)
예제 #4
0
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)
예제 #5
0
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)
예제 #6
0
 def concurrent_train_model(model_name, body):
     return ModelApi.train_model(model_name, body)
예제 #7
0
 def concurrent_make_predictions(body):
     return ModelApi.make_predictions(body)
예제 #8
0
 def concurrent_create_model(model_name, body):
     return ModelApi.create_model(model_name, body)