kernel-svm

Deterministic kernel SVM training and evaluation toolkit for MoonBit

svm
machine-learning
classification
kernel
smo
moon add Yuxiao-Bot/kernel-svm@0.1.0
Download zip
Version
0.1.0
License
Apache-2.0
Last updated
12 days ago
Downloads
3
README

#Yuxiao-Bot/kernel-svm

MoonBit deterministic kernel SVM classification, evaluation, diagnostics, and reporting toolkit.

See README.md for installation, examples, scope, and verification.

#
BinaryConfig

pub struct BinaryConfig {
penalty_c : Double
selected_kernel : Kernel
iteration_limit : Int
unchanged_pass_limit : Int
kkt_tolerance : Double
alpha_change_epsilon : Double
} derive(Eq,
Debug
)

Controls deterministic binary C-SVC optimization.

#
BinaryConfig::alpha_epsilon

fn BinaryConfig::alpha_epsilon(self : BinaryConfig) -> Double

#
BinaryConfig::c

fn BinaryConfig::c(self : BinaryConfig) -> Double

#
BinaryConfig::kernel

fn BinaryConfig::kernel(self : BinaryConfig) -> Kernel

#
BinaryConfig::max_iterations

fn BinaryConfig::max_iterations(self : BinaryConfig) -> Int

#
BinaryConfig::max_passes

fn BinaryConfig::max_passes(self : BinaryConfig) -> Int

#
BinaryConfig::tolerance

fn BinaryConfig::tolerance(self : BinaryConfig) -> Double

#
BinaryModel

pub struct BinaryModel {
support_rows : Array[Array[Double]]
support_class_labels : Array[Int]
support_alpha_values : Array[Double]
signed_coefficients : Array[Double]
bias_value : Double
input_columns : Int
model_kernel : Kernel
lower_class : Int
upper_class : Int
convergence_data : ConvergenceReport
} derive(Eq,
Debug
)

Stores the support-vector representation of a fitted binary C-SVC model.

#
BinaryModel::bias

fn BinaryModel::bias(self : BinaryModel) -> Double

#
BinaryModel::convergence

fn BinaryModel::convergence(self : BinaryModel) -> ConvergenceReport

#
BinaryModel::decision_value

fn BinaryModel::decision_value(self : BinaryModel, row : Array[Double]) -> Result[Double, SvmError]

Returns the signed decision value; positive values select the higher class.

#
BinaryModel::feature_count

fn BinaryModel::feature_count(self : BinaryModel) -> Int

#
BinaryModel::kernel

fn BinaryModel::kernel(self : BinaryModel) -> Kernel

#
BinaryModel::negative_class

fn BinaryModel::negative_class(self : BinaryModel) -> Int

#
BinaryModel::positive_class

fn BinaryModel::positive_class(self : BinaryModel) -> Int

#
BinaryModel::predict

fn BinaryModel::predict(self : BinaryModel, row : Array[Double]) -> Result[Int, SvmError]

#
BinaryModel::predict_batch

fn BinaryModel::predict_batch(self : BinaryModel, rows : Array[Array[Double]]) -> Result[Array[Int], SvmError]

#
BinaryModel::support_alphas

fn BinaryModel::support_alphas(self : BinaryModel) -> Array[Double]

#
BinaryModel::support_labels

fn BinaryModel::support_labels(self : BinaryModel) -> Array[Int]

#
BinaryModel::support_vector_count

fn BinaryModel::support_vector_count(self : BinaryModel) -> Int

#
BinaryModel::support_vectors

fn BinaryModel::support_vectors(self : BinaryModel) -> Array[Array[Double]]

#
BinaryModelDiagnostics

pub struct BinaryModelDiagnostics {
retained_count : Int
lower_class_count : Int
upper_class_count : Int
smallest_alpha : Double
largest_alpha : Double
average_alpha : Double
} derive(Eq,
Debug
)

Summarizes the retained support vectors of a binary model.

#
BinaryModelDiagnostics::maximum_alpha

fn BinaryModelDiagnostics::maximum_alpha(self : BinaryModelDiagnostics) -> Double

#
BinaryModelDiagnostics::mean_alpha

fn BinaryModelDiagnostics::mean_alpha(self : BinaryModelDiagnostics) -> Double

#
BinaryModelDiagnostics::minimum_alpha

fn BinaryModelDiagnostics::minimum_alpha(self : BinaryModelDiagnostics) -> Double

#
BinaryModelDiagnostics::negative_support_vectors

fn BinaryModelDiagnostics::negative_support_vectors(self : BinaryModelDiagnostics) -> Int

#
BinaryModelDiagnostics::positive_support_vectors

fn BinaryModelDiagnostics::positive_support_vectors(self : BinaryModelDiagnostics) -> Int

#
BinaryModelDiagnostics::support_vectors

fn BinaryModelDiagnostics::support_vectors(self : BinaryModelDiagnostics) -> Int

#
BinaryPredictionExplanation

pub struct BinaryPredictionExplanation {
output_class : Int
signed_decision_value : Double
model_bias : Double
ordered_contributions : Array[SupportContribution]
} derive(Eq,
Debug
)

Explains a binary decision as bias plus support-vector contributions.

#
BinaryPredictionExplanation::bias

#
BinaryPredictionExplanation::contributions

#
BinaryPredictionExplanation::decision_value

fn BinaryPredictionExplanation::decision_value(self : BinaryPredictionExplanation) -> Double

#
BinaryPredictionExplanation::predicted_class

fn BinaryPredictionExplanation::predicted_class(self : BinaryPredictionExplanation) -> Int

#
BinaryThresholdAnalysis

pub struct BinaryThresholdAnalysis {
threshold_points : Array[ThresholdPoint]
observed_positive_count : Int
observed_negative_count : Int
roc_area : Double
average_precision_value : Double
} derive(Eq,
Debug
)

Stores deterministic ROC and precision-recall analysis.

#
BinaryThresholdAnalysis::average_precision

fn BinaryThresholdAnalysis::average_precision(self : BinaryThresholdAnalysis) -> Double

#
BinaryThresholdAnalysis::negative_count

fn BinaryThresholdAnalysis::negative_count(self : BinaryThresholdAnalysis) -> Int

#
BinaryThresholdAnalysis::points

#
BinaryThresholdAnalysis::positive_count

