RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

RunMat™ is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

LicensePrivacy
/
See all docs
Builtin Reference
    • bayesopt
    • classify
    • confusionmat
    • crossvalind
    • cvpartition
    • fitclinear
    • fitctree
    • fitlm
    • kmeans
    • knnsearch
    • lasso
    • lassoglm
    • linkage
    • lscov
    • mnrfit
    • optimizableVariable
    • pdist
    • pdist2
    • perfcurve
    • predict
    • regress
    • ridge
    • squareform
    • test
    • training
    • tsne

fitctree — Fit a binary decision tree for multiclass classification.

fitctree fits a numeric-predictor classification tree from a predictor matrix or table and returns a ClassificationTree object usable with predict.

Syntax

Mdl = fitctree(Tbl, ResponseVarName)
Mdl = fitctree(Tbl, formula)
Mdl = fitctree(X, Y)
Mdl = fitctree(___, Name, Value)

Inputs

NameTypeRequiredDefaultDescription
tblOrXAnyYes—Input table or numeric predictor matrix.
yOrResponseAnyNo—Response vector, response variable name, or table formula.
optionsAnyVariadic—Name-value options such as ClassNames, PredictorNames, ResponseName, MaxNumSplits, MinLeafSize, MinParentSize, SplitCriterion, and Weights.

Returns

NameTypeDescription
MdlAnyClassificationTree object containing class names, split rules, and posterior probabilities.

Errors

IdentifierWhenMessage
RunMat:fitctree:InvalidArgumentInputs, response labels, dimensions, or name-value options are malformed or unsupported.fitctree: invalid argument
RunMat:fitctree:InternalRunMat cannot construct the ClassificationTree result.fitctree: internal error

How fitctree works

  • fitctree(X,Y) fits a classification tree with observations in rows of X and class labels in Y.
  • Table input supports fitctree(Tbl,ResponseVarName), fitctree(Tbl,formula), and fitctree(Tbl,Y). Formula support covers additive predictor lists such as Y ~ A + B.
  • Y can contain numeric, logical, string, char, cell-string, or any of the eight signed and unsigned integer label classes. Integer grouping identity and class are preserved exactly in ClassNames and prediction, including adjacent int64 or uint64 labels above flintmax.
  • Typed-integer matrix predictors and table numeric predictor variables are a compatibility-gated RunMat extension. Every value must be exactly representable in binary64 before statistical computation; inexact wide integers are rejected rather than rounded.
  • Typed-integer Weights and numeric name-value controls are a separate compatibility-gated RunMat extension and use the same exact binary64 boundary. MATLAB-compatible mode accepts the documented floating forms and rejects these integer extensions.
  • Name-value options ClassNames, PredictorNames, ResponseName, MaxNumSplits, MinLeafSize, MinParentSize, SplitCriterion, Weights, and ScoreTransform are accepted.
  • SplitCriterion supports gdi and deviance. ScoreTransform currently accepts none.
  • Rows with missing responses, zero weights, or all predictor values missing are omitted. Rows with only some missing predictors remain available for split evaluation on observed variables. Inf values and negative weights are rejected.
  • Host and table fitting remain CPU operations. Resident input support is reported as GatherFallback and is independently gated as a RunMat extension before download.
  • Categorical predictors, pruning, surrogate splits, cross-validation, prior/cost matrices, and hyperparameter optimization are not implemented yet and raise explicit errors instead of silently producing partial models.
  • The returned object exposes ResponseName, PredictorNames, ClassNames, CategoricalPredictors, ScoreTransform, NumObservations, NumPredictors, NumNodes, NumSplits, and ModelParameters properties.

Examples

Fit and predict numeric classes

X = [0; 1; 2; 3];
Y = [0; 0; 1; 1];
mdl = fitctree(X, Y, 'MaxNumSplits', 1, 'MinParentSize', 2);
[label,score] = predict(mdl, [0.5; 2.5])

Expected output:

label is [0; 1], and score has one posterior-probability column per class.

Fit a table-input classification tree

T = table(A, B, Y, 'VariableNames', {'A','B','Y'});
mdl = fitctree(T, 'Y ~ A + B')

Expected output:

mdl uses A and B as numeric predictors and Y as the response.

Using fitctree with coding agents

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

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

FAQ

Does fitctree support categorical predictors?⌄

No. RunMat currently supports numeric predictors only and raises an explicit error for categorical-predictor options.

What does predict return for a classification tree?⌄

predict(mdl,Xnew) returns predicted class labels. With multiple outputs, [label,score,node,cnum] returns posterior probabilities, one-based leaf node ids, and one-based class-number predictions.

Related Stats functions

Ml

bayesopt · classify · confusionmat · crossvalind · cvpartition · fitclinear · fitlm · kmeans · knnsearch · lasso · lassoglm · linkage · lscov · mnrfit · optimizableVariable · pdist · pdist2 · perfcurve · predict · regress · ridge · squareform · test · training · tsne

Summary

binocdf · boxplot · cdf · cdfplot · chi2cdf · corr · corrcoef · corrcov · cov · cov2corr · dummyvar · ecdf · filloutliers · fitdist · geomean · grpstats · harmmean · icdf · isoutlier · kstest · kurtosis · lsline · mad · mode · nanmax · normalize · normcdf · norminv · normpdf · onehotdecode · onehotencode · pdf · prctile · quantile · refline · rmse · skewness · tabulate · tcdf · tiedrank · tinv · tpdf · ttest2 · wblinv

Random

binornd · bootstrp · datasample · dividerand · exprnd · gamrnd · lhsdesign · mvnrnd · normrnd · random · randsample · rng · trnd · unidrnd · unifrnd · wblrnd

Hist

histc · histcounts · histcounts2

Options

statget · statset

Open-source implementation

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

  • View the source for fitctree in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

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.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • How fitctree works
  • Examples
  • Fit and predict numeric classes
  • Fit a table-input classification tree
  • Using fitctree with coding agents
  • FAQ
  • Related Stats functions
  • Ml
  • Summary
  • Random
  • Hist
  • Options
  • Open-source implementation
  • About RunMat