Exemplo n.º 1
0
def predict():
    if request.method == 'POST':
        Cylinders = int(request.form['Cylinders'])
        Displacement = float(request.form['Displacement'])
        Horsepower = float(request.form['Horsepower'])
        Weight = float(request.form['Weight'])
        Acceleration = float(request.form['Acceleration'])
        Model_Year = int(request.form['Model_Year'])
        Origin = int(request.form['Origin'])

        if Origin == 1:
            country = [1, 2, 3]
        elif Origin == 2:
            country = [2, 1, 3]
        else:
            country = [3, 1, 2]

        vehicle_config = {
            'Cylinders': [Cylinders, 2, 4],
            'Displacement': [Displacement, 100, 130],
            'Horsepower': [Horsepower, 93, 120],
            'Weight': [Weight, 2500, 3500],
            'Acceleration': [Acceleration, 13, 15],
            'Model Year': [Model_Year, 78, 82],
            'Origin': country
        }

        # data = np.array([[preg, glucose, bp, st, insulin, bmi, dpf, age]])
        my_prediction = predict_mpg(vehicle_config, classifier)

    return render_template('result.html', prediction=my_prediction[0])
Exemplo n.º 2
0
def predict():
    vehicle = request.get_json()
    print(vehicle)
    with open('./model_files/model.bin', 'rb') as f_in:
        model = pickle.load(f_in)
        f_in.close()
    predictions = predict_mpg(vehicle, model)

    result = {'mpg_prediction': list(predictions)}
    return jsonify(result)
Exemplo n.º 3
0
def predict():
    vehicle_config = request.get_json()
    with open(" ./model_files/model.bin", 'rb') as f_in:
        model = pickle.load(f_in)
        f_in.close()
    predictions = predict_mpg(vehicle_config, model)

    response = {'mpg_predictions': list(predictions)}

    return jsonify(response)
def predict():
    vehicle = request.get_json()
    print(vehicle)
    with open('./model_files/model.bin', 'rb') as f_in:
        model = pickle.load(f_in)
        f_in.close()
    predictions = predict_mpg(vehicle, model)
    result = {'mpg_prediction': list(predictions)}
    return jsonify(result)


# @app.route('/ping', methods=['GET'])
# def ping():
#     return "Pinging Model!!"

# Commented code below while deploying.
# if __name__ == '__main__':
#     app.run(debug=True, host='localhost', port=9696)