diff --git a/app.py b/app.py deleted file mode 100644 index 8d6f6e8..0000000 --- a/app.py +++ /dev/null @@ -1,57 +0,0 @@ -from flask import Flask,request, url_for, redirect, render_template -import pickle -import numpy as np -import requests - -app = Flask(__name__) - -model=pickle.load(open('models/RandomForest.pkl','rb')) - - -@app.route('/') -def hello_world(): - return render_template("form.html") - - - -# @app.route('/submit', methods=['GET', 'POST']) -# def predict(): -# if request.method == 'POST': -# try: -# features = [float(x) for x in request.form.values()] -# final = [np.array(features)] -# prediction = model.predict(final) -# print("Prediction successful:", prediction) -# return render_template('prediction.html', pred=prediction) -# except Exception as e: -# print("An error occurred:", e) -# return "An error occurred while processing the prediction." -# else: -# # Handle GET request (if needed) -# return render_template("form.html") - -feature_names = ['no2','so2','pm2_5','pm10','Leq','DO','pH','BOD','Land_use','NBR'] - -@app.route('/submit', methods=['GET','POST']) -def submit(): - try: - features=[float(x) for x in request.form.values()] - final=[np.array(features)] - print("Input features:", final) - prediction = model.predict(final) - output=int(prediction[0]) - print(output) - return render_template('prediction.html', result=output) - except Exception as e: - print("An error occurred:", e) - return f"An error occurred while processing the prediction: {str(e)}" - -@app.route('/predict_api',methods=['POST']) -def predict_api(): - data=request.get_json(force=True) - prediction=model.predict([np.array(list(data.values()))]) - output=prediction[0] - return jsonify(output) - -if __name__ == '__main__': - app.run(host='0.0.0.0', port=3000) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 1dae064..ebe6976 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +Flask==2.2.2 matplotlib==3.7.2 numpy==1.26.4 pandas==2.0.3 @@ -6,5 +7,3 @@ Requests==2.31.0 scikit_learn==1.3.1 seaborn==0.13.2 xgboost==0.90 -Flask -pickle \ No newline at end of file