fn BinaryThresholdAnalysis::positive_count(self : BinaryThresholdAnalysis) -> Int

#
BinaryThresholdAnalysis::roc_auc

fn BinaryThresholdAnalysis::roc_auc(self : BinaryThresholdAnalysis) -> Double

#
CandidateEvaluation

pub struct CandidateEvaluation {
original_index : Int
evaluated_name : String
metric_score : Double
validation_report : ValidationReport
} derive(Eq,
Debug
)

Stores one successfully evaluated candidate.

#
CandidateEvaluation::index

fn CandidateEvaluation::index(self : CandidateEvaluation) -> Int

#
CandidateEvaluation::name

fn CandidateEvaluation::name(self : CandidateEvaluation) -> String

#
CandidateEvaluation::score

fn CandidateEvaluation::score(self : CandidateEvaluation) -> Double

#
CandidateEvaluation::validation

#
CandidateFailure

pub struct CandidateFailure {
original_index : Int
failed_name : String
failure_error : SvmError
} derive(Eq,
Debug
)

Stores one candidate's typed evaluation failure.

#
CandidateFailure::error

#
CandidateFailure::index

fn CandidateFailure::index(self : CandidateFailure) -> Int

#
CandidateFailure::name

fn CandidateFailure::name(self : CandidateFailure) -> String

#
ClassMetric

pub struct ClassMetric {
class_label : Int
true_positive_count : Int
false_positive_count : Int
false_negative_count : Int
class_support : Int
precision_value : Double
recall_value : Double
f1_value : Double
} derive(Eq,
Debug
)

Stores one class's confusion-derived rates.

#
ClassMetric::f1

fn ClassMetric::f1(self : ClassMetric) -> Double

#
ClassMetric::false_negatives

fn ClassMetric::false_negatives(self : ClassMetric) -> Int

#
ClassMetric::false_positives

fn ClassMetric::false_positives(self : ClassMetric) -> Int

#
ClassMetric::label

fn ClassMetric::label(self : ClassMetric) -> Int

#
ClassMetric::precision

fn ClassMetric::precision(self : ClassMetric) -> Double

#
ClassMetric::recall

fn ClassMetric::recall(self : ClassMetric) -> Double

#
ClassMetric::support

fn ClassMetric::support(self : ClassMetric) -> Int

#
ClassMetric::true_positives

fn ClassMetric::true_positives(self : ClassMetric) -> Int

#
ClassProfile

pub struct ClassProfile {
class_label : Int
observation_count : Int
observation_proportion : Double
} derive(Eq,
Debug
)

Records one sorted class label's frequency.

#
ClassProfile::count

fn ClassProfile::count(self : ClassProfile) -> Int

#
ClassProfile::label

fn ClassProfile::label(self : ClassProfile) -> Int

#
ClassProfile::proportion

fn ClassProfile::proportion(self : ClassProfile) -> Double

#
ClassScoreProfile

pub struct ClassScoreProfile {
profiled_class : Int
positive_observations : Int
negative_observations : Int
positive_score_minimum : Double
positive_score_maximum : Double
positive_score_mean : Double
negative_score_minimum : Double
negative_score_maximum : Double
negative_score_mean : Double
mean_score_separation : Double
} derive(Eq,
Debug
)

Summarizes one OvR classifier's scores on positive and negative rows.

#
ClassScoreProfile::class_label

fn ClassScoreProfile::class_label(self : ClassScoreProfile) -> Int

#
ClassScoreProfile::maximum_negative_score

fn ClassScoreProfile::maximum_negative_score(self : ClassScoreProfile) -> Double

#
ClassScoreProfile::maximum_positive_score

fn ClassScoreProfile::maximum_positive_score(self : ClassScoreProfile) -> Double

#
ClassScoreProfile::minimum_negative_score

fn ClassScoreProfile::minimum_negative_score(self : ClassScoreProfile) -> Double

#
ClassScoreProfile::minimum_positive_score

fn ClassScoreProfile::minimum_positive_score(self : ClassScoreProfile) -> Double

#
ClassScoreProfile::negative_count

fn ClassScoreProfile::negative_count(self : ClassScoreProfile) -> Int

#
ClassScoreProfile::negative_mean_score

fn ClassScoreProfile::negative_mean_score(self : ClassScoreProfile) -> Double

#
ClassScoreProfile::positive_count

fn ClassScoreProfile::positive_count(self : ClassScoreProfile) -> Int

#
ClassScoreProfile::positive_mean_score

fn ClassScoreProfile::positive_mean_score(self : ClassScoreProfile) -> Double

#
ClassScoreProfile::score_separation

fn ClassScoreProfile::score_separation(self : ClassScoreProfile) -> Double

#
ClassWeight

pub struct ClassWeight {
weighted_label : Int
weight_value : Double
} derive(Eq,
Debug
)

Associates a positive multiplier with one integer class label.

#
ClassWeight::label

fn ClassWeight::label(self : ClassWeight) -> Int

#
ClassWeight::value

fn ClassWeight::value(self : ClassWeight) -> Double

#
ClassificationMetrics

pub struct ClassificationMetrics {
ordered_classes : Array[Int]
confusion_counts : Array[Array[Int]]
class_metrics : Array[ClassMetric]
total_observations : Int
accuracy_value : Double
error_rate_value : Double
balanced_accuracy_value : Double
macro_precision_value : Double
macro_recall_value : Double
macro_f1_value : Double
micro_precision_value : Double
micro_recall_value : Double
micro_f1_value : Double
weighted_precision_value : Double
weighted_recall_value : Double
weighted_f1_value : Double
} derive(Eq,
Debug
)

Stores deterministic multiclass classification metrics.

#
ClassificationMetrics::accuracy

fn ClassificationMetrics::accuracy(self : ClassificationMetrics) -> Double

#
ClassificationMetrics::balanced_accuracy

fn ClassificationMetrics::balanced_accuracy(self : ClassificationMetrics) -> Double

#
ClassificationMetrics::classes

#
ClassificationMetrics::confusion_matrix

fn ClassificationMetrics::confusion_matrix(self : ClassificationMetrics) -> Array[Array[Int]]

#
ClassificationMetrics::error_rate

fn ClassificationMetrics::error_rate(self : ClassificationMetrics) -> Double

