Skip to content

Commit

Permalink
pdate
Browse files Browse the repository at this point in the history
  • Loading branch information
aarevalom0 committed Oct 7, 2024
1 parent 83c8e6c commit 7b9c77e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
41 changes: 41 additions & 0 deletions docs/app.py
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)
8 changes: 5 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ <h2>Data Analysis Plus 📊</h2>
<a href="descriptive statistics report.html" class="action-button">View Descriptive Statistical Analysis</a>
</section>

<section id="usage-guide">
<section id="usage-guide WEB">
<h2>How to Use the Model</h2>
<p>To utilize our model, follow these simple steps:</p>
<h3>1. Open the Jupyter Notebook</h3>
Expand All @@ -178,8 +178,10 @@ <h3>1. Open the Jupyter Notebook</h3>
<li>Click on the file to open it.</li>
</ol>
<h3>2. Upload Your CSV File</h3>
<p>Use the button below to upload your CSV file for analysis:</p>
<a href="upload.html" class="action-button">Upload CSV</a>
<form method="POST" enctype="multipart/form-data" action="/upload">
<input type="file" name="file" accept=".csv" required />
<button type="submit">Upload and Predict</button>
</form>
<h3>3. Analyze the Results</h3>
<p>Run the notebook cells and discover insights from your data!</p>
</section>
Expand Down
Binary file added docs/modelo_seleccionado.pkl
Binary file not shown.

0 comments on commit 7b9c77e

Please sign in to comment.