Skip to main content

load_problem

Function load_problem 

Source
pub fn load_problem(path: &Path) -> Result<SvmProblem, SvmError>
Expand description

Load an SVM problem from a file in LIBSVM sparse format.

Format: <label> <index1>:<value1> <index2>:<value2> ...

Uses LoadOptions::default — appropriate for untrusted input. For trusted bulk files exceeding the defaults, use load_problem_from_reader_with_options with a custom LoadOptions.

Validates:

  • total file size and per-line length,
  • embedded NUL byte absence,
  • parseable labels and feature values,
  • index:value token shape,
  • ascending feature indices,
  • LoadOptions::max_feature_index.

This loader does not validate statistical quality, feature normalization, or whether labels are appropriate for a particular SVM formulation. Malformed text input within the configured caps is returned as SvmError rather than panicking.

§Complexity

Linear in file size for parsing and O(n · d) memory where n is the number of instances and d is the average number of non-zero features per instance. No per-row allocation is driven by an untrusted header.