Back to work

Academic prototype · public source

Pneumonia Model Comparison Prototype

A Flask-based academic interface for loading a CSV dataset and comparing illustrative Random Forest, SVM, and CNN result summaries through JSON responses and generated accuracy charts.

Academic project developerPublic prototype · non-diagnostic
architectureCSV upload → Flask routes → model-result summaries → cached Matplotlib chart

3

algorithm result sets

5

HTTP routes in the committed prototype

CSV

accepted dataset format

0

trained models included in source

The system

From operational problem to reliable workflow.

Problem

The project explores how a simple web interface can present multiple classification-result summaries, confusion matrices, and comparative accuracy visualizations for a pneumonia-detection topic.

Approach

A Flask server accepts a CSV upload, exposes endpoints for running one or all named algorithms, accumulates result summaries, and renders a base64 Matplotlib chart. The committed source uses fixed illustrative metrics rather than training models at runtime.

Outcome

The repository demonstrates API routing, file handling, JSON response design, server-side chart generation, and comparison-state management, while remaining explicitly an academic visualization prototype rather than a medical model.

Architecture

System architecture

The committed project is best understood as a web/API prototype for comparing model-result presentations. Its source does not contain a CNN architecture, image preprocessing pipeline, training loop, serialized model, or chest X-ray inference endpoint. The case study therefore documents the actual Flask and visualization work instead of repeating the repository title as a production claim.

Flask application

Hosts the interface routes, upload handler, algorithm-selection endpoint, reset behavior, and chart endpoint.

Python · Flask · Flask-CORS

Dataset intake

Accepts a multipart file, loads CSV content into a process-level Pandas DataFrame, and returns the dataset size or a parsing error.

Pandas · multipart upload

Result registry

Returns fixed classification reports, confusion matrices, and accuracy values for Random Forest, SVM, and CNN labels and accumulates selected outputs in memory.

Python dictionaries · JSON

Visualization layer

Builds a comparative accuracy bar chart, annotates percentages, encodes the PNG as base64, and caches it by the selected-result signature.

Matplotlib Agg · BytesIO · base64

Execution model

End-to-end execution

  1. 01

    Upload a dataset

    The browser posts a CSV file; Flask validates that a file exists and Pandas parses it into in-memory state.

  2. 02

    Select comparison scope

    The client requests Random Forest, SVM, CNN, or all result sets through the algorithm endpoint.

  3. 03

    Return illustrative metrics

    The server returns fixed precision, recall, F1, support, confusion matrix, and accuracy structures and stores them in the accumulated-result map.

  4. 04

    Render a comparison chart

    The chart endpoint converts accumulated accuracies into a labeled bar chart and returns a base64 PNG, reusing the cache for an identical result signature.

Implementation

What Harshitha implemented

  • Defined Flask endpoints for page rendering, CSV upload, algorithm selection, accumulated state, and chart generation.
  • Handled missing files, CSV parsing failures, unknown algorithm names, and chart-generation exceptions through JSON responses.
  • Structured classification-report and confusion-matrix payloads consistently across three named algorithms.
  • Used Matplotlib's non-interactive Agg backend so chart rendering can run in a server process.
  • Encoded generated figures as base64 PNG data and cached charts by a key derived from the accumulated accuracy state.

Contribution summary

  • Built Flask routes for the home, upload, algorithm execution, chart generation, and accumulated-result reset flows.
  • Implemented CSV ingestion with success/error JSON responses and in-memory dataset state.
  • Represented precision, recall, F1, support, confusion matrix, and accuracy results for three algorithm labels.
  • Generated and cached a base64 Matplotlib comparison chart for the accumulated results.

Failure design

Reliability engineering

R01

Risk

A missing or invalid upload crashes the request.

Control

The upload route checks filename presence and catches Pandas parsing exceptions before returning structured errors.

R02

Risk

Server-side plotting requires a desktop display.

Control

Matplotlib uses the Agg backend and writes figures to an in-memory buffer.

R03

Risk

Repeated chart requests redo the same rendering work.

Control

A result-derived cache key reuses the base64 chart for unchanged accumulated metrics.

R04

Risk

Illustrative metrics are mistaken for a validated medical model.

Control

The portfolio explicitly labels the values as fixed prototype data and the project as non-diagnostic.

Tradeoffs

Technical decisions

Document the implementation as a comparison prototype

The public source supports Flask, data-loading, JSON, and charting claims, but it does not support a trained-CNN or X-ray inference claim.

Keep chart output in memory

BytesIO and base64 avoid temporary image files for a small academic demo.

Use a consistent metrics schema

Matching report and matrix shapes make it simpler for one client UI to compare different algorithm labels.

Credibility

Evidence and scope

Attribution boundary

This is an academic Flask visualization prototype, not a diagnostic device and not evidence of a trained CNN. No medical use, clinical accuracy, or 97% validated performance is claimed because the public source contains fixed illustrative metrics rather than a training or inference implementation.

Technology

PythonFlaskFlask-CORSPandasMatplotlibJSON APIs