2D Binary Classification
Classification problems involve predicting which category or class an input belongs to. In 2D binary classification, we have two features (X₁ and X₂) and need to separate data points into two classes.

In civil engineering, this could represent: • Soil stability: Classifying soil samples as "stable" or "unstable" based on moisture content and density
Structural safety: Categorizing bridge components as "safe" or "requires inspection" based on load and age
Traffic flow: Predicting "congested" vs "free-flowing" traffic based on time of day and weather conditions

The goal is to find a decision boundary that best separates the two classes, minimizing classification errors.
How to Use This Demo:
• Select different Decision Boundary Types to handle nonlinear data patterns
• Adjust the parameters shown below the boundary type (different parameters appear for different types)
• Use the "Click adds" dropdown to select which class to add, then click anywhere on the plot to add data points
• Use "Generate New Data" to create random 2D classification data
• Use "Clear All Data" to remove all points
Find Optimal Solution: Optimizes parameters for the selected boundary type

Interactive Features:
• Click on the plot to manually add data points of the selected class
• Watch how the decision boundary changes as you adjust parameters
• Observe real-time updates to accuracy and loss metrics
Visual Elements:
Red circles: Class 0 data points
Blue squares: Class 1 data points
Solid line: Decision boundary (50% probability - where the model is most uncertain)
Dotted lines: Probability contours at 25% and 75% - show regions of high confidence for each class
Background shading: Probability regions (redder = more likely Class 0, bluer = more likely Class 1)

Boundary Types:
Linear: Uses w₁, w₂, b → Straight line boundary
Quadratic: Uses w₁, w₂, b, w₁₁, w₂₂, w₁₂ → Curved boundaries (ellipses, parabolas)
Mathematical Foundation:
Binary classification uses the sigmoid function to map any real value to a probability between 0 and 1:

P(y=1|x)=σ(f(x))=11+ef(x)

Where f(x) is the decision function that depends on the boundary type:
Linear: f(x)=w1x1+w2x2+b
Quadratic: f(x)=w1x1+w2x2+w11x12+w22x22+w12x1x2+b

The decision boundary occurs where f(x)=0 (50% probability).
Optimization Tips:
• Start with linear boundaries for linearly separable data
• Use quadratic boundaries when data forms curved patterns
• The "Find Optimal Solution" button uses gradient descent to minimize loss

Interpreting Results:
Accuracy: Percentage of correctly classified points (higher is better)
Loss: Cross-entropy loss measuring prediction confidence (lower is better)
• Perfect separation: Loss approaches 0, accuracy approaches 100%
• Overfitting risk: Complex boundaries may not generalize to new data

Engineering Applications:
• Use simpler boundaries (linear) when interpretability is important
• Complex boundaries may be needed for real-world civil engineering data
• Always validate on separate test data to check generalization
f(x)=σ(0.1x1+0.1x2+0)
Accuracy=100.0%
Loss=0.509
0.1
0.1
0