Skip to content

app.routers.ml

ml

ML model performance: metrics, predictions, feature importance, correlation.

get_correlation_matrix async

get_correlation_matrix(request: Request)

Feature correlation matrix from training data. Cached after first request.

Source code in dashboard/backend/app/routers/ml.py
@router.get("/correlation-matrix")
async def get_correlation_matrix(request: Request):
    """Feature correlation matrix from training data. Cached after first request."""
    engine = request.app.state.engine
    return await run_in_threadpool(_get_correlation_matrix_sync, engine)

get_price_distributions async

get_price_distributions(request: Request, source: str = Query('historical', pattern='^(historical|forecast)$'), scenario: str = Query(''))

Price distribution statistics by year for violin plots.

Source code in dashboard/backend/app/routers/ml.py
@router.get("/price-distributions")
async def get_price_distributions(
    request: Request,
    source: str = Query("historical", pattern="^(historical|forecast)$"),
    scenario: str = Query(""),
):
    """Price distribution statistics by year for violin plots."""
    engine = request.app.state.engine

    if source == "forecast":
        if not scenario:
            raise HTTPException(400, "scenario required for forecast distributions")
        return await run_in_threadpool(
            _get_price_distributions_forecast_sync, engine, scenario
        )

    return await run_in_threadpool(_get_price_distributions_historical_sync, engine)