def ez_predict():
    try:
        global auth_token
        global model_id
        global prediction_dataset_id
        options = {}
        response = eazyml.ez_predict(auth_token, model_id, filepath_test,
                                     options)
        prediction_dataset_id = response['prediction_dataset_id']
    except Exception as e:
        print('The function ez_predict was not executed properly', e)
Exemple #2
0
def predict(token, model_id, model_name, predict_file):
    options = {"model_name": model_name}

    response = ez.ez_predict(token, model_id, predict_file, options)
    if response and response["status_code"] != 200:
        print("Could not predict", response["message"])
        return None
    prediction_id = response["prediction_dataset_id"]
    #options =  {
    #
    #   "record_number": list(range(1, len(response['predictions']['indices'])+1))
    #
    #    }
    #response_explain = ez.ez_explain(token, model_id, prediction_id, options)
    return response
Exemple #3
0
def ez_predict():

    '''
    This function calls the API which allows you to predict the outcome variable
    for each record in the given prediction (or test) dataset
    '''
    try:
        global auth_token
        global model_id
        global prediction_dataset_id

        #The options dictionary that is to be provided as part of the request payload. 
        #Please check the API guide for more parameters
        options = {}

        #Calling the eazyml library function for prediction
        response = eazyml.ez_predict(auth_token, model_id, filepath_test, options)
        prediction_dataset_id = response['prediction_dataset_id']
        print("Output of ez_predict function is", response)
    except Exception as e:
        print('The function ez_predict was not executed properly', e)
Exemple #4
0
def ez_predict():

    '''
    This function calls the API which allows you to predict the outcome variable
    for each record in the given prediction (or test) dataset
    '''
    try:
        ##global auth_token
        ##global model_id
        #WHAT IS THIS ID??????####
        global prediction_dataset_id

        #The options dictionary that is to be provided as part of the request payload. 
        #Please check the API guide for more parameters
        options = {}

        #Calling the eazyml library function for prediction
        #put exact values here
        response = eazyml.ez_predict(auth_token, model_id = 12411, filepath_test="C:\Users\csankar1\Downloads\eazyml-client-mastercsankar1\Downloads\eazyml-client-master\book1.csv", options)
        ##prediction_dataset_id = response['predict_dataset_id']
        print(response)
    except Exception as e:
        print('The function ez_predict was not executed properly', e)
Exemple #5
0
ez_model_config = {
    "model_type": "predictive",
    "derive_text": "no",
    "derive_numeric": "no",
    "accelerate": "yes"
}

#loading the training data
resp = eazyml.ez_load(auth_token, train_file_path, options)
dataset_id = resp["dataset_id"]

#building the model
resp = eazyml.ez_init_model(auth_token, dataset_id, ez_model_config)
model_id = resp["model_id"]
model_name = resp["model_performance"]["data"][0][0]

options = {"model_name": model_name}

#getting final response with answers and displaying to user
response = eazyml.ez_predict(auth_token, model_id, 'prediction.csv', options)
for row in response['predictions']['data']:
    answer = row[-1]
    if answer == 'TRUE':
        print(
            "There is a likely chance that a wildfire here would become a major incident. "
        )
    if answer == 'FALSE':
        print(
            "There is an unlikely chance that a wildfire here would become a major incident. "
        )
def main_function(county_name):
    big_df = pd.read_csv("webserver\\big_data.csv")
    dates = big_df["Date"]
    county_column = big_df[county_name]

    average = sum(list(big_df[county_name])) / 310

    result = pd.concat([dates, county_column], axis=1)
    result.to_csv("webserver\\dataset.csv", index=False)

    #authentication to use api
    username = '******'
    password = '******'
    train_file_path = 'webserver\\dataset.csv'

    resp = eazyml.ez_auth(username, None, password)
    auth_token = resp["token"]

    options = {
        "id": "null",
        "impute": "yes",
        "outlier": "yes",
        "discard": "null",
        "accelerate": "yes",
        "shuffle": "no",
        "outcome": county_name
    }

    ez_model_config = {
        "model_type": "timeseries",
        "derive_text": "no",
        "derive_numeric": "no",
        "accelerate": "yes",
        "date_time_column": "Date"
    }

    #loading the training data
    resp = eazyml.ez_load(auth_token, train_file_path, options)
    print(resp)
    dataset_id = resp["dataset_id"]

    #building the model
    resp = eazyml.ez_init_model(auth_token, dataset_id, ez_model_config)
    resp = eazyml.ez_get_models(auth_token)
    print(resp)
    model_id = resp["dataframe"]["data"][0][4]

    prediction_df = pd.DataFrame({
        'Date': ["6/30/2020", "12/31/2020"],
        'Monmouth': ["", ""]
    })
    prediction_df.to_csv("webserver\\prediction.csv", index=False)
    #getting final response with answers and displaying to user
    response = eazyml.ez_predict(auth_token, model_id,
                                 'webserver\\prediction.csv')
    half_year = float(response["predictions"]["data"][0][2])
    if half_year > average:
        half_year_statement = True
    else:
        half_year_statement = False
    full_year = float(response["predictions"]["data"][1][2])
    if full_year > average:
        full_year_statement = True
    else:
        full_year_statement = False
    return half_year, half_year_statement, full_year, full_year_statement