ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
Loading...
Searching...
No Matches
ppforest2::cli::serve Namespace Reference

Classes

struct  LoadedModel
 Immutable model snapshot captured once at server startup. More...
 
struct  PredictionResult
 Result of running a prediction request — kept around for the predictions store so the server can serve cached HTML on shareable URLs. More...
 
class  PredictionStore
 In-memory bounded store of recent prediction results, keyed by opaque IDs that survive a page refresh. Capacity-limited LRU; evicts the oldest entry once capacity is reached. More...
 
struct  Response
 Status, body, MIME content type, and extra response headers. More...
 

Functions

Response handle_health (std::string const &version)
 GET /health → 200 with status + version.
 
Response handle_predict (LoadedModel const &loaded, PredictionStore &store, std::string const &csv_body)
 POST /predict (Accept: application/json) → 200 with {predictions, [proportions], [metrics], id}.
 
Response handle_predict_html (LoadedModel const &loaded, PredictionStore &store, std::string const &csv_body)
 POST /predict (Accept: text/html) → 200 with the predict page rendered against the new result. Content-Location header points to the canonical /predict?id=<id> URL so the browser can update its address bar and share/refresh works.
 
Response handle_predict_view (LoadedModel const &loaded, PredictionStore const &store, std::string const &id_query)
 GET /predict → 200 with the predict page (always showing the upload form). When id_query refers to an entry still in the store, the results section is also populated.
 
Response handle_summarize (LoadedModel const &loaded)
 GET / (Accept: application/json) → 200 with the loaded model JSON, minus the heavy model field.
 
Response handle_summary_html (LoadedModel const &loaded)
 GET / (Accept: text/html) → 200 with a self-contained HTML page rendering meta, training metrics, and variable importance.
 

Function Documentation

◆ handle_health()

Response ppforest2::cli::serve::handle_health ( std::string const & version)

GET /health → 200 with status + version.

◆ handle_predict()

Response ppforest2::cli::serve::handle_predict ( LoadedModel const & loaded,
PredictionStore & store,
std::string const & csv_body )

POST /predict (Accept: application/json) → 200 with {predictions, [proportions], [metrics], id}.

Stores the result in store so the corresponding GET endpoint can return the same data later. The id field in the body and the Content-Location: /predict?id=<id> header point to the canonical URL.

Returns
400 on malformed CSV / feature-name mismatch.

◆ handle_predict_html()

Response ppforest2::cli::serve::handle_predict_html ( LoadedModel const & loaded,
PredictionStore & store,
std::string const & csv_body )

POST /predict (Accept: text/html) → 200 with the predict page rendered against the new result. Content-Location header points to the canonical /predict?id=<id> URL so the browser can update its address bar and share/refresh works.

◆ handle_predict_view()

Response ppforest2::cli::serve::handle_predict_view ( LoadedModel const & loaded,
PredictionStore const & store,
std::string const & id_query )

GET /predict → 200 with the predict page (always showing the upload form). When id_query refers to an entry still in the store, the results section is also populated.

◆ handle_summarize()

Response ppforest2::cli::serve::handle_summarize ( LoadedModel const & loaded)

GET / (Accept: application/json) → 200 with the loaded model JSON, minus the heavy model field.

◆ handle_summary_html()

Response ppforest2::cli::serve::handle_summary_html ( LoadedModel const & loaded)

GET / (Accept: text/html) → 200 with a self-contained HTML page rendering meta, training metrics, and variable importance.