Data2Model / templates /result.html
Nausad's picture
Upload 25 files
facf506 verified
Raw History Blame Contribute Delete
15.2 kB
{% extends "base.html" %}
{% block title %}Training Results - Data2Model{% endblock %}
{% block content %}
<div class="container my-5">
<div class="text-center mb-5">
<h1 class="display-4">
<i class="fas fa-check-circle text-success"></i> Training Complete!
</h1>
<p class="lead">Your machine learning model has been successfully trained</p>
</div>
<!-- Model Information -->
<div class="row mb-4">
<div class="col-lg-8 mx-auto">
<div class="card shadow">
<div class="card-header bg-success text-white">
<h4 class="mb-0">
<i class="fas fa-trophy"></i> Best Model: {{ pipeline.model_name }}
</h4>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-6">
<p><strong>Problem Type:</strong>
<span class="badge bg-primary">{{ pipeline.problem_type|title }}</span>
</p>
<p><strong>Algorithm:</strong> {{ pipeline.model_name }}</p>
</div>
<div class="col-md-6">
<p><strong>Target Variable:</strong> {{ pipeline.target_name }}</p>
<p><strong>Features Used:</strong> {{ pipeline.feature_names|length }}</p>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Performance Metrics -->
<div class="row mb-4">
<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-chart-bar"></i> Performance Metrics
</h4>
</div>
<div class="card-body">
{% if pipeline.problem_type == 'classification' %}
<!-- Classification Metrics -->
<div class="row text-center">
<div class="col-md-3 mb-3">
<div class="metric-box">
<h3 class="text-success">{{ "%.2f%%"|format(results.results.accuracy * 100) }}</h3>
<p class="text-muted">Test Accuracy</p>
</div>
</div>
<div class="col-md-3 mb-3">
<div class="metric-box">
<h3 class="text-info">{{ "%.2f%%"|format(results.results.precision * 100) }}</h3>
<p class="text-muted">Precision</p>
</div>
</div>
<div class="col-md-3 mb-3">
<div class="metric-box">
<h3 class="text-warning">{{ "%.2f%%"|format(results.results.recall * 100) }}</h3>
<p class="text-muted">Recall</p>
</div>
</div>
<div class="col-md-3 mb-3">
<div class="metric-box">
<h3 class="text-primary">{{ "%.2f%%"|format(results.results.f1_score * 100) }}</h3>
<p class="text-muted">F1 Score</p>
</div>
</div>
</div>
{% if results.results.validation_accuracy %}
<div class="alert alert-info mt-3">
<strong>Validation Set Accuracy:</strong> {{ "%.2f%%"|format(results.results.validation_accuracy * 100) }}
<br><small>Large dataset detected - used 60% training, 20% testing, 20% validation split</small>
</div>
{% endif %}
{% elif pipeline.problem_type == 'regression' %}
<!-- Regression Metrics -->
<div class="row text-center">
<div class="col-md-3 mb-3">
<div class="metric-box">
<h3 class="text-success">{{ "%.4f"|format(results.results.r2_score) }}</h3>
<p class="text-muted">Test R² Score</p>
</div>
</div>
<div class="col-md-3 mb-3">
<div class="metric-box">
<h3 class="text-info">{{ "%.4f"|format(results.results.rmse) }}</h3>
<p class="text-muted">RMSE</p>
</div>
</div>
<div class="col-md-3 mb-3">
<div class="metric-box">
<h3 class="text-warning">{{ "%.4f"|format(results.results.mae) }}</h3>
<p class="text-muted">MAE</p>
</div>
</div>
<div class="col-md-3 mb-3">
<div class="metric-box">
<h3 class="text-danger">{{ "%.4f"|format(results.results.mse) }}</h3>
<p class="text-muted">MSE</p>
</div>
</div>
</div>
{% if results.results.validation_r2 %}
<div class="alert alert-info mt-3">
<strong>Validation Set Metrics:</strong> R² = {{ "%.4f"|format(results.results.validation_r2) }},
RMSE = {{ "%.4f"|format(results.results.validation_rmse) }}
<br><small>Large dataset detected - used 60% training, 20% testing, 20% validation split</small>
</div>
{% endif %}
{% endif %}
<div class="mt-4">
<h6>Metrics Explained:</h6>
<ul class="small text-muted">
{% if pipeline.problem_type == 'classification' %}
<li><strong>Accuracy:</strong> Percentage of correct predictions</li>
<li><strong>Precision:</strong> Of predicted positives, how many were correct</li>
<li><strong>Recall:</strong> Of actual positives, how many were found</li>
<li><strong>F1 Score:</strong> Harmonic mean of precision and recall</li>
{% else %}
<li><strong>R² Score:</strong> Proportion of variance explained (closer to 1 is better)</li>
<li><strong>RMSE:</strong> Root Mean Square Error (lower is better)</li>
<li><strong>MAE:</strong> Mean Absolute Error (lower is better)</li>
<li><strong>MSE:</strong> Mean Squared Error (lower is better)</li>
{% endif %}
</ul>
</div>
</div>
</div>
</div>
</div>
<!-- Preprocessing Steps -->
<div class="row mb-4">
<div class="col-lg-8 mx-auto">
<div class="card shadow">
<div class="card-header bg-info text-white">
<h4 class="mb-0">
<i class="fas fa-tasks"></i> Preprocessing Steps Applied
</h4>
</div>
<div class="card-body">
<ol>
{% for step in pipeline.preprocessing_steps %}
<li>{{ step }}</li>
{% endfor %}
</ol>
</div>
</div>
</div>
</div>
<!-- Split Info Banner -->
<div class="row mb-4">
<div class="col-lg-8 mx-auto">
{% if results.use_val %}
<div class="alert alert-success d-flex align-items-center gap-3">
<i class="fas fa-check-circle fa-2x"></i>
<div>
<strong>3-Way Split Used:</strong> {{ results.split_info }}<br>
<span class="small">Model trained, tested, and validated — Prediction is fully unlocked!</span>
</div>
</div>
{% else %}
<div class="alert alert-success d-flex align-items-center gap-3">
<i class="fas fa-check-circle fa-2x"></i>
<div>
<strong>2-Way Split Used:</strong> {{ results.split_info }}<br>
<span class="small">Model trained and tested — Prediction is fully unlocked!</span>
</div>
</div>
{% endif %}
</div>
</div>
<!-- Download Section -->
<div class="row mb-4">
<div class="col-lg-8 mx-auto">
<div class="card shadow border-success">
<div class="card-body text-center">
<h4>
<i class="fas fa-download"></i> Download Your Model
</h4>
<p class="text-muted">
Save the trained model for future predictions
</p>
<a href="{{ url_for('download_model') }}" class="btn btn-success btn-lg">
<i class="fas fa-download"></i> Download Model (.pkl)
</a>
</div>
</div>
</div>
</div>
<!-- Deployable App Download Section -->
<div class="row mb-4">
<div class="col-lg-8 mx-auto">
<div class="card shadow border-primary" style="background: linear-gradient(135deg, #1e293b, #0f172a); border-width: 2px;">
<div class="card-body text-center py-4">
<div class="mb-3">
<span style="font-size: 3rem;">🚀</span>
</div>
<h4 class="text-white">
<i class="fas fa-box-open"></i> Download Deployable Web App
</h4>
<p class="text-white-50 mb-1">
Get a <strong class="text-info">complete, ready-to-run Flask application</strong> with your trained model built-in.
</p>
<p class="text-white-50 small mb-3">
Includes <code>app.py</code>, a beautiful <code>index.html</code>, model artifacts, and <code>requirements.txt</code>.<br>
Just unzip → <code>pip install -r requirements.txt</code> → <code>python app.py</code> and you're live!
</p>
<a href="{{ url_for('download_app') }}" class="btn btn-lg text-white px-5 py-3" style="background: linear-gradient(135deg, #6366f1, #4f46e5); border: none; border-radius: 14px; font-weight: 700; font-size: 1.1rem; transition: all 0.3s;" onmouseover="this.style.transform='translateY(-2px)'; this.style.boxShadow='0 12px 30px rgba(99,102,241,0.35)';" onmouseout="this.style.transform=''; this.style.boxShadow='';">
<i class="fas fa-file-zipper"></i> Download App (.zip)
</a>
<div class="mt-3">
<span class="badge bg-info"><i class="fas fa-code"></i> app.py</span>
<span class="badge bg-warning text-dark"><i class="fas fa-palette"></i> index.html</span>
<span class="badge bg-success"><i class="fas fa-brain"></i> model.pkl</span>
<span class="badge bg-secondary"><i class="fas fa-list"></i> requirements.txt</span>
</div>
</div>
</div>
</div>
</div>
<!-- Preprocessing Artifacts Download Section (only shown when applicable) -->
{% if model_state.scaling_applied or model_state.encoding_applied %}
<div class="row mb-4">
<div class="col-lg-8 mx-auto">
<div class="card shadow border-info">
<div class="card-header bg-info text-white">
<h5 class="mb-0">
<i class="fas fa-cogs"></i> Download Preprocessing Artifacts
</h5>
</div>
<div class="card-body">
<p class="text-muted small mb-3">
These fitted preprocessing objects were used during training.
Download and reuse them during inference to ensure consistent transformations.
</p>
<div class="d-flex flex-wrap gap-3 justify-content-center">
{% if model_state.scaling_applied %}
<a href="{{ url_for('download_scaler') }}" class="btn btn-outline-primary btn-lg">
<i class="fas fa-balance-scale"></i> Download Scaler (.pkl)
<span class="badge bg-primary ms-2">Numeric</span>
</a>
{% endif %}
{% if model_state.encoding_applied %}
<a href="{{ url_for('download_encoder') }}" class="btn btn-outline-warning btn-lg">
<i class="fas fa-tag"></i> Download Encoder (.pkl)
<span class="badge bg-warning text-dark ms-2">Categorical</span>
</a>
{% endif %}
</div>
</div>
</div>
</div>
</div>
{% endif %}
<!-- Actions -->
<div class="row">
<div class="col-lg-8 mx-auto">
<div class="d-grid gap-2">
{% if predict_unlocked %}
<a href="{{ url_for('predict') }}" class="btn btn-primary btn-lg">
<i class="fas fa-chart-line"></i> Make Predictions
<span class="badge bg-success ms-2">Unlocked</span>
</a>
{% else %}
<button class="btn btn-secondary btn-lg" disabled title="Retrain with 3-way split to unlock">
<i class="fas fa-lock"></i> Make Predictions
<span class="badge bg-dark ms-2">Locked — needs Train/Test/Val split</span>
</button>
{% endif %}
<a href="{{ url_for('index') }}" class="btn btn-outline-secondary">
<i class="fas fa-plus"></i> Train Another Model
</a>
</div>
</div>
</div>
</div>
<style>
.metric-box {
padding: 20px;
border-radius: 10px;
background-color: #f8f9fa;
}
.metric-box h3 {
font-size: 2.5rem;
font-weight: bold;
margin-bottom: 5px;
}
.metric-box p {
margin-bottom: 0;
font-weight: 500;
}
</style>
{% endblock %}