#
ClassificationMetrics::macro_f1

fn ClassificationMetrics::macro_f1(self : ClassificationMetrics) -> Double

#
ClassificationMetrics::macro_precision

fn ClassificationMetrics::macro_precision(self : ClassificationMetrics) -> Double

#
ClassificationMetrics::macro_recall

fn ClassificationMetrics::macro_recall(self : ClassificationMetrics) -> Double

#
ClassificationMetrics::micro_f1

fn ClassificationMetrics::micro_f1(self : ClassificationMetrics) -> Double

#
ClassificationMetrics::micro_precision

fn ClassificationMetrics::micro_precision(self : ClassificationMetrics) -> Double

#
ClassificationMetrics::micro_recall

fn ClassificationMetrics::micro_recall(self : ClassificationMetrics) -> Double

#
ClassificationMetrics::observation_count

fn ClassificationMetrics::observation_count(self : ClassificationMetrics) -> Int

#
ClassificationMetrics::per_class

#
ClassificationMetrics::weighted_f1

fn ClassificationMetrics::weighted_f1(self : ClassificationMetrics) -> Double

#
ClassificationMetrics::weighted_precision

fn ClassificationMetrics::weighted_precision(self : ClassificationMetrics) -> Double

#
ClassificationMetrics::weighted_recall

fn ClassificationMetrics::weighted_recall(self : ClassificationMetrics) -> Double

#
ConvergenceReport

pub struct ConvergenceReport {
completed_iterations : Int
completed_pair_updates : Int
retained_support_vectors : Int
largest_kkt_violation : Double
final_dual_objective : Double
reached_stopping_condition : Bool
} derive(Eq,
Debug
)

Records directly computed optimization evidence for a fitted binary model.

#
ConvergenceReport::converged

fn ConvergenceReport::converged(self : ConvergenceReport) -> Bool

#
ConvergenceReport::dual_objective

fn ConvergenceReport::dual_objective(self : ConvergenceReport) -> Double

#
ConvergenceReport::iterations

fn ConvergenceReport::iterations(self : ConvergenceReport) -> Int

#
ConvergenceReport::max_kkt_violation

fn ConvergenceReport::max_kkt_violation(self : ConvergenceReport) -> Double

#
ConvergenceReport::pair_updates

fn ConvergenceReport::pair_updates(self : ConvergenceReport) -> Int

#
ConvergenceReport::support_vectors

fn ConvergenceReport::support_vectors(self : ConvergenceReport) -> Int

#
Dataset

pub struct Dataset {
feature_rows : Array[Array[Double]]
class_labels : Array[Int]
dataset_name : String
column_count : Int
sorted_classes : Array[Int]
} derive(Eq,
Debug
)

Stores a validated dense numeric matrix and its integer class labels.

#
Dataset::class_count

fn Dataset::class_count(self : Dataset, label : Int) -> Int

#
Dataset::classes

fn Dataset::classes(self : Dataset) -> Array[Int]

#
Dataset::feature_count

fn Dataset::feature_count(self : Dataset) -> Int

#
Dataset::features

fn Dataset::features(self : Dataset) -> Array[Array[Double]]

#
Dataset::labels

fn Dataset::labels(self : Dataset) -> Array[Int]

#
Dataset::name

fn Dataset::name(self : Dataset) -> String

#
Dataset::row

fn Dataset::row(self : Dataset, index : Int) -> Result[Array[Double], SvmError]

#
Dataset::row_count

fn Dataset::row_count(self : Dataset) -> Int

#
Dataset::subset

fn Dataset::subset(self : Dataset, indices : Array[Int], name : String) -> Result[Dataset, SvmError]

Selects unique rows in caller-provided order and gives the result a new name.

#
DatasetProfile

pub struct DatasetProfile {
source_name : String
source_row_count : Int
source_feature_count : Int
source_class_count : Int
feature_profiles : Array[FeatureProfile]
class_profiles : Array[ClassProfile]
feature_centroid : Array[Double]
smallest_squared_row_norm : Double
largest_squared_row_norm : Double
average_squared_row_norm : Double
} derive(Eq,
Debug
)

Stores deterministic descriptive evidence for a validated dataset.

#
DatasetProfile::centroid

fn DatasetProfile::centroid(self : DatasetProfile) -> Array[Double]

#
DatasetProfile::class_count

fn DatasetProfile::class_count(self : DatasetProfile) -> Int

#
DatasetProfile::classes

#
DatasetProfile::feature_count

fn DatasetProfile::feature_count(self : DatasetProfile) -> Int

#
DatasetProfile::features

#
DatasetProfile::maximum_squared_norm

fn DatasetProfile::maximum_squared_norm(self : DatasetProfile) -> Double

#
DatasetProfile::mean_squared_norm

fn DatasetProfile::mean_squared_norm(self : DatasetProfile) -> Double

#
DatasetProfile::minimum_squared_norm

fn DatasetProfile::minimum_squared_norm(self : DatasetProfile) -> Double

#
DatasetProfile::name

fn DatasetProfile::name(self : DatasetProfile) -> String

#
DatasetProfile::row_count

fn DatasetProfile::row_count(self : DatasetProfile) -> Int

#
FeatureImportance

pub struct FeatureImportance {
source_feature_index : Int
unpermuted_accuracy : Double
permuted_accuracy_value : Double
measured_accuracy_drop : Double
} derive(Eq,
Debug
)

Records the accuracy change after deterministically permuting one feature.

#
FeatureImportance::accuracy_drop

fn FeatureImportance::accuracy_drop(self : FeatureImportance) -> Double

#
FeatureImportance::baseline_accuracy

fn FeatureImportance::baseline_accuracy(self : FeatureImportance) -> Double

#
FeatureImportance::feature_index

fn FeatureImportance::feature_index(self : FeatureImportance) -> Int

#
FeatureImportance::permuted_accuracy

fn FeatureImportance::permuted_accuracy(self : FeatureImportance) -> Double

#
FeatureProfile

pub struct FeatureProfile {
source_column : Int
minimum_value : Double
maximum_value : Double
arithmetic_mean : Double
population_variance : Double
population_standard_deviation : Double
constant_column : Bool
} derive(Eq,
Debug
)

Summarizes one dense feature column using population variance.

#
FeatureProfile::feature_index

