Ejemplo n.º 1
0
def batch_prediction_route_client():
    """
    * method: batch_prediction_route_client
    * description: method to call batch prediction route
    * return: none
    *
    *
    * Parameters
    *   None
    """
    try:
        config = Config()
        # get run id
        run_id = config.get_run_id()
        data_path = config.prediction_data_path
        # prediction object initialization
        predictModel = PredictModel(run_id, data_path)
        # prediction the model
        predictModel.batch_predict_from_model()
        return Response("Prediction successfull! and its RunID is : " +
                        str(run_id))
    except ValueError:
        return Response("Error Occurred! %s" % ValueError)
    except KeyError:
        return Response("Error Occurred! %s" % KeyError)
    except Exception as e:
        return Response("Error Occurred! %s" % e)
Ejemplo n.º 2
0
def training_route_client():
    """
    * method: training_route_client
    * description: method to call training route
    * return: none
    *
    * Parameters
    *   None
    """
    try:
        config = Config()
        # get run id
        run_id = config.get_run_id()
        data_path = config.training_data_path
        # trainmodel object initialization
        trainModel = TrainModel(run_id, data_path)
        # training the model
        trainModel.training_model()
        return Response("Training successfull! and its RunID is : " +
                        str(run_id))
    except ValueError:
        return Response("Error Occurred! %s" % ValueError)
    except KeyError:
        return Response("Error Occurred! %s" % KeyError)
    except Exception as e:
        return Response("Error Occurred! %s" % e)
Ejemplo n.º 3
0
def single_prediction_route_client():

    try:
        config = Config()
        #get run id
        run_id = config.get_run_id()
        data_path = config.prediction_data_path
        print('Test')

        if request.method == 'POST':
            satisfaction_level = request.form['satisfaction_level']
            last_evaluation = request.form["last_evaluation"]
            number_project = request.form["number_project"]
            average_montly_hours = request.form["average_montly_hours"]
            time_spend_company = request.form["time_spend_company"]
            work_accident = request.form["work_accident"]
            promotion_last_5years = request.form["promotion_last_5years"]
            salary = request.form["salary"]

            data = pd.DataFrame(data=[[
                0, satisfaction_level, last_evaluation, number_project,
                average_montly_hours, time_spend_company, work_accident,
                promotion_last_5years, salary
            ]],
                                columns=[
                                    'empid', 'satisfaction_level',
                                    'last_evaluation', 'number_project',
                                    'average_montly_hours',
                                    'time_spend_company', 'Work_accident',
                                    'promotion_last_5years', 'salary'
                                ])
            # using dictionary to convert specific columns
            convert_dict = {
                'empid': int,
                'satisfaction_level': float,
                'last_evaluation': float,
                'number_project': int,
                'average_montly_hours': int,
                'time_spend_company': int,
                'Work_accident': int,
                'promotion_last_5years': int,
                'salary': object
            }

            data = data.astype(convert_dict)

            # object initialization
            predictModel = PredictModel(run_id, data_path)
            # prediction the model
            output = predictModel.single_predict_from_model(data)
            print('output : ' + str(output))
            return Response("Predicted Output is : " + str(output))
    except ValueError:
        return Response("Error Occurred! %s" % ValueError)
    except KeyError:
        return Response("Error Occurred! %s" % KeyError)
    except Exception as e:
        return Response("Error Occurred! %s" % e)
def batch_prediction_route_client():
	try:
		config = Config()
		run_id = config.get_run_id()
		data_path = config.prediction_data_path
		predictModel = PredictModel(run_id, data_path)
		predictModel.batch_predict_from_model()
		return Response("Prediction sucessfull with RunID : " + str(run_id))
	except ValueError:
		return Response("Error Occured! %s" % ValueError)
	except KeyError:
		return Reponse("Error Occured! %s" % KeyError)
	except Exception as e:
		return Response("Error Occured! %s" % e)
def training_route_client():
	try:
		config = Config()
		run_id = config.get_run_id()
		data_path = config.training_data_path
		trainModel = TrainModel(run_id, data_path)
		trainModel.training_model()
		return Response("Training sucessfull with RunID : " + str(run_id))
	except ValueError:
		return Response("Error Occured! %s" % ValueError)
	except KeyError:
		return Reponse("Error Occured! %s" % KeyError)
	except Exception as e:
		return Response("Error Occured! %s" % e)
Ejemplo n.º 6
0
def batch_prediction_route_client():

    try:
        config = Config()
        #get run id
        run_id = config.get_run_id()
        data_path = config.prediction_data_path
        #prediction object initialization
        predictModel=PredictModel(run_id, data_path)
        #prediction the model
        predictModel.batch_predict_from_model()
        return Response("Prediction successfull! and its RunID is : "+str(run_id))
    except ValueError:
        return Response("Error Occurred! %s" % ValueError)
    except KeyError:
        return Response("Error Occurred! %s" % KeyError)
    except Exception as e:
        return Response("Error Occurred! %s" % e)
Ejemplo n.º 7
0
from apps.data_ingestion.scrap_load_validate import ScrapeLoadValidate
from apps.core.config import Config

if __name__ == '__main__':
    try:
        #initiate the Config class
        config = Config()
        #get run_id
        run_id = config.get_run_id()
        #Get training data file path
        data_path = config.training_data_path
        #initiate TrainModel object
        scrap_load_validate = ScrapeLoadValidate(run_id,data_path)
        df = scrap_load_validate.get_data_glassdoor()
        print(df.head())
    except Exception as e:
        print(e)