training — Return training-set masks from a cvpartition object.

training(c) returns a logical training mask for single-test-set partitions. training(c,i) returns masks for selected K-fold, leaveout, or custom test sets.

Syntax

mask = training(c)
mask = training(c, i)

Inputs

NameTypeRequiredDefaultDescription
cAnyYescvpartition object.
iAnyNoOne-based test-set index, vector of indices, or 'all'.

Returns

NameTypeDescription
maskLogicalArrayLogical observation mask for one or more test sets.

Errors

IdentifierWhenMessage
RunMat:cvpartition:InvalidArgumentInputs, partition kinds, dimensions, indices, or name-value options are malformed.cvpartition: invalid argument
RunMat:cvpartition:InternalRunMat cannot allocate or construct a partition output.cvpartition: internal error

How training works

  • training(c) works for holdout, resubstitution, and custom partitions with one test-set column.
  • training(c,i) accepts a one-based numeric scalar or vector of test-set indices.
  • training(c,'all') returns one logical mask column per test set.
  • For every returned column, training observations are the complement of that column's test mask.

Example

Get training masks for every fold

c = cvpartition(6, 'KFold', 3);
idx = training(c, 'all')

Expected output:

`idx` is a 6-by-3 logical matrix.

Using training with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how training changes the result.

Run a small training example, explain the result, then change one input and compare the output.

FAQ

Why does training(c) error for K-fold partitions?

K-fold partitions have multiple test sets, so specify a fold index or use 'all'.

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how training is executed, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.