fn FeatureProfile::feature_index(self : FeatureProfile) -> Int

#
FeatureProfile::is_constant

fn FeatureProfile::is_constant(self : FeatureProfile) -> Bool

#
FeatureProfile::maximum

fn FeatureProfile::maximum(self : FeatureProfile) -> Double

#
FeatureProfile::mean

fn FeatureProfile::mean(self : FeatureProfile) -> Double

#
FeatureProfile::minimum

fn FeatureProfile::minimum(self : FeatureProfile) -> Double

#
FeatureProfile::standard_deviation

fn FeatureProfile::standard_deviation(self : FeatureProfile) -> Double

#
FeatureProfile::variance

fn FeatureProfile::variance(self : FeatureProfile) -> Double

#
FeatureScaler

pub struct FeatureScaler {
scaler_kind : ScalerKind
offset_values : Array[Double]
scale_values : Array[Double]
constant_columns : Array[Bool]
input_columns : Int
} derive(Eq,
Debug
)

Stores immutable per-feature parameters for reversible scaling.

#
FeatureScaler::feature_count

fn FeatureScaler::feature_count(self : FeatureScaler) -> Int

#
FeatureScaler::inverse_row

fn FeatureScaler::inverse_row(self : FeatureScaler, row : Array[Double]) -> Result[Array[Double], SvmError]

#
FeatureScaler::kind

#
FeatureScaler::offsets

fn FeatureScaler::offsets(self : FeatureScaler) -> Array[Double]

#
FeatureScaler::scales

fn FeatureScaler::scales(self : FeatureScaler) -> Array[Double]

#
FeatureScaler::transform_dataset

fn FeatureScaler::transform_dataset(self : FeatureScaler, data : Dataset, name : String) -> Result[Dataset, SvmError]

Applies fitted parameters to every row while preserving class labels.

#
FeatureScaler::transform_row

fn FeatureScaler::transform_row(self : FeatureScaler, row : Array[Double]) -> Result[Array[Double], SvmError]

#
FoldEvaluation

pub struct FoldEvaluation {
fold_number : Int
training_rows : Array[Int]
testing_rows : Array[Int]
actual_labels : Array[Int]
predicted_labels : Array[Int]
fold_metrics : ClassificationMetrics
fitted_scaler : FeatureScaler?
} derive(Eq,
Debug
)

Stores complete evidence for one held-out fold.

#
FoldEvaluation::actual

fn FoldEvaluation::actual(self : FoldEvaluation) -> Array[Int]

#
FoldEvaluation::index

fn FoldEvaluation::index(self : FoldEvaluation) -> Int

#
FoldEvaluation::metrics

#
FoldEvaluation::predicted

fn FoldEvaluation::predicted(self : FoldEvaluation) -> Array[Int]

#
FoldEvaluation::scaler

#
FoldEvaluation::test_indices

fn FoldEvaluation::test_indices(self : FoldEvaluation) -> Array[Int]

#
FoldEvaluation::train_indices

fn FoldEvaluation::train_indices(self : FoldEvaluation) -> Array[Int]

#
Kernel

pub(all) enum Kernel {
Linear
Rbf(Double)
Polynomial(Double, Double, Int)
} derive(Eq,
Debug
)

Selects the similarity function used by SVM training and prediction.

#
Kernel::name

fn Kernel::name(self : Kernel) -> String

#
KernelDiagnostics

pub struct KernelDiagnostics {
matrix_entry_count : Int
smallest_entry : Double
largest_entry : Double
average_entry : Double
average_diagonal : Double
largest_symmetry_error : Double
} derive(Eq,
Debug
)

Summarizes the numeric range and symmetry of a kernel matrix.

#
KernelDiagnostics::diagonal_mean

fn KernelDiagnostics::diagonal_mean(self : KernelDiagnostics) -> Double

#
KernelDiagnostics::entry_count

fn KernelDiagnostics::entry_count(self : KernelDiagnostics) -> Int

#
KernelDiagnostics::maximum

fn KernelDiagnostics::maximum(self : KernelDiagnostics) -> Double

#
KernelDiagnostics::maximum_symmetry_error

fn KernelDiagnostics::maximum_symmetry_error(self : KernelDiagnostics) -> Double

#
KernelDiagnostics::mean

fn KernelDiagnostics::mean(self : KernelDiagnostics) -> Double

#
KernelDiagnostics::minimum

fn KernelDiagnostics::minimum(self : KernelDiagnostics) -> Double

#
MarginDiagnostics

pub struct MarginDiagnostics {
fitted_observation_count : Int
incorrect_count : Int
violating_count : Int
smallest_margin : Double
largest_margin : Double
average_margin : Double
} derive(Eq,
Debug
)

Summarizes signed training margins for a fitted binary model.

#
MarginDiagnostics::margin_violation_count

fn MarginDiagnostics::margin_violation_count(self : MarginDiagnostics) -> Int

#
MarginDiagnostics::maximum_margin

fn MarginDiagnostics::maximum_margin(self : MarginDiagnostics) -> Double

#
MarginDiagnostics::mean_margin

fn MarginDiagnostics::mean_margin(self : MarginDiagnostics) -> Double

#
MarginDiagnostics::minimum_margin

fn MarginDiagnostics::minimum_margin(self : MarginDiagnostics) -> Double

#
MarginDiagnostics::misclassified_count

fn MarginDiagnostics::misclassified_count(self : MarginDiagnostics) -> Int

#
MarginDiagnostics::observation_count

fn MarginDiagnostics::observation_count(self : MarginDiagnostics) -> Int

#
MulticlassModel

pub struct MulticlassModel {
ordered_classes : Array[Int]
class_models : Array[BinaryModel]
input_columns : Int
} derive(Eq,
Debug
)

Stores one binary model per sorted class for one-vs-rest prediction.

#
MulticlassModel::binary_models

fn MulticlassModel::binary_models(self : MulticlassModel) -> Array[BinaryModel]

#
MulticlassModel::classes

fn MulticlassModel::classes(self : MulticlassModel) -> Array[Int]

#
MulticlassModel::decision_values

fn MulticlassModel::decision_values(self : MulticlassModel, row : Array[Double]) -> Result[Array[Double], SvmError]

#
MulticlassModel::feature_count

fn MulticlassModel::feature_count(self : MulticlassModel) -> Int

#
MulticlassModel::model_count

fn MulticlassModel::model_count(self : MulticlassModel) -> Int

#
MulticlassModel::predict

fn MulticlassModel::predict(self : MulticlassModel, row : Array[Double]) -> Result[Int, SvmError]

Chooses the largest one-vs-rest score; exact ties retain sorted class order.

#
MulticlassModel::predict_batch

fn MulticlassModel::predict_batch(self : MulticlassModel, rows : Array[Array[Double]]) -> Result[Array[Int], SvmError]

#
MulticlassModelDiagnostics

pub struct MulticlassModelDiagnostics {
fitted_class_count : Int
retained_support_counts : Array[Int]
fitted_convergence_reports : Array[ConvergenceReport]
retained_support_total : Int
every_model_converged : Bool
} derive(Eq,
Debug
)

Aggregates support-vector and convergence evidence for an OvR model.

#
MulticlassModelDiagnostics::all_converged

fn MulticlassModelDiagnostics::all_converged(self : MulticlassModelDiagnostics) -> Bool

#
MulticlassModelDiagnostics::class_count

#
MulticlassModelDiagnostics::convergence_reports

#
MulticlassModelDiagnostics::support_counts

#
MulticlassModelDiagnostics::total_support_vectors

fn MulticlassModelDiagnostics::total_support_vectors(self : MulticlassModelDiagnostics) -> Int

#
MulticlassPredictionExplanation

pub struct MulticlassPredictionExplanation {
output_class : Int
ordered_classes : Array[Int]
ordered_scores : Array[Double]
} derive(Eq,
Debug
)

Explains an OvR prediction with class-aligned binary decision scores.

#
MulticlassPredictionExplanation::classes

#
MulticlassPredictionExplanation::predicted_class

#
MulticlassPredictionExplanation::scores

#
PermutationImportance

pub struct PermutationImportance {
original_accuracy : Double
ordered_importances : Array[FeatureImportance]
} derive(Eq,
Debug
)

Stores feature importances ordered by descending accuracy drop.

#
PermutationImportance::baseline_accuracy

fn PermutationImportance::baseline_accuracy(self : PermutationImportance) -> Double

#
PermutationImportance::feature_count

fn PermutationImportance::feature_count(self : PermutationImportance) -> Int

#
PermutationImportance::ranked_features

#
PredictionAudit

pub struct PredictionAudit {
audited_observations : Array[PredictionObservation]
audited_class_profiles : Array[ClassScoreProfile]
audit_metrics : ClassificationMetrics
correct_prediction_count : Int
incorrect_prediction_count : Int
smallest_winning_margin : Double
largest_winning_margin : Double
average_winning_margin : Double
} derive(Eq,
Debug
)

Aggregates row-level prediction evidence and class-score separation.

#
PredictionAudit::accuracy

fn PredictionAudit::accuracy(self : PredictionAudit) -> Double

#
PredictionAudit::class_score_profiles

fn PredictionAudit::class_score_profiles(self : PredictionAudit) -> Array[ClassScoreProfile]

#
PredictionAudit::correct_count

fn PredictionAudit::correct_count(self : PredictionAudit) -> Int

#
PredictionAudit::incorrect_count

fn PredictionAudit::incorrect_count(self : PredictionAudit) -> Int

#
PredictionAudit::maximum_winning_margin

fn PredictionAudit::maximum_winning_margin(self : PredictionAudit) -> Double

#
PredictionAudit::mean_winning_margin

fn PredictionAudit::mean_winning_margin(self : PredictionAudit) -> Double

#
PredictionAudit::metrics

#
PredictionAudit::minimum_winning_margin

fn PredictionAudit::minimum_winning_margin(self : PredictionAudit) -> Double

#
PredictionAudit::misclassified_observations

fn PredictionAudit::misclassified_observations(self : PredictionAudit) -> Array[PredictionObservation]

#
PredictionAudit::observation_count

fn PredictionAudit::observation_count(self : PredictionAudit) -> Int

#
PredictionAudit::observations

#
PredictionObservation

pub struct PredictionObservation {
source_row_index : Int
observed_class : Int
selected_class : Int
selected_score : Double
runner_up_class : Int
runner_up_score : Double
selected_margin : Double
ordered_scores : Array[Double]
prediction_correct : Bool
} derive(Eq,
Debug
)

Stores all evidence used for one multiclass prediction.

#
PredictionObservation::actual_class

fn PredictionObservation::actual_class(self : PredictionObservation) -> Int

#
PredictionObservation::is_correct

fn PredictionObservation::is_correct(self : PredictionObservation) -> Bool

#
PredictionObservation::predicted_class

fn PredictionObservation::predicted_class(self : PredictionObservation) -> Int

#
PredictionObservation::row_index

fn PredictionObservation::row_index(self : PredictionObservation) -> Int

#
PredictionObservation::scores

fn PredictionObservation::scores(self : PredictionObservation) -> Array[Double]

#
PredictionObservation::second_class

fn PredictionObservation::second_class(self : PredictionObservation) -> Int

#
PredictionObservation::second_score

fn PredictionObservation::second_score(self : PredictionObservation) -> Double

#
PredictionObservation::winning_margin

fn PredictionObservation::winning_margin(self : PredictionObservation) -> Double

#
PredictionObservation::winning_score

fn PredictionObservation::winning_score(self : PredictionObservation) -> Double

#
RepeatedValidationReport

pub struct RepeatedValidationReport {
round_reports : Array[ValidationReport]
folds_per_round : Int
accuracy_mean : Double
accuracy_minimum : Double
accuracy_maximum : Double
accuracy_deviation : Double
macro_f1_mean : Double
macro_f1_minimum : Double
macro_f1_maximum : Double
macro_f1_deviation : Double
} derive(Eq,
Debug
)

Aggregates reproducible metrics across several stratified CV rounds.

#
RepeatedValidationReport::accuracy_standard_deviation

fn RepeatedValidationReport::accuracy_standard_deviation(self : RepeatedValidationReport) -> Double

#
RepeatedValidationReport::fold_count

#
RepeatedValidationReport::macro_f1_standard_deviation

fn RepeatedValidationReport::macro_f1_standard_deviation(self : RepeatedValidationReport) -> Double

#
RepeatedValidationReport::maximum_accuracy

fn RepeatedValidationReport::maximum_accuracy(self : RepeatedValidationReport) -> Double

#
RepeatedValidationReport::maximum_macro_f1

fn RepeatedValidationReport::maximum_macro_f1(self : RepeatedValidationReport) -> Double

#
RepeatedValidationReport::mean_accuracy

fn RepeatedValidationReport::mean_accuracy(self : RepeatedValidationReport) -> Double

#
RepeatedValidationReport::mean_macro_f1

fn RepeatedValidationReport::mean_macro_f1(self : RepeatedValidationReport) -> Double

#
RepeatedValidationReport::minimum_accuracy

fn RepeatedValidationReport::minimum_accuracy(self : RepeatedValidationReport) -> Double

#
RepeatedValidationReport::minimum_macro_f1

fn RepeatedValidationReport::minimum_macro_f1(self : RepeatedValidationReport) -> Double

#
RepeatedValidationReport::repetition_count

fn RepeatedValidationReport::repetition_count(self : RepeatedValidationReport) -> Int

#
RepeatedValidationReport::reports

#
ScalerKind

pub(all) enum ScalerKind {
StandardScale
MinMaxScale(Double, Double)
} derive(Eq,
Debug
)

Selects feature preprocessing fitted only from training observations.

#
ScalingPlan

pub(all) enum ScalingPlan {
NoScaling
StandardScaling
MinMaxScaling(Double, Double)
} derive(Eq,
Debug
)

Selects fold-local feature preprocessing for validation.

#
SearchResult

pub struct SearchResult {
successful_candidates : Array[CandidateEvaluation]
failed_candidates : Array[CandidateFailure]
selected_original_index : Int
selected_name : String
selected_score : Double
selected_metric : SelectionMetric
selected_validation : ValidationReport
selected_model : MulticlassModel
selected_scaler : FeatureScaler?
} derive(Eq,
Debug
)

Stores candidate evidence and a full-data refit of the selected workflow.

#
SearchResult::best_index

fn SearchResult::best_index(self : SearchResult) -> Int

#
SearchResult::best_name

fn SearchResult::best_name(self : SearchResult) -> String

#
SearchResult::best_score

fn SearchResult::best_score(self : SearchResult) -> Double

#
SearchResult::candidates

#
SearchResult::failures

#
SearchResult::metric

#
SearchResult::model

#
SearchResult::predict

fn SearchResult::predict(self : SearchResult, row : Array[Double]) -> Result[Int, SvmError]

#
SearchResult::scaler

fn SearchResult::scaler(self : SearchResult) -> FeatureScaler?

#
SearchResult::validation

fn SearchResult::validation(self : SearchResult) -> ValidationReport

#
SelectionMetric

pub(all) enum SelectionMetric {
SelectAccuracy
SelectBalancedAccuracy
SelectMacroF1
SelectWeightedF1
} derive(Eq,
Debug
)

Selects the held-out metric maximized during candidate search.

#
StratifiedFold

pub struct StratifiedFold {
fold_index : Int
training_indices : Array[Int]
testing_indices : Array[Int]
} derive(Eq,
Debug
)

Stores one deterministic train/test index partition.

#
StratifiedFold::index

fn StratifiedFold::index(self : StratifiedFold) -> Int

#
StratifiedFold::test_indices

fn StratifiedFold::test_indices(self : StratifiedFold) -> Array[Int]

#
StratifiedFold::train_indices

fn StratifiedFold::train_indices(self : StratifiedFold) -> Array[Int]

#
SupportContribution

pub struct SupportContribution {
retained_index : Int
retained_row : Array[Double]
retained_label : Int
retained_alpha : Double
evaluated_kernel_value : Double
signed_decision_contribution : Double
} derive(Eq,
Debug
)

Records one support vector's signed contribution to a decision value.

#
SupportContribution::alpha

fn SupportContribution::alpha(self : SupportContribution) -> Double

#
SupportContribution::class_label

fn SupportContribution::class_label(self : SupportContribution) -> Int

#
SupportContribution::contribution

fn SupportContribution::contribution(self : SupportContribution) -> Double

#
SupportContribution::kernel_value

fn SupportContribution::kernel_value(self : SupportContribution) -> Double

#
SupportContribution::support_index

fn SupportContribution::support_index(self : SupportContribution) -> Int

#
SupportContribution::support_vector

fn SupportContribution::support_vector(self : SupportContribution) -> Array[Double]

#
SvmCandidate

pub struct SvmCandidate {
candidate_name : String
binary_configuration : BinaryConfig
candidate_scaling : ScalingPlan
} derive(Eq,
Debug
)

Names one explicit training and preprocessing candidate.

#
SvmCandidate::config

fn SvmCandidate::config(self : SvmCandidate) -> BinaryConfig

#
SvmCandidate::name

fn SvmCandidate::name(self : SvmCandidate) -> String

#
SvmCandidate::scaling

fn SvmCandidate::scaling(self : SvmCandidate) -> ScalingPlan

#
SvmError

pub(all) enum SvmError {
EmptyDataset
EmptyFeatureSet
RaggedRow(Int, Int, Int)
LabelLengthMismatch(Int, Int)
NonFiniteFeature(Int, Int)
SingleClassDataset
InvalidSubsetIndex(Int, Int)
DuplicateSubsetIndex(Int)
InvalidKernelParameter(String, Double)
KernelDimensionMismatch(Int, Int)
InvalidConfiguration(String, Double)
InvalidIterationCount(Int)
InvalidWeight(Int, Double)
WeightLengthMismatch(Int, Int)
InvalidClassWeight(Int, Double)
DuplicateClassWeight(Int)
ZeroEffectiveWeight
InvalidBinaryClassCount(Int)
PredictionDimensionMismatch(Int, Int)
TrainingDidNotConverge(Int)
NumericFailure(String)
InvalidFoldCount(Int)
InsufficientClassSamples(Int, Int, Int)
EmptyMetricInput
MetricLengthMismatch(Int, Int)
UnknownClassLabel(Int)
InvalidCandidateCount(Int)
NoValidCandidate
NonFiniteReportValue(String)
} derive(Eq,
Debug
)

Describes rejected data, invalid configurations, and failed SVM operations.

#
ThresholdPoint

pub struct ThresholdPoint {
score_threshold : Double
accepted_true_positives : Int
accepted_false_positives : Int
rejected_true_negatives : Int
rejected_false_negatives : Int
true_positive_rate_value : Double
false_positive_rate_value : Double
precision_value : Double
recall_value : Double
} derive(Eq,
Debug
)

Records binary confusion evidence after accepting scores at a threshold.

#
ThresholdPoint::false_negatives

fn ThresholdPoint::false_negatives(self : ThresholdPoint) -> Int

#
ThresholdPoint::false_positive_rate

fn ThresholdPoint::false_positive_rate(self : ThresholdPoint) -> Double

#
ThresholdPoint::false_positives

fn ThresholdPoint::false_positives(self : ThresholdPoint) -> Int

#
ThresholdPoint::precision

fn ThresholdPoint::precision(self : ThresholdPoint) -> Double

#
ThresholdPoint::recall

fn ThresholdPoint::recall(self : ThresholdPoint) -> Double

#
ThresholdPoint::threshold

fn ThresholdPoint::threshold(self : ThresholdPoint) -> Double

#
ThresholdPoint::true_negatives

fn ThresholdPoint::true_negatives(self : ThresholdPoint) -> Int

#
ThresholdPoint::true_positive_rate

fn ThresholdPoint::true_positive_rate(self : ThresholdPoint) -> Double

#
ThresholdPoint::true_positives

fn ThresholdPoint::true_positives(self : ThresholdPoint) -> Int

#
ValidationReport

pub struct ValidationReport {
fold_evaluations : Array[FoldEvaluation]
aggregate_metrics : ClassificationMetrics
evaluated_observations : Int
scaling_plan : ScalingPlan
} derive(Eq,
Debug
)

Stores all fold evidence and aggregate held-out metrics.

#
ValidationReport::fold_count

fn ValidationReport::fold_count(self : ValidationReport) -> Int

#
ValidationReport::folds

#
ValidationReport::metrics

#
ValidationReport::observation_count

fn ValidationReport::observation_count(self : ValidationReport) -> Int

#
ValidationReport::scaling

#
WeightProfile

pub struct WeightProfile {
weight_count : Int
minimum_weight : Double
maximum_weight : Double
total_weight : Double
average_weight : Double
effective_observation_count : Double
} derive(Eq,
Debug
)

Summarizes positive sample weights and their concentration.

#
WeightProfile::count

fn WeightProfile::count(self : WeightProfile) -> Int

#
WeightProfile::effective_sample_size

fn WeightProfile::effective_sample_size(self : WeightProfile) -> Double

#
WeightProfile::maximum

fn WeightProfile::maximum(self : WeightProfile) -> Double

#
WeightProfile::mean

fn WeightProfile::mean(self : WeightProfile) -> Double

#
WeightProfile::minimum

fn WeightProfile::minimum(self : WeightProfile) -> Double

#
WeightProfile::total

fn WeightProfile::total(self : WeightProfile) -> Double

#
binary_config

fn binary_config(c : Double, kernel : Kernel, max_iterations : Int, max_passes : Int, tolerance : Double, alpha_epsilon : Double) -> Result[BinaryConfig, SvmError]

Creates a fully explicit, validated binary SVM configuration.

#
binary_diagnostics_json

fn binary_diagnostics_json(diagnostics : BinaryModelDiagnostics, convergence : ConvergenceReport) -> String

Produces deterministic JSON for binary model diagnostics.

#
binary_diagnostics_text

fn binary_diagnostics_text(diagnostics : BinaryModelDiagnostics, convergence : ConvergenceReport) -> String

Produces stable binary support-vector and convergence evidence.

#
binary_model_diagnostics

fn binary_model_diagnostics(model : BinaryModel) -> BinaryModelDiagnostics

Summarizes alpha magnitudes and original-class support counts.

#
binary_permutation_importance

fn binary_permutation_importance(model : BinaryModel, data : Dataset) -> Result[PermutationImportance, SvmError]

Measures binary accuracy changes using a deterministic reverse permutation.

#
binary_threshold_analysis

fn binary_threshold_analysis(labels : Array[Int], scores : Array[Double], positive_class : Int) -> Result[BinaryThresholdAnalysis, SvmError]

Builds tied-threshold confusion evidence and deterministic curve areas.

#
class_weight

fn class_weight(label : Int, value : Double) -> Result[ClassWeight, SvmError]

#
classification_metrics

fn classification_metrics(actual : Array[Int], predicted : Array[Int]) -> Result[ClassificationMetrics, SvmError]

Computes a confusion matrix and common single-label classification metrics.

#
classification_metrics_json

fn classification_metrics_json(metrics : ClassificationMetrics) -> String

Produces deterministic JSON including confusion and per-class evidence.

#
classification_metrics_text

fn classification_metrics_text(metrics : ClassificationMetrics) -> String

Produces a stable human-readable classification report.

#
cross_validate

fn cross_validate(data : Dataset, config : BinaryConfig, fold_count : Int, scaling : ScalingPlan) -> Result[ValidationReport, SvmError]

Evaluates held-out predictions with preprocessing fitted inside each fold.

#
dataset

fn dataset(features : Array[Array[Double]], labels : Array[Int], name : String) -> Result[Dataset, SvmError]

Validates and defensively copies a dense numeric classification dataset.

#
dataset_profile

fn dataset_profile(data : Dataset) -> DatasetProfile

Computes reproducible descriptive statistics from validated dense data.

#
dataset_profile_json

fn dataset_profile_json(profile : DatasetProfile) -> String

Produces deterministic JSON for a dataset profile.

#
dataset_profile_text

fn dataset_profile_text(profile : DatasetProfile) -> String

Produces a stable line-oriented dataset audit report.

#
default_binary_config

fn default_binary_config(kernel : Kernel) -> Result[BinaryConfig, SvmError]

Returns C=1, 1000 iterations, 10 unchanged passes, and strict tolerances.

#
error_code

fn error_code(error : SvmError) -> String

Returns a stable machine-readable category for an error.

#
error_message

fn error_message(error : SvmError) -> String

Formats a concise explanation suitable for logs and command-line output.

#
explain_binary_prediction

fn explain_binary_prediction(model : BinaryModel, row : Array[Double]) -> Result[BinaryPredictionExplanation, SvmError]

Decomposes a checked binary prediction into support-vector contributions.

#
explain_multiclass_prediction

fn explain_multiclass_prediction(model : MulticlassModel, row : Array[Double]) -> Result[MulticlassPredictionExplanation, SvmError]

Returns class-aligned OvR scores and the deterministic winning class.

#
fit_scaler

fn fit_scaler(data : Dataset, kind : ScalerKind) -> Result[FeatureScaler, SvmError]

Fits preprocessing parameters from a validated training dataset.

#
kernel_diagnostics

fn kernel_diagnostics(data : Dataset, kernel : Kernel) -> Result[KernelDiagnostics, SvmError]

Computes finite summary statistics for the checked kernel matrix.

#
kernel_diagnostics_json

fn kernel_diagnostics_json(diagnostics : KernelDiagnostics) -> String

Produces deterministic JSON for kernel matrix diagnostics.

#
kernel_diagnostics_text

fn kernel_diagnostics_text(diagnostics : KernelDiagnostics) -> String

Produces stable range and symmetry evidence for a kernel matrix.

#
kernel_matrix

fn kernel_matrix(kernel : Kernel, data : Dataset) -> Result[Array[Array[Double]], SvmError]

Builds a symmetric kernel matrix for a validated dataset.

#
kernel_value

fn kernel_value(kernel : Kernel, left : Array[Double], right : Array[Double]) -> Result[Double, SvmError]

Evaluates a checked kernel on two finite vectors of equal length.

#
multiclass_diagnostics_json

fn multiclass_diagnostics_json(diagnostics : MulticlassModelDiagnostics) -> String

Produces deterministic JSON for every OvR convergence report.

#
multiclass_diagnostics_text

fn multiclass_diagnostics_text(diagnostics : MulticlassModelDiagnostics) -> String

Produces stable aggregate diagnostics for an OvR model.

#
multiclass_model_diagnostics

fn multiclass_model_diagnostics(model : MulticlassModel) -> MulticlassModelDiagnostics

Aggregates support counts and convergence reports in sorted class order.

#
multiclass_permutation_importance

fn multiclass_permutation_importance(model : MulticlassModel, data : Dataset) -> Result[PermutationImportance, SvmError]

Measures OvR accuracy changes using the same deterministic permutation.

#
multiclass_prediction_audit

fn multiclass_prediction_audit(model : MulticlassModel, data : Dataset) -> Result[PredictionAudit, SvmError]

Audits every OvR prediction and class score on a compatible dataset.

#
permutation_importance_json

fn permutation_importance_json(importance : PermutationImportance) -> String

Produces deterministic JSON for ranked feature importance.

#
permutation_importance_text

fn permutation_importance_text(importance : PermutationImportance) -> String

Produces a stable ranked permutation-importance report.

#
prediction_audit_json

fn prediction_audit_json(audit : PredictionAudit) -> String

Produces deterministic JSON for row-level prediction evidence.

#
prediction_audit_text

fn prediction_audit_text(audit : PredictionAudit) -> String

Produces a stable row-level prediction audit report.

#
repeated_cross_validate

fn repeated_cross_validate(data : Dataset, config : BinaryConfig, fold_count : Int, repetitions : Int, scaling : ScalingPlan) -> Result[RepeatedValidationReport, SvmError]

Repeats deterministic stratified CV with class-specific fold rotations.

#
repeated_validation_json

fn repeated_validation_json(report : RepeatedValidationReport) -> String

Produces deterministic JSON for repeated validation variability.

#
repeated_validation_text

fn repeated_validation_text(report : RepeatedValidationReport) -> String

Produces stable repeated-validation summary text.

#
select_svm

fn select_svm(data : Dataset, candidates : Array[SvmCandidate], fold_count : Int, metric : SelectionMetric) -> Result[SearchResult, SvmError]

Evaluates candidates in order and retains the earliest candidate on ties.

#
stratified_folds

fn stratified_folds(data : Dataset, fold_count : Int) -> Result[Array[StratifiedFold], SvmError]

Distributes each sorted class round-robin while retaining source row order.

#
svm_candidate

fn svm_candidate(name : String, config : BinaryConfig, scaling : ScalingPlan) -> SvmCandidate

#
threshold_analysis_json

fn threshold_analysis_json(analysis : BinaryThresholdAnalysis) -> String

Produces deterministic JSON for ROC and precision-recall points.

#
threshold_analysis_text

fn threshold_analysis_text(analysis : BinaryThresholdAnalysis) -> String

Produces a line-oriented threshold report with confusion evidence.

#
train_binary

fn train_binary(data : Dataset, config : BinaryConfig) -> Result[BinaryModel, SvmError]

Fits a deterministic, unweighted binary C-SVC model.

#
train_binary_weighted

fn train_binary_weighted(data : Dataset, sample_weights : Array[Double], class_weights : Array[ClassWeight], config : BinaryConfig) -> Result[BinaryModel, SvmError]

Fits binary C-SVC with positive sample and optional class multipliers.

#
train_multiclass

fn train_multiclass(data : Dataset, config : BinaryConfig) -> Result[MulticlassModel, SvmError]

Fits an unweighted deterministic one-vs-rest multiclass classifier.

#
train_multiclass_weighted

fn train_multiclass_weighted(data : Dataset, sample_weights : Array[Double], class_weights : Array[ClassWeight], config : BinaryConfig) -> Result[MulticlassModel, SvmError]

Fits one deterministic weighted binary classifier for each sorted class.

#
training_margin_diagnostics

fn training_margin_diagnostics(model : BinaryModel, data : Dataset) -> Result[MarginDiagnostics, SvmError]

Computes y*f(x) for observations belonging to the model's two classes.

#
validate_kernel

fn validate_kernel(kernel : Kernel) -> Result[Unit, SvmError]

Checks that all parameters define a finite, usable kernel.

#
weight_profile

fn weight_profile(weights : Array[Double]) -> Result[WeightProfile, SvmError]

Computes Kish's effective sample size for finite positive weights.

#
weight_profile_json

fn weight_profile_json(profile : WeightProfile) -> String

Produces deterministic JSON for positive sample-weight evidence.

#
weight_profile_text

fn weight_profile_text(profile : WeightProfile) -> String

Produces a stable summary of positive sample-weight concentration.