-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83c8e6c
commit 7b9c77e
Showing
3 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from flask import Flask, render_template, request, redirect, jsonify | ||
import pandas as pd | ||
import joblib # Assuming you're using a pre-trained model | ||
import os | ||
|
||
app = Flask(__name__) | ||
|
||
# Load your pre-trained model | ||
model = joblib.load('modelo_seleccionado.pkl') # Use your trained model file | ||
|
||
# Home route to display the HTML form | ||
@app.route('/') | ||
def index(): | ||
return render_template('index.html') | ||
|
||
# Route to handle the CSV upload and prediction | ||
@app.route('/upload', methods=['POST']) | ||
def upload_file(): | ||
if 'file' not in request.files: | ||
return redirect('/') | ||
|
||
file = request.files['file'] | ||
|
||
if file.filename == '': | ||
return redirect('/') | ||
|
||
if file: | ||
# Assuming the file is a CSV, load it into a DataFrame | ||
data = pd.read_csv(file) | ||
|
||
# Make predictions using your model | ||
predictions = model.predict(data) | ||
|
||
# Convert predictions to a format you can return (e.g., a list or JSON) | ||
results = {'predictions': predictions.tolist()} | ||
|
||
# Return the predictions as a JSON response | ||
return jsonify(results) | ||
|
||
if __name__ == "__main__": | ||
app.run(debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.