A native MoonBit toolkit for online learning, sparse and dense models, streaming features, evaluation, monitoring, serving, and reproducible model lifecycle workflows.
moon add phjphj676/moon-online-modelslet model = @moon-online-models.AdagradLogisticRegression::new(
3,
learning_rate=0.1,
)
model.update([1.0, 0.0, 0.2], 1.0)
model.update([0.0, 1.0, -0.2], 0.0)
let probability = model.predict([1.0, 0.0, 0.2])let hasher = @moon-online-models.FeatureHasher::new(1_000_000)
let features = hasher.encode(["country=CN", "device=mobile", "slot=home"])
let model = @moon-online-models.SparseAdagradClassifier::new(1_000_000)
model.update(features, 1.0)
let probability = model.predict(features)moon version --all
moon update
moon check --target all
moon test --target all
moon fmt && git diff --exit-code
moon info && git diff --exit-codepub trait Snapshot {
fn to_bytes(Self) -> Bytes
fn from_bytes(Self, Bytes) -> Bool
}fn AdagradLinearRegression::loss(self : AdagradLinearRegression, features : Array[Double], label : Double) -> Doublefn AdagradLinearRegression::new(dimension : Int, learning_rate? : Double, epsilon? : Double, l2? : Double) -> AdagradLinearRegressionfn AdagradLinearRegression::predict(self : AdagradLinearRegression, features : Array[Double]) -> Doublefn AdagradLinearRegression::residual(self : AdagradLinearRegression, features : Array[Double], label : Double) -> Doublefn AdagradLinearRegression::update(self : AdagradLinearRegression, features : Array[Double], label : Double) -> Unitfn AdagradLogisticRegression::logit(self : AdagradLogisticRegression, features : Array[Double]) -> Doublefn AdagradLogisticRegression::loss(self : AdagradLogisticRegression, features : Array[Double], label : Double) -> Doublefn AdagradLogisticRegression::new(dimension : Int, learning_rate? : Double, epsilon? : Double, l1? : Double, l2? : Double) -> AdagradLogisticRegressionfn AdagradLogisticRegression::predict(self : AdagradLogisticRegression, features : Array[Double]) -> Doublefn AdagradLogisticRegression::predict_label(self : AdagradLogisticRegression, features : Array[Double], threshold? : Double) -> Doublefn AdagradLogisticRegression::sparsity(self : AdagradLogisticRegression, tolerance? : Double) -> Doublefn AdagradLogisticRegression::update(self : AdagradLogisticRegression, features : Array[Double], label : Double) -> Unitfn AdagradLogisticRegression::update_weighted(self : AdagradLogisticRegression, features : Array[Double], label : Double, sample_weight : Double) -> Unitpub struct AdagradOptimizer {
learning_rate : Double
epsilon : Double
schedule : LearningRateSchedule
accumulator : Array[Double]
clipper : GradientClipper
step_count : Int
statistics : OptimizerStatistics
}fn AdagradOptimizer::apply(self : AdagradOptimizer, parameters : Array[Double], gradients : Array[Double]) -> Unitfn AdagradOptimizer::new(dimension : Int, learning_rate? : Double, epsilon? : Double, schedule? : LearningRateSchedule, clipper? : GradientClipper) -> AdagradOptimizerpub struct AdamOptimizer {
learning_rate : Double
beta1 : Double
beta2 : Double
epsilon : Double
first_moment : Array[Double]
second_moment : Array[Double]
clipper : GradientClipper
step_count : Int
}fn AdamOptimizer::apply(self : AdamOptimizer, parameters : Array[Double], gradients : Array[Double]) -> Unitfn AdamOptimizer::new(dimension : Int, learning_rate? : Double, beta1? : Double, beta2? : Double, epsilon? : Double, clipper? : GradientClipper) -> AdamOptimizerpub struct AlertRule {
name : String
metric : String
condition : AlertCondition
lower : Double
upper : Double
severity : AlertSeverity
cooldown : Int64
last_alert : Int64?
}fn AlertRule::greater(name : String, metric : String, threshold : Double, severity? : AlertSeverity, cooldown? : Int64) -> AlertRulefn AlertRule::less(name : String, metric : String, threshold : Double, severity? : AlertSeverity, cooldown? : Int64) -> AlertRulefn AlertRule::outside(name : String, metric : String, lower : Double, upper : Double, severity? : AlertSeverity, cooldown? : Int64) -> AlertRulefn AlertRule::stale(name : String, metric : String, max_age : Int64, severity? : AlertSeverity) -> AlertRulepub struct AuditRecord {
event_id : String
actor : String
action : AuditAction
model : String
version : String
timestamp : Int64
detail : String
success : Bool
}fn AuditRecord::new(event_id : String, actor : String, action : AuditAction, model : String, version : String, timestamp : Int64, detail? : String, success? : Bool) -> AuditRecordpub struct AuditTrail {
capacity : Int
records : Array[AuditRecord]
ids : Map[String, Bool]
accepted : Int
duplicates : Int
evicted : Int
}pub struct BernoulliSampler {
probability : Double
rng : DeterministicRng
accepted : Int
seen : Int
}pub struct CalibrationBin {
count : Double
predicted : Double
observed : Double
}fn CalibrationTracker::update(self : CalibrationTracker, prediction : Double, label : Double) -> Unitpub struct CanaryExperiment {
name : String
baseline : String
candidate : String
target_samples : Int
baseline_metric : Double
candidate_metric : Double
samples : Int
}fn CanaryExperiment::new(name : String, baseline : String, candidate : String, target_samples? : Int) -> CanaryExperimentfn CanaryExperiment::observe(self : CanaryExperiment, baseline : Double, candidate : Double) -> Unitpub struct ChangePointDetector {
short : SequenceWindow
long : SequenceWindow
threshold : Double
changes : Int
last_score : Double
}fn ChangePointDetector::new(short_window? : Int, long_window? : Int, threshold? : Double) -> ChangePointDetectorpub struct ClassCost {
false_positive : Double
false_negative : Double
true_positive : Double
true_negative : Double
}pub struct ClickThroughRateTracker {
impressions : Double
clicks : Double
predicted_sum : Double
squared_calibration_error : Double
}fn ClickThroughRateTracker::update(self : ClickThroughRateTracker, probability : Double, clicked : Bool, weight? : Double) -> Unitpub struct ConformalInterval {
residuals : Array[Double]
capacity : Int
confidence : Double
seen : Int
}fn ConformalInterval::coverage(self : ConformalInterval, prediction : Double, label : Double) -> Boolfn ConformalInterval::observe(self : ConformalInterval, prediction : Double, label : Double) -> Unitpub struct ConfusionMatrix {
true_positive : Double
false_positive : Double
true_negative : Double
false_negative : Double
}fn ConfusionMatrix::update(self : ConfusionMatrix, prediction : Double, label : Double, threshold? : Double) -> Unitfn CostSensitiveEvaluator::observe(self : CostSensitiveEvaluator, prediction : Double, label : Double, threshold : Double) -> Doublepub struct CsvOptions {
separator : Char
quote : Char
escape : Char
trim_fields : Bool
skip_empty : Bool
}fn CsvOptions::new(separator? : Char, quote? : Char, escape? : Char, trim_fields? : Bool, skip_empty? : Bool) -> CsvOptionspub struct CumulativeSumDetector {
target : Double
allowance : Double
threshold : Double
positive : Double
negative : Double
}fn CumulativeSumDetector::new(target? : Double, allowance? : Double, threshold? : Double) -> CumulativeSumDetectorpub struct DataLineage {
nodes : Map[String, LineageNode]
edges : Map[String, Array[String]]
registrations : Int
}pub struct DataQualityReport {
rows : Int
accepted : Int
rejected : Int
missing_values : Int
dimension_errors : Int
out_of_range : Int
}fn DataQualityReport::observe(self : DataQualityReport, accepted : Bool, missing : Int, dimension_error : Bool, range_error : Bool) -> Unitfn DenseVector::zip_map(self : DenseVector, other : DenseVector, transform : (Double, Double) -> Double) -> DenseVectorpub struct Deployment {
model : String
version : String
state : DeploymentState
created_at : Int64
updated_at : Int64
traffic : Double
}pub struct DeploymentManager {
deployments : Map[String, Deployment]
policy : RollbackPolicy
transitions : Int
rollbacks : Int
}fn DeploymentManager::get(self : DeploymentManager, model : String, version : String) -> Deployment?fn DeploymentManager::healthy(self : DeploymentManager, accuracy : Double, loss : Double, error_rate : Double) -> Boolfn DeploymentManager::transition(self : DeploymentManager, model : String, version : String, next : DeploymentState, timestamp : Int64) -> Boolpub struct DeterministicRng {
state : UInt64
}pub struct DriftMonitor {
feature_detectors : Array[PageHinkleyDetector]
target_detector : PageHinkleyDetector
feature_drift_events : Int
target_drift_events : Int
}fn DuplicateSignatureTracker::observe(self : DuplicateSignatureTracker, features : Array[Double]) -> Boolpub struct EarlyStopping {
patience : Int
minimum_delta : Double
best : Double
bad_rounds : Int
initialized : Bool
}pub struct ErrorBudget {
target : Double
window : Int
successes : Int
failures : Int
}pub struct EventLog {
capacity : Int
events : Array[TrainingEvent]
ids : Map[String, Bool]
appended : Int
evicted : Int
}pub struct EwmaAnomalyDetector {
baseline : ExponentialMovingVariance
threshold : Double
anomalies : Int
}pub struct ExponentialMovingAverage {
alpha : Double
value : Double
initialized : Bool
}pub struct ExponentialMovingVariance {
alpha : Double
mean : Double
variance : Double
initialized : Bool
}fn FactorizationMachine::new(dimension : Int, rank : Int, learning_rate? : Double, l2? : Double) -> FactorizationMachinefn FairnessMonitor::observe(self : FairnessMonitor, group : String, prediction : Double, label : Double, threshold? : Double) -> Unitpub struct FeatureAttribution {
index : Int
contribution : Double
}pub struct FeatureHasher {
buckets : Int
signed : Bool
}fn FeatureHasher::encode_weighted(self : FeatureHasher, tokens : Array[(String, Double)]) -> SparseVectorpub struct FeatureMaterializer {
schema : FeatureSchema
defaults : Array[Double]
materialized : Int
fallback : Int
}fn FeatureMaterializer::materialize(self : FeatureMaterializer, values : Array[Double]) -> Array[Double]fn FeatureMaterializer::new(schema : FeatureSchema, defaults? : Array[Double]) -> FeatureMaterializerpub struct FeaturePipeline {
standardizer : Standardizer
lower : Array[Double]
upper : Array[Double]
clip_enabled : Bool
hasher : FeatureHasher?
transformed : Int
}fn FeaturePipeline::new(dimension : Int, clip_lower? : Double, clip_upper? : Double, hashing_buckets? : Int) -> FeaturePipelinefn FeaturePipeline::transform_tokens(self : FeaturePipeline, tokens : Array[String]) -> SparseVector?pub struct FeatureRecord {
key : String
version : Int
values : Array[Double]
timestamp : Int64
source : String
}fn FeatureRecord::new(key : String, values : Array[Double], timestamp : Int64, source? : String, version? : Int) -> FeatureRecordfn FeatureSchema::new(name : String, dimension : Int, minimum? : Array[Double], maximum? : Array[Double], required? : Bool) -> FeatureSchemapub struct FeatureStore {
schemas : Map[String, FeatureSchema]
records : Map[String, Array[FeatureRecord]]
capacity : Int
writes : Int
reads : Int
misses : Int
rejected : Int
}pub struct GatedRegressor {
low : OnlineRidgeRegression
high : OnlineRidgeRegression
boundary : Double
low_count : Int
high_count : Int
}fn GatedRegressor::predict(self : GatedRegressor, features : Array[Double], gate : Double) -> Doublefn GatedRegressor::update(self : GatedRegressor, features : Array[Double], gate : Double, label : Double) -> Unitfn GaussianClassStats::log_likelihood(self : GaussianClassStats, features : Array[Double], smoothing? : Double) -> Doublefn GaussianClassStats::update(self : GaussianClassStats, features : Array[Double], weight? : Double) -> Unitpub struct GradientClipper {
max_norm : Double
max_value : Double
}pub struct GradientGuard {
lower : Double
upper : Double
clipped : Int
invalid : Int
}pub struct GroupMetric {
group : String
count : Int
positives : Int
true_positives : Int
false_positives : Int
false_negatives : Int
}fn GroupMetric::observe(self : GroupMetric, prediction : Double, label : Double, threshold? : Double) -> Unitpub struct HashedFeatureSelector {
dimension : Int
importance : ExponentialImportance
threshold : Double
}fn HashedFeatureSelector::observe(self : HashedFeatureSelector, vector : SparseVector, gradient : Double) -> Unitfn HashingVectorizer::new(buckets : Int, lowercase? : Bool, ngram_order? : Int) -> HashingVectorizerfn HistogramAuc::update(self : HistogramAuc, score : Double, label : Double, weight? : Double) -> Unitpub struct HoltWinters {
alpha : Double
beta : Double
gamma : Double
season_length : Int
seasonals : Array[Double]
level : Double
trend : Double
count : Int
}fn HoltWinters::new(season_length : Int, alpha? : Double, beta? : Double, gamma? : Double) -> HoltWintersfn KeyedFeatureJoin::put_features(self : KeyedFeatureJoin, key : String, features : Array[Double]) -> Array[Double]?fn KeyedFeatureJoin::put_label(self : KeyedFeatureJoin, key : String, label : Double) -> Array[Double]?fn LearningCurve::record(self : LearningCurve, train_loss : Double, validation_loss : Double) -> Unitpub struct LineageNode {
dataset : String
source : String
schema : String
row_count : Int
checksum : String
timestamp : Int64
}fn LineageNode::new(dataset : String, source : String, schema : String, row_count : Int, checksum : String, timestamp : Int64) -> LineageNodepub struct LinearEndpoint {
weights : Array[Double]
bias : Double
version : String
prediction_guard : PredictionGuard
requests : Int
rejected : Int
}fn LinearEndpoint::new(weights : Array[Double], bias? : Double, version? : String, lower? : Double, upper? : Double) -> LinearEndpointfn LinearEndpoint::predict(self : LinearEndpoint, request : PredictionRequest) -> PredictionResponsefn LinearEndpoint::predict_batch(self : LinearEndpoint, requests : Array[PredictionRequest]) -> Array[PredictionResponse]pub struct LossAccumulator {
kind : LossKind
parameter : Double
count : Int
weight : Double
total : Double
absolute_gradient : Double
maximum : Double
}fn LossAccumulator::update(self : LossAccumulator, prediction : Double, label : Double, weight? : Double) -> Doublepub struct LossSchedule {
initial : Double
decay : Double
floor : Double
step : Int
}pub struct MetricSnapshot {
name : String
value : Double
timestamp : Int64
samples : Int
}fn MetricSnapshot::new(name : String, value : Double, timestamp : Int64, samples? : Int) -> MetricSnapshotpub struct MetricsTracker {
count : Double
sum_squared_error : Double
sum_log_loss : Double
}fn MiniBatchAccumulator::add(self : MiniBatchAccumulator, features : Array[Double], label : Double, weight? : Double) -> Boolfn ModelArtifact::new(name : String, version : String, checksum : String, created_at : String) -> ModelArtifactpub struct ModelHealth {
accepted : Int
rejected : Int
prediction_errors : Int
inference_failures : Int
latency : MetricSeries
loss : MetricSeries
}fn ModelHealth::record_sample(self : ModelHealth, accepted : Bool, loss : Double, latency_ms : Double) -> Unitpub struct ModelMonitor {
name : String
metrics : Map[String, RunningMoments]
rules : Array[AlertRule]
snapshots : Int
alerts : Int
}fn ModelMonitor::observe(self : ModelMonitor, snapshot : MetricSnapshot, now : Int64) -> Array[String]fn ModelRegistry::promote(self : ModelRegistry, name : String, version : String, stage : String) -> Boolpub struct MomentumOptimizer {
learning_rate : Double
momentum : Double
dampening : Double
velocity : Array[Double]
clipper : GradientClipper
step_count : Int
}fn MomentumOptimizer::apply(self : MomentumOptimizer, parameters : Array[Double], gradients : Array[Double]) -> Unitfn MomentumOptimizer::new(dimension : Int, learning_rate? : Double, momentum? : Double, dampening? : Double, clipper? : GradientClipper) -> MomentumOptimizerpub struct MultivariateAnomalyDetector {
moments : VectorMoments
threshold : Double
anomalies : Int
}fn MultivariateAnomalyDetector::new(dimension : Int, threshold? : Double) -> MultivariateAnomalyDetectorfn MultivariateAnomalyDetector::score(self : MultivariateAnomalyDetector, values : Array[Double]) -> Doublefn MultivariateAnomalyDetector::update(self : MultivariateAnomalyDetector, values : Array[Double]) -> Boolpub struct ObjectiveTracker {
objective : ObjectiveKind
count : Double
total : Double
last : Double
}fn ObjectiveTracker::observe(self : ObjectiveTracker, prediction : Double, label : Double, weight? : Double) -> Unitpub struct OnlineAR {
lags : Int
coefficients : Array[Double]
history : SequenceWindow
learning_rate : Double
observations : Int
squared_error : Double
}fn OnlineAutoregressive::new(lags : Int, learning_rate? : Double, l2? : Double) -> OnlineAutoregressivepub struct OnlineBaggingClassifier {
models : Array[AdagradLogisticRegression]
rng : DeterministicRng
observations : Int
}fn OnlineBaggingClassifier::member_predictions(self : OnlineBaggingClassifier, features : Array[Double]) -> Array[Double]fn OnlineBaggingClassifier::new(model_count : Int, dimension : Int, seed? : UInt64) -> OnlineBaggingClassifierfn OnlineBaggingClassifier::predict(self : OnlineBaggingClassifier, features : Array[Double]) -> Doublefn OnlineBaggingClassifier::update(self : OnlineBaggingClassifier, features : Array[Double], label : Double) -> Unitpub struct OnlineBatchScorer {
endpoint : LinearEndpoint
batcher : RequestBatcher
stats : ServingStats
}fn OnlineBatchScorer::new(weights : Array[Double], batch_size? : Int, version? : String) -> OnlineBatchScorerfn OnlineBatchScorer::submit(self : OnlineBatchScorer, request : PredictionRequest) -> Array[PredictionResponse]fn OnlineBernoulliNB::feature_probability(self : OnlineBernoulliNB, label : Int, index : Int) -> Doublefn OnlineBernoulliNB::log_scores(self : OnlineBernoulliNB, features : Array[Double]) -> Array[Double]fn OnlineBernoulliNB::predict_proba(self : OnlineBernoulliNB, features : Array[Double]) -> Array[Double]fn OnlineBernoulliNB::update(self : OnlineBernoulliNB, features : Array[Double], label : Int, weight? : Double) -> Boolpub struct OnlineDecisionStump {
feature : Int
threshold : Double
left_positive : Double
left_negative : Double
right_positive : Double
right_negative : Double
updates : Int
}fn OnlineDecisionStump::predict(self : OnlineDecisionStump, features : Array[Double], smoothing? : Double) -> Doublefn OnlineDecisionStump::update(self : OnlineDecisionStump, features : Array[Double], label : Double, weight? : Double) -> Unitpub struct OnlineEvaluationSession {
metrics : MetricsTracker
confusion : ConfusionMatrix
auc_tracker : AucTracker
calibration : CalibrationTracker
regression : RegressionMetrics
}fn OnlineEvaluationSession::observe_binary(self : OnlineEvaluationSession, probability : Double, label : Double) -> Unitfn OnlineEvaluationSession::observe_regression(self : OnlineEvaluationSession, prediction : Double, label : Double) -> Unitpub struct OnlineFeatureSelector {
moments : VectorMoments
target : RunningMoments
cross : Array[Double]
observations : Double
}fn OnlineFeatureSelector::update(self : OnlineFeatureSelector, features : Array[Double], target : Double) -> Unitpub struct OnlineGammaRegression {
weights : Array[Double]
learning_rate : Double
l2 : Double
steps : Int
}fn OnlineGammaRegression::loss(self : OnlineGammaRegression, features : Array[Double], value : Double) -> Doublefn OnlineGammaRegression::new(dimension : Int, learning_rate? : Double, l2? : Double) -> OnlineGammaRegressionfn OnlineGammaRegression::update(self : OnlineGammaRegression, features : Array[Double], value : Double) -> Unitpub struct OnlineGaussianNB {
classes : Array[GaussianClassStats]
class_counts : Array[Double]
smoothing : Double
steps : Int
}fn OnlineGaussianNB::predict_proba(self : OnlineGaussianNB, features : Array[Double]) -> Array[Double]fn OnlineGaussianNB::update(self : OnlineGaussianNB, features : Array[Double], label : Int, weight? : Double) -> Boolpub struct OnlineHuberRegression {
weights : Array[Double]
learning_rate : Double
delta : Double
l2 : Double
steps : Int
}fn OnlineHuberRegression::loss(self : OnlineHuberRegression, features : Array[Double], label : Double) -> Doublefn OnlineHuberRegression::new(dimension : Int, learning_rate? : Double, delta? : Double, l2? : Double) -> OnlineHuberRegressionfn OnlineHuberRegression::update(self : OnlineHuberRegression, features : Array[Double], label : Double) -> Unitfn OnlineIsotonicCalibrator::update(self : OnlineIsotonicCalibrator, score : Double, label : Double) -> Unitpub struct OnlineKernelClassifier {
kernel : KernelKind
budget : Int
supports : Array[KernelSupport]
learning_rate : Double
bias : Double
updates : Int
}fn OnlineKernelClassifier::loss(self : OnlineKernelClassifier, features : Array[Double], label : Double) -> Doublefn OnlineKernelClassifier::new(kernel? : KernelKind, budget? : Int, learning_rate? : Double) -> OnlineKernelClassifierfn OnlineKernelClassifier::predict(self : OnlineKernelClassifier, features : Array[Double]) -> Doublefn OnlineKernelClassifier::predict_label(self : OnlineKernelClassifier, features : Array[Double]) -> Doublefn OnlineKernelClassifier::update(self : OnlineKernelClassifier, features : Array[Double], label : Double) -> Boolfn OnlineMatrixFactorization::item_vector(self : OnlineMatrixFactorization, item : Int) -> Array[Double]?fn OnlineMatrixFactorization::new(users : Int, items : Int, rank : Int, learning_rate? : Double, regularization? : Double) -> OnlineMatrixFactorizationfn OnlineMatrixFactorization::predict(self : OnlineMatrixFactorization, user : Int, item : Int) -> Doublefn OnlineMatrixFactorization::update(self : OnlineMatrixFactorization, user : Int, item : Int, rating : Double) -> Boolfn OnlineMatrixFactorization::user_vector(self : OnlineMatrixFactorization, user : Int) -> Array[Double]?pub struct OnlineMedoid {
center : Array[Double]
count : Double
learning_rate : Double
cost : Double
}pub struct OnlinePlattScaler {
slope : Double
intercept : Double
learning_rate : Double
steps : Int
}pub struct OnlinePoissonRegression {
weights : Array[Double]
learning_rate : Double
l2 : Double
steps : Int
}fn OnlinePoissonRegression::loss(self : OnlinePoissonRegression, features : Array[Double], count : Double) -> Doublefn OnlinePoissonRegression::new(dimension : Int, learning_rate? : Double, l2? : Double) -> OnlinePoissonRegressionfn OnlinePoissonRegression::predict(self : OnlinePoissonRegression, features : Array[Double]) -> Doublefn OnlinePoissonRegression::rate(self : OnlinePoissonRegression, features : Array[Double]) -> Doublefn OnlinePoissonRegression::update(self : OnlinePoissonRegression, features : Array[Double], count : Double) -> Unitpub struct OnlineQuantileInterval {
lower : OnlineQuantileRegression
upper : OnlineQuantileRegression
observations : Int
}fn OnlineQuantileInterval::contains(self : OnlineQuantileInterval, features : Array[Double], label : Double) -> Boolfn OnlineQuantileInterval::new(dimension : Int, coverage? : Double, learning_rate? : Double) -> OnlineQuantileIntervalfn OnlineQuantileInterval::predict(self : OnlineQuantileInterval, features : Array[Double]) -> (Double, Double)fn OnlineQuantileInterval::update(self : OnlineQuantileInterval, features : Array[Double], label : Double) -> Unitpub struct OnlineQuantileRegression {
weights : Array[Double]
learning_rate : Double
quantile : Double
l2 : Double
steps : Int
}fn OnlineQuantileRegression::new(dimension : Int, quantile? : Double, learning_rate? : Double, l2? : Double) -> OnlineQuantileRegressionfn OnlineQuantileRegression::pinball_loss(self : OnlineQuantileRegression, features : Array[Double], label : Double) -> Doublefn OnlineQuantileRegression::predict(self : OnlineQuantileRegression, features : Array[Double]) -> Doublefn OnlineQuantileRegression::update(self : OnlineQuantileRegression, features : Array[Double], label : Double) -> Unitfn OnlineRidgeRegression::loss(self : OnlineRidgeRegression, features : Array[Double], label : Double) -> Doublefn OnlineRidgeRegression::new(dimension : Int, learning_rate? : Double, l2? : Double) -> OnlineRidgeRegressionfn OnlineRidgeRegression::residual(self : OnlineRidgeRegression, features : Array[Double], label : Double) -> Doublefn OnlineRidgeRegression::rmse(self : OnlineRidgeRegression, samples : Array[Array[Double]], labels : Array[Double]) -> Doublefn OnlineRidgeRegression::update(self : OnlineRidgeRegression, features : Array[Double], label : Double) -> Unitfn OnlineRidgeRegression::update_weighted(self : OnlineRidgeRegression, features : Array[Double], label : Double, sample_weight : Double) -> Unitfn OnlineSoftmaxRegression::accuracy_on(self : OnlineSoftmaxRegression, samples : Array[Array[Double]], labels : Array[Int]) -> Doublefn OnlineSoftmaxRegression::logits(self : OnlineSoftmaxRegression, features : Array[Double]) -> Array[Double]fn OnlineSoftmaxRegression::loss(self : OnlineSoftmaxRegression, features : Array[Double], label : Int) -> Doublefn OnlineSoftmaxRegression::new(classes : Int, dimension : Int, learning_rate? : Double, l2? : Double) -> OnlineSoftmaxRegressionfn OnlineSoftmaxRegression::predict_class(self : OnlineSoftmaxRegression, features : Array[Double]) -> Int?fn OnlineSoftmaxRegression::predict_proba(self : OnlineSoftmaxRegression, features : Array[Double]) -> Array[Double]fn OnlineSoftmaxRegression::predict_top_k(self : OnlineSoftmaxRegression, features : Array[Double], k : Int) -> Array[Int]fn OnlineSoftmaxRegression::top_k_accuracy(self : OnlineSoftmaxRegression, samples : Array[Array[Double]], labels : Array[Int], k : Int) -> Doublefn OnlineSoftmaxRegression::update(self : OnlineSoftmaxRegression, features : Array[Double], label : Int) -> Boolfn OnlineSoftmaxRegression::update_weighted(self : OnlineSoftmaxRegression, features : Array[Double], label : Int, weight : Double) -> Boolpub struct OnlineStumpEnsemble {
stumps : Array[OnlineDecisionStump]
rng : DeterministicRng
updates : Int
}fn OnlineStumpEnsemble::new(stump_count : Int, dimension : Int, seed? : UInt64) -> OnlineStumpEnsemblefn OnlineStumpEnsemble::predict_label(self : OnlineStumpEnsemble, features : Array[Double], threshold? : Double) -> Doublefn OnlineStumpEnsemble::update(self : OnlineStumpEnsemble, features : Array[Double], label : Double, weight? : Double) -> Unitpub struct OptimizerStatistics {
steps : Int
gradient_l1 : Double
gradient_l2 : Double
update_l2 : Double
}fn OptimizerStatistics::record(self : OptimizerStatistics, gradient : Array[Double], update : Array[Double]) -> Unitpub struct PageHinkleyDetector {
threshold : Double
delta : Double
mean : Double
cumulative : Double
minimum : Double
count : Double
}pub struct PairwiseRanker {
weights : Array[Double]
learning_rate : Double
margin : Double
l2 : Double
updates : Int
}fn PairwiseRanker::compare(self : PairwiseRanker, left : Array[Double], right : Array[Double]) -> Doublefn PairwiseRanker::loss(self : PairwiseRanker, positive : Array[Double], negative : Array[Double]) -> Doublefn PairwiseRanker::new(dimension : Int, learning_rate? : Double, margin? : Double, l2? : Double) -> PairwiseRankerfn PairwiseRanker::update(self : PairwiseRanker, positive : Array[Double], negative : Array[Double]) -> Boolpub struct PassiveAggressiveRegressor {
weights : Array[Double]
aggressiveness : Double
epsilon : Double
l2 : Double
updates : Int
}fn PassiveAggressiveRegressor::new(dimension : Int, aggressiveness? : Double, epsilon? : Double, l2? : Double) -> PassiveAggressiveRegressorfn PassiveAggressiveRegressor::predict(self : PassiveAggressiveRegressor, features : Array[Double]) -> Doublefn PassiveAggressiveRegressor::update(self : PassiveAggressiveRegressor, features : Array[Double], label : Double) -> Boolpub struct PredictionGuard {
lower : Double
upper : Double
repaired : Int
}pub struct PredictionRequest {
request_id : String
features : Array[Double]
timestamp : Int64
group : String
}fn PredictionRequest::new(request_id : String, features : Array[Double], timestamp : Int64, group? : String) -> PredictionRequestpub struct PredictionResponse {
request_id : String
prediction : Double
probability : Double
model_version : String
latency_ms : Double
accepted : Bool
}fn PredictionResponse::new(request_id : String, prediction : Double, model_version : String, latency_ms? : Double, accepted? : Bool) -> PredictionResponsepub struct PrivacyBudget {
total : Double
remaining_budget : Double
queries : Int
rejected : Int
}pub struct PromotionGate {
minimum_auc : Double
maximum_log_loss : Double
minimum_samples : Int
}fn PromotionGate::new(minimum_auc? : Double, maximum_log_loss? : Double, minimum_samples? : Int) -> PromotionGatepub struct QualityGate {
dimension : Int
min_weight : Double
max_weight : Double
allow_nan_like : Bool
}fn QualityGate::validate_sample(self : QualityGate, features : Array[Double], weight : Double) -> ValidationReportpub struct RMSPropOptimizer {
learning_rate : Double
decay : Double
epsilon : Double
mean_square : Array[Double]
clipper : GradientClipper
step_count : Int
}fn RMSPropOptimizer::apply(self : RMSPropOptimizer, parameters : Array[Double], gradients : Array[Double]) -> Unitfn RMSPropOptimizer::new(dimension : Int, learning_rate? : Double, decay? : Double, epsilon? : Double, clipper? : GradientClipper) -> RMSPropOptimizerpub struct RandomFourierFeatures {
input_dimension : Int
output_dimension : Int
weights : Array[Array[Double]]
phases : Array[Double]
scale : Double
rng : DeterministicRng
}fn RandomFourierFeatures::new(input_dimension : Int, output_dimension : Int, width? : Double, seed? : UInt64) -> RandomFourierFeaturesfn RandomFourierFeatures::transform(self : RandomFourierFeatures, features : Array[Double]) -> Array[Double]pub struct RankingMetrics {
queries : Double
reciprocal_rank : Double
ndcg_sum : Double
hits : Array[Double]
}pub struct RateLimiter {
limit : Int
period : Int
ticks : Int
accepted : Int
}pub struct RegressionMetrics {
count : Double
absolute_error : Double
squared_error : Double
label_sum : Double
label_squared_sum : Double
minimum_error : Double
maximum_error : Double
}fn RegressionMetrics::update(self : RegressionMetrics, prediction : Double, label : Double, weight? : Double) -> Unitpub struct Regularizer {
l1 : Double
l2 : Double
}pub struct ReproducibilityManifest {
model : String
version : String
source_checksum : String
data_checksum : String
seed : Int
parameters : Map[String, String]
}fn ReproducibilityManifest::new(model : String, version : String, source_checksum : String, data_checksum : String, seed : Int) -> ReproducibilityManifestfn ReproducibilityManifest::set(self : ReproducibilityManifest, key : String, value : String) -> Unitpub struct RequestBatcher {
capacity : Int
requests : Array[PredictionRequest]
flushed : Int
dropped : Int
}pub struct ReservoirSampler {
capacity : Int
values : Array[Double]
seen : Int
rng : DeterministicRng
}pub struct RollbackPolicy {
minimum_accuracy : Double
maximum_loss : Double
maximum_error_rate : Double
}fn RollbackPolicy::new(minimum_accuracy? : Double, maximum_loss? : Double, maximum_error_rate? : Double) -> RollbackPolicyfn RollbackPolicy::should_rollback(self : RollbackPolicy, accuracy : Double, loss : Double, error_rate : Double) -> Boolfn RollingWindow::push(self : RollingWindow, features : Array[Double], label : Double, weight? : Double) -> Boolpub struct RunningMean {
count : Double
mean : Double
}pub struct RunningMoments {
count : Double
mean : Double
m2 : Double
minimum : Double
maximum : Double
}fn SGDLogisticRegression::update(self : SGDLogisticRegression, features : Array[Double], label : Double) -> Unitpub struct SequenceFeatureBuilder {
lags : Int
include_delta : Bool
include_mean : Bool
include_variance : Bool
window : SequenceWindow
}fn SequenceFeatureBuilder::new(lags : Int, include_delta? : Bool, include_mean? : Bool, include_variance? : Bool) -> SequenceFeatureBuilderfn SequenceFeatureBuilder::transform(self : SequenceFeatureBuilder, value : Double) -> Array[Double]pub struct SequenceWindow {
capacity : Int
values : Array[Double]
total : Double
sum_squares : Double
}pub struct ServingStats {
requests : Int
successes : Int
failures : Int
total_latency : Double
max_latency : Double
bytes : Int
}fn ServingStats::observe(self : ServingStats, response : PredictionResponse, payload_bytes? : Int) -> Unitpub struct ShadowEvaluator {
primary_version : String
shadow_version : String
comparisons : Int
disagreements : Int
absolute_difference : Double
}fn ShadowEvaluator::observe(self : ShadowEvaluator, primary : Double, shadow : Double, tolerance? : Double) -> Boolfn SnapshotEnvelope::is_compatible(self : SnapshotEnvelope, schema : String, model : String) -> Boolfn SnapshotEnvelope::new(schema : String, model : String, version : String, payload : String, checksum : String) -> SnapshotEnvelopefn SparseAdagradClassifier::new(dimension : Int, learning_rate? : Double, epsilon? : Double, l2? : Double) -> SparseAdagradClassifierfn SparseAdagradClassifier::predict(self : SparseAdagradClassifier, features : SparseVector) -> Doublefn SparseAdagradClassifier::update(self : SparseAdagradClassifier, features : SparseVector, label : Double) -> Unitfn SparseFTRL::new(dimension : Int, alpha? : Double, beta? : Double, l1? : Double, l2? : Double) -> SparseFTRLpub struct SparseVector {
dimension : Int
entries : Array[SparseEntry]
} derive(ToJson, Debug, FromJson)fn Standardizer::update_and_transform(self : Standardizer, features : Array[Double]) -> Array[Double]pub struct StratifiedSampler {
capacity_per_class : Int
samples : Map[Int, Array[Array[Double]]]
seen : Int
rng : DeterministicRng
}fn StratifiedSampler::observe(self : StratifiedSampler, label : Int, features : Array[Double]) -> Boolpub struct StreamCounters {
rows : Int
accepted : Int
rejected : Int
positive : Int
negative : Int
}pub struct StreamWatermark {
current : Int64
allowed_lateness : Int64
late_events : Int
}pub struct TargetEncoder {
sums : Map[String, Double]
counts : Map[String, Double]
prior : RunningMean
smoothing : Double
}fn TargetEncoder::update(self : TargetEncoder, category : String, target : Double, weight? : Double) -> Unitpub struct ThresholdOptimizer {
costs : ClassCost
minimum : Double
maximum : Double
steps : Int
best_threshold : Double
best_cost : Double
}fn ThresholdOptimizer::fit(self : ThresholdOptimizer, predictions : Array[Double], labels : Array[Double]) -> Doublefn ThresholdOptimizer::new(costs? : ClassCost, minimum? : Double, maximum? : Double, steps? : Int) -> ThresholdOptimizerpub struct TimeWindowAggregate {
start : Int64
end : Int64
events : Int
positives : Double
weight : Double
loss : RegressionMetrics
}fn TimeWindowAggregate::observe(self : TimeWindowAggregate, event : TrainingEvent, prediction : Double) -> Boolfn TrainingEvent::new(id : String, timestamp : Int64, features : Array[Double], label : Double, weight? : Double) -> TrainingEventfn WeightedProbabilityEnsemble::normalized_weights(self : WeightedProbabilityEnsemble) -> Array[Double]fn WeightedProbabilityEnsemble::predict(self : WeightedProbabilityEnsemble, predictions : Array[Double]) -> Doublefn WeightedProbabilityEnsemble::update(self : WeightedProbabilityEnsemble, predictions : Array[Double], label : Double, learning_rate? : Double) -> Unitfn expected_binary_cost(probability : Double, positive_cost : Double, negative_cost : Double) -> Doublefn explain_linear(weights : Array[Double], features : Array[Double], top_k? : Int) -> Array[FeatureAttribution]fn explain_sparse(weights : SparseVector, features : SparseVector, top_k? : Int) -> Array[FeatureAttribution]fn loss_gradient(kind : LossKind, prediction : Double, label : Double, parameter? : Double) -> Doublefn moving_average(previous : Double, value : Double, smoothing : Double) -> Doublefn train_adagrad(model : AdagradLogisticRegression, batch : DataBatch, report : TrainingReport) -> TrainingReportfn train_ridge(model : OnlineRidgeRegression, batch : DataBatch, report : TrainingReport) -> TrainingReportA native MoonBit toolkit for online learning, sparse and dense models, streaming features, evaluation, monitoring, serving, and reproducible model lifecycle workflows.