コード例 #1
0
ファイル: main.py プロジェクト: GokulDev4U/Credit_Approval
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)
コード例 #2
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)
コード例 #3
0
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)
コード例 #4
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)