14#include <nlohmann/json.hpp>
22#include <unordered_map>
39 std::map<std::string, std::string>
headers;
69 std::optional<PredictionResult>
get(std::string
const&
id)
const;
72 mutable std::mutex mu;
74 std::deque<std::string> order;
75 std::unordered_map<std::string, PredictionResult> entries;
Mode-specific evaluation metric blocks.
std::shared_ptr< Model > Ptr
Definition Model.hpp:31
In-memory bounded store of recent prediction results, keyed by opaque IDs that survive a page refresh...
Definition ServeHandlers.hpp:59
std::string put(PredictionResult result)
Store result and return its newly-generated id.
std::optional< PredictionResult > get(std::string const &id) const
Look up id; returns nullopt if not in the store (evicted or never existed).
PredictionStore(std::size_t capacity=DEFAULT_CAPACITY)
static constexpr std::size_t DEFAULT_CAPACITY
Definition ServeHandlers.hpp:61
Definition ServeHandlers.hpp:24
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...
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....
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,...
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],...
std::vector< std::string > Names
Vector of name strings — used uniformly for class labels (group_names[i] is the label for GroupId == ...
Definition Types.hpp:49
Eigen::Matrix< Feature, Eigen::Dynamic, Eigen::Dynamic > FeatureMatrix
Dynamic-size matrix of feature values.
Definition Types.hpp:33
Eigen::Matrix< Outcome, Eigen::Dynamic, 1 > OutcomeVector
Dynamic-size column vector of predictions.
Definition Types.hpp:42
Mode
Training mode.
Definition Types.hpp:58
@ Classification
Definition Types.hpp:58
Immutable model snapshot captured once at server startup.
Definition ServeHandlers.hpp:26
Model::Ptr model
Definition ServeHandlers.hpp:27
nlohmann::json model_json
Definition ServeHandlers.hpp:31
types::Names feature_names
Definition ServeHandlers.hpp:29
types::Names group_names
Definition ServeHandlers.hpp:28
types::Mode mode
Definition ServeHandlers.hpp:30
Result of running a prediction request — kept around for the predictions store so the server can serv...
Definition ServeHandlers.hpp:45
types::OutcomeVector predictions
Definition ServeHandlers.hpp:46
types::FeatureMatrix proportions
Definition ServeHandlers.hpp:47
std::optional< stats::Metrics > metrics
Definition ServeHandlers.hpp:48
Status, body, MIME content type, and extra response headers.
Definition ServeHandlers.hpp:35
std::string body
Definition ServeHandlers.hpp:37
std::map< std::string, std::string > headers
Definition ServeHandlers.hpp:39
int status
Definition ServeHandlers.hpp:36
std::string content_type
Definition ServeHandlers.hpp:38