Files
gogo2/UI_FIXES_AND_TRAINING_ENHANCEMENT.md
Dobromir Popov 5349e23563 wip
2025-12-10 16:02:19 +02:00

4.6 KiB

UI Fixes and Training Enhancement - Complete

Issues Addressed

1. Training on Yellow Dotted Line Predictions

Problem: Yellow dotted lines (trend vectors) weren't being trained on because trend_vector data wasn't included in live predictions.

Fix Applied:

  • Added trend_vector extraction to _get_live_transformer_prediction()
  • Now includes: calculated_angle, calculated_steepness, calculated_direction
  • Both line types (yellow dotted + dash-dot) can now be trained on

Result: Model can learn from both trend predictions and action predictions.

2. UI State Persistence After Page Reload

Problem: If you started online learning and reloaded the page, UI would reset and not show active training session.

Fix Applied:

  • Added /api/training-session-status endpoint
  • Added restoreUIState() JavaScript function
  • Automatically restores on page load:
    • Shows inference status panel
    • Hides start buttons, shows stop button
    • Restores timeframe and prediction steps
    • Resumes polling for metrics

Result: UI now reflects actual server state after page reload.

3. Pivot Point Hover Fix

Problem: Pivot tooltips triggered when hovering over vertical lines, not just the pivot dots.

Fix Applied:

  • Added hoverinfo: 'skip' to all pivot lines (dashed horizontal lines)
  • Only pivot dots (triangular markers) now trigger hover tooltips
  • Applied to all chart updates to ensure consistency

Result: Hover tooltips only appear when hovering directly over pivot points.

4. Enhanced Loss Calculation Debugging

Problem: Candle loss calculation seemed wrong - showing <1% difference when actual vs predicted directions were opposite.

Fix Applied:

  • Added detailed logging for accuracy calculations
  • Logs predicted vs actual OHLC values
  • Shows direction predictions and correctness
  • Displays individual field errors and overall accuracy

Debug Output Example:

ACCURACY DEBUG for 1m_2025-12-10T14:30:00Z:
  Predicted: O=3320.15 H=3325.42 L=3318.23 C=3322.61
  Actual:    O=3320.89 H=3326.12 L=3318.45 C=3318.18
  Pred Direction: UP
  Actual Direction: DOWN
  Direction Correct: False
  Accuracy: 87.5%, Avg Error: 1.25%
  Individual Errors: {'open': 0.8, 'high': 1.2, 'low': 0.5, 'close': 0.9}

Result: Can now debug exactly why accuracy calculations appear incorrect.

Training Enhancement

Both Line Types Now Trainable

  1. Yellow Dotted Lines (Trend Vectors):

    • Source: trend_vector from transformer model
    • Data: Angle, steepness, direction predictions
    • Training: Can validate against actual price movement direction
  2. Dash-Dot Lines (Action Predictions):

    • Source: action, confidence, predicted_price from transformer
    • Data: Specific trading signals with price targets
    • Training: Can validate against actual price targets and timing

Training Data Flow

  1. Prediction Made: Both trend and action data generated
  2. Actual Candle Arrives: Compare predicted vs actual
  3. Accuracy Calculated: Detailed error analysis for each component
  4. Backpropagation: Train model on prediction errors
  5. Checkpoint Saved: Best models preserved

UI State Management

Session Restoration

  • Training Status: Shows if online learning is active
  • Button States: Correct start/stop button visibility
  • Settings: Timeframe and prediction steps restored
  • Polling: Metrics and trading stats resume automatically

Hover Behavior

  • Pivot Points: Only dots trigger tooltips, not lines
  • Ghost Candles: Rich accuracy information on hover
  • Prediction Lines: Action markers show confidence levels

Debugging Capabilities

Accuracy Calculation

The detailed logging will help identify if the issue is:

  1. Wrong candle comparison: Comparing prediction at time T with candle at time T instead of T+1
  2. Direction calculation error: Logic error in up/down determination
  3. Percentage calculation: Error in how percentage differences are computed
  4. Data timing: Mismatch between prediction timestamp and validation timestamp

Next Steps for Loss Investigation

With the enhanced logging, you can now:

  1. Check timestamps: Verify prediction and actual candle timestamps align correctly
  2. Verify direction logic: Confirm up/down calculations are correct
  3. Validate percentages: Ensure error calculations match expected values
  4. Debug timing: Identify if predictions are being compared to the right candles

The system now provides complete visibility into the training process and should help identify the root cause of any accuracy calculation discrepancies!