def ez_load(): ''' This function calls the API which allows the user to upload training data in a file. The accepted file formats are .csv and .xlsx. ''' try: global auth_token global 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 = {"accelerate":"no"} #Calling the eazyml library function for loading data response = eazyml.ez_load(auth_token, filepath_train, options) dataset_id = response['dataset_id'] print("Output of ez_load function is", response) except Exception as e: print('The function ez_load was not executed properly', e)
def train_data(token, file_path): options = { "id": "null", "impute": "yes", "outlier": "yes", "discard": [ "started", "extinguished", "counties", "latitude", "longitude", "acresBurned", "visibility", "uvIndex" ], "accelerate": "yes", "outcome": "wildfireIntensity" } response = ez.ez_load(token, file_path, options) if response and response["status_code"] != 200: print("Dataset could not uploaded", response["message"]) return None, None dataset_id = response["dataset_id"] #Now building the model options = { "model_type": "predictive", "derive_text": "no", "derive_numeric": "no", "accelerate": "yes" } response = ez.ez_init_model(token, dataset_id, options) if response and response["status_code"] != 200: print("Model could not build", response["message"]) return None, None model_id = response["model_id"] best_model = response["model_performance"]["data"][0][0] return model_id, best_model
"impute": "yes", "outlier": "yes", "discard": "null", "accelerate": "yes", "outcome": "Major Incident" } 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(
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