Data2Model / templates /predict.html
Nausad's picture
Upload 25 files
facf506 verified
Raw History Blame Contribute Delete
6.05 kB
{% extends "base.html" %}
{% block title %}Predict - Data2Model{% endblock %}
{% block content %}
<div class="container my-5">
<div class="text-center mb-4">
<h1 class="display-4">
<i class="fas fa-chart-line"></i> Make Predictions
</h1>
<p class="lead">Use your validated model to predict on new data</p>
</div>
<!-- Model Status Banner -->
<div class="row mb-4">
<div class="col-lg-8 mx-auto">
<div class="alert alert-success d-flex align-items-center gap-3 mb-0">
<i class="fas fa-unlock-alt fa-2x"></i>
<div>
<strong>Model Ready:</strong> {{ model_state.model_name }}
<span class="badge bg-primary ms-2">{{ model_state.problem_type|title }}</span><br>
<small>Split: {{ model_state.split_info }} — trained, tested &amp; validated ✓</small>
</div>
</div>
</div>
</div>
{% if predictions %}
<!-- Predictions Results -->
<div class="row mb-4">
<div class="col-lg-10 mx-auto">
<div class="card shadow">
<div class="card-header bg-success text-white">
<h4 class="mb-0">
<i class="fas fa-check-circle"></i> Predictions Generated Successfully!
</h4>
</div>
<div class="card-body">
<p>Total predictions made: <strong>{{ predictions|length }}</strong></p>
<div class="table-responsive mt-3">
<table class="table table-striped table-hover">
<thead class="table-dark">
<tr>
<th>Row #</th>
<th>Prediction</th>
</tr>
</thead>
<tbody>
{% for i, pred in enumerate(predictions) %}
<tr>
<td>{{ i + 1 }}</td>
<td><span class="badge bg-primary">{{ pred }}</span></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% if predictions|length == 100 %}
<p class="text-muted small">
<i class="fas fa-info-circle"></i> Showing first 100 predictions.
Download the full file to see all results.
</p>
{% endif %}
<div class="d-grid gap-2 mt-3">
<a href="{{ url_for('static', filename='predictions.csv') }}"
class="btn btn-success btn-lg" download>
<i class="fas fa-download"></i> Download Full Predictions (CSV)
</a>
<button type="button" class="btn btn-outline-primary" onclick="location.reload()">
<i class="fas fa-redo"></i> Make Another Prediction
</button>
</div>
</div>
</div>
</div>
</div>
{% else %}
<!-- Upload Form for Prediction -->
<div class="row">
<div class="col-lg-8 mx-auto">
<div class="card shadow">
<div class="card-header bg-primary text-white">
<h4 class="mb-0">
<i class="fas fa-upload"></i> Upload Data for Prediction
</h4>
</div>
<div class="card-body">
<form action="{{ url_for('predict') }}" method="post" enctype="multipart/form-data">
<div class="mb-4">
<label for="file" class="form-label">
<strong>Select your dataset file</strong>
</label>
<input type="file" class="form-control" id="file" name="file"
accept=".csv,.xlsx,.xls,.json" required>
<div class="form-text">
Upload a file with the same features as your training data
</div>
</div>
<div class="alert alert-info">
<h6 class="alert-heading">
<i class="fas fa-info-circle"></i> Important Notes:
</h6>
<ul class="mb-0">
<li>Ensure your data has the <strong>same features</strong> as the training data</li>
<li>Feature names and order should match</li>
<li>Do NOT include the target column in prediction data</li>
<li>Missing values will be handled automatically</li>
</ul>
</div>
<div class="d-grid gap-2">
<button type="submit" class="btn btn-primary btn-lg">
<i class="fas fa-play"></i> Generate Predictions
</button>
<a href="{{ url_for('index') }}" class="btn btn-outline-secondary">
<i class="fas fa-arrow-left"></i> Back to Home
</a>
</div>
</form>
</div>
</div>
</div>
</div>
{% endif %}
</div>
{% if predictions %}
<script>
// Add enumerate filter functionality
Jinja2.filters.enumerate = function(arr) {
return arr.map((item, index) => [index, item]);
};
</script>
{% endif %}
{% endblock %}