Interactive Query

This page describes the interactive query component of the project. It allows users to submit live morphology data and receive instant classification results from the trained breast cancer model.

Interface Purpose

The query interface simulates how a clinician might enter measured tumor features into a diagnostic system. It serves both as a functional utility and a demonstration of the model's practical applicability in real-time contexts.

Diagnostic Support

Provides rapid feedback on whether a tumor profile is likely malignant or benign.

Model Transparency

Displays prediction probability and confidence, helping users assess trustworthiness.

Input Structure

The model expects a 30-dimensional input vector, mirroring the original dataset's structure. Each entry corresponds to a numeric feature like mean radius, worst concavity, etc.

{
  "radius_mean": 14.5,
  "texture_mean": 19.0,
  "perimeter_mean": 95.5,
  ...
  "fractal_dimension_worst": 0.087
}

All values are required, and the frontend form includes helper text and valid ranges for each.

Prediction Workflow

The query system sends an AJAX POST request to a Flask API endpoint. The server parses and validates the JSON payload, scales the values using the same pipeline used in training, and runs the model prediction.

@app.route("/predict", methods=["POST"])
def predict():
    data = request.get_json()
    X_input = pd.DataFrame([data])
    X_scaled = scaler.transform(X_input)
    prob = model.predict_proba(X_scaled)[0][1]
    result = int(prob > 0.5)
    return jsonify({"malignant": result, "confidence": round(prob, 4)})

The API returns a binary result and confidence score for rendering in the UI.

Validation and Feedback

The frontend validates entries for:

  • Presence and numeric format
  • Reasonable range (based on training set min/max)
  • Auto-formatting decimals and padding

When predictions are returned, the interface displays both the diagnosis and a color-coded confidence meter.

Sample Interaction

A user enters morphology metrics and clicks “Run Diagnosis.” The result section updates instantly:

Input:

{ radius_mean: 17.2, concavity_worst: 0.25, ... }
          

Response:

{ malignant: 1, confidence: 0.9821 }
          

Key Takeaways

  • The interactive interface lets users engage directly with the trained model.
  • It handles real-time prediction, input validation, and feedback visualization.
  • Diagnostic outcomes are backed by confidence scores to guide decision-making.