def training(data): print('inside controller') # removing rows with label values data = data.dropna(subset=[label]) tabclient = Client(tabpy_serverurl) # dataframe to json input_data = json.loads(data.to_json(orient='records')) returnResult = tabclient.query('RapidMiner_Train', go_url, go_username, go_password, input_data, label,cost_matrix,high_value,low_value,selection_criteria, max_min_crietria_selector, platform) final_out = json_normalize(returnResult['response']) return final_out
def quick_training(training_data): # removing rows with label values training_data = training_data.dropna(subset=[label]) tabclient = Client(tabpy_serverurl) # dataframe to json+ responseJSON = training_data.to_json(orient='records') input_data = json.loads(responseJSON) returnResult = tabclient.query('Rapidminer_Quick_Training', go_url, go_username, go_password, input_data, label,selection_criteria,max_min_crietria_selector,'tabprep') final_out = json_normalize(returnResult['response']) return final_out
TASK_STATE = 'state' FINISHED_STATUS = 'FINISHED' ERROR_STATUS = 'ERROR' COMPLETE_STATUS = [FINISHED_STATUS, ERROR_STATUS] DATA_ID = 'id' DEPLOYMENT_ID = 'DeploymentID' STATUS = 'Deployment_Status' MODEL = 'Deployed_Model' MODELING_ID = 'Modeling_ID' URL = 'URL' depID = '' AUTODEPLOY = True client = '' tabclient = Client('http://localhost:9004/') #new update def rapidminer_quick_training(go_url, gouser, gopassword, input_data, label, selection_criteria, max_min_crietria_selector, platform): from rapidminer_go_python import rapidminergoclient as amw # To get the AMW instance client = amw.RapidMinerGoClient(go_url, gouser, gopassword) data = client.convert_json_to_dataframe(input_data) trainingResult = client.quick_automodel(data, label, AUTODEPLOY, selection_criteria,
go_url = 'https://go.rapidminer.com' go_username = '' go_password = '' #values to be changed based on data label = 'Survived' cost_matrix =[[1,-1],[-1,1]] high_value = 'Yes' low_value = 'No' #### possible values, selection_criteria = 'performance_accuracy' max_min_crietria_selector = 'max' #or 'min' should_deploy = True platform = 'tabprep' tabclient = Client(tabpy_serverurl) STATUS = 'Deployment_Status' MODEL = 'Deployed_Model' DEPLOYMENT_ID = 'DeploymentID' MODELING_ID = 'Modeling_ID' URL = 'URL' def training(data): print('inside controller') # removing rows with label values data = data.dropna(subset=[label]) tabclient = Client(tabpy_serverurl) # dataframe to json input_data = json.loads(data.to_json(orient='records')) returnResult = tabclient.query('RapidMiner_Train', go_url, go_username, go_password, input_data, label,cost_matrix,high_value,low_value,selection_criteria, max_min_crietria_selector, platform)
import tabpy import json from tabpy_client import Client import pandas as pd tabclient = Client('http://localhost:9004/') go_url = 'https://go.rapidminer.com' go_username = '' go_password = '' #values to be changed based on data deployment_ID = '' label = 'Survived' PREDICTION = 'prediction(' + label + ')' def score(test): #removing rows with label values test = test[pd.isnull(test[label])] # dataframe to json input_data = json.loads(test.to_json(orient='records')) returnResult = tabclient.query('RapidMiner_Score', go_url, go_username, go_password, input_data, label, deployment_ID) test[PREDICTION] = returnResult['response'] return test #This function defines the output schema #***Change the schema according to your result*** def get_output_schema():
for x in variables_categoricas: df[x] = df[x].astype(str) for x in variables_binarias: df[x] = df[x].fillna(0) df[x] = df[x].astype(np.int8) for x in variables_numericas: df[x] = df[x].apply(lambda c: getCleanPrice(c)) df[x] = df[x].astype(float) full_pipeline.transform(df) tree_predictions = tree_reg.predict(listing_prepared) tree_mse = mean_squared_error(listing_label, tree_predictions) tree_rmse = np.sqrt(tree_mse) tree_mae = mean_absolute_error(listing_label, tree_predictions) print("DecisionTreeRegressor:\nRMSE = ${:.4f}\nMAE = ${:.4f}".format( tree_rmse, tree_mae)) print("-" * 100) forest_predictions = forest_reg.predict(listing_prepared) forest_mse = mean_squared_error(listing_label, forest_predictions) forest_rmse = np.sqrt(forest_mse) forest_mae = mean_absolute_error(listing_label, forest_predictions) print("RandomForestRegressor:\nRMSE = ${:.4f}\nMAE = ${:.4f}".format( forest_rmse, forest_mae)) return [price for price in forest_predictions] cliente = Client("http://localhost:9004") cliente.deploy("hostPricePredictor", hostPricePredictor, "Calcula el precio del hosting segun los parametros recibidos", override=True)