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

fitclinear — Fit a binary linear classification model.

fitclinear fits a binary linear classifier from a predictor matrix or table and returns a ClassificationLinear object usable with predict.

Syntax

Mdl = fitclinear(X, Y)
Mdl = fitclinear(Tbl, ResponseVarName)
Mdl = fitclinear(Tbl, formula)
Mdl = fitclinear(Tbl, Y)
Mdl = fitclinear(___, Name, Value)
[Mdl, FitInfo] = fitclinear(___)

Inputs

NameTypeRequiredDefaultDescription
tblOrXAnyYes—Input table or predictor matrix.
yOrResponseAnyNo—Response vector, response variable name, or table formula.
optionsAnyVariadic—Name-value options such as Learner, Lambda, Regularization, Solver, ObservationsIn, FitBias, ClassNames, PredictorNames, ResponseName, Weights, Prior, and ScoreTransform.

Returns

NameTypeDescription
MdlAnyClassificationLinear object containing coefficients, class names, and fit metadata.
MdlAnyClassificationLinear object.
FitInfoAnyTraining diagnostics for each Lambda value.

Returned values from fitclinear depend on how many outputs the caller requests.

Errors

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

How fitclinear works

  • fitclinear(X,Y) fits a binary SVM-style linear classifier with observations in rows of X and labels in Y.
  • Table input supports fitclinear(Tbl,ResponseVarName), fitclinear(Tbl,formula), and fitclinear(Tbl,Y). Formula support covers additive predictor lists such as Y ~ A + B.
  • Learner supports svm and logistic. Logistic models use logistic-loss training and return posterior-style scores by default; SVM models return raw signed-margin scores.
  • Regularization supports ridge and lasso. Lambda accepts a nonnegative scalar or vector, producing one coefficient column per Lambda value.
  • ObservationsIn supports rows and columns for numeric matrices. Table input requires row observations.
  • 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, Weights, Prior, FitBias, Beta, Bias, Solver, IterationLimit, PassLimit, and ScoreTransform are accepted.
  • Rows containing NaN in predictors or response, or zero weights, are omitted before fitting; 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.
  • Cross-validation, cost matrices, leaveout/holdout partitions, and hyperparameter optimization are not implemented yet and raise explicit errors instead of silently producing partial models.
  • The returned object exposes Beta, Bias, Lambda, Learner, Regularization, Solver, ScoreTransform, ResponseName, PredictorNames, ClassNames, Prior, NumObservations, NumPredictors, and ModelParameters properties. [Mdl,FitInfo] returns training diagnostics including Lambda, Objective, NumIterations, NumPasses, and GradientNorm.

Examples

Fit and predict a logistic linear classifier

X = [0; 1; 2; 3];
Y = [0; 0; 1; 1];
[Mdl,FitInfo] = fitclinear(X, Y, 'Learner', 'logistic', 'Lambda', 0);
[label,score] = predict(Mdl, [0.2; 2.8])

Expected output:

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

Use column-oriented observations

Mdl = fitclinear([0 1 2 3], Y, 'ObservationsIn', 'columns');
label = predict(Mdl, [0.2 2.8], 'ObservationsIn', 'columns')

Expected output:

The predictor matrix is transposed internally so columns are observations.

Fit a table-input classifier

T = table(A, B, Y, 'VariableNames', {'A','B','Y'});
Mdl = fitclinear(T, 'Y ~ A + B', 'Learner', 'svm')

Expected output:

Mdl uses A and B as numeric predictors and Y as the binary response.

Using fitclinear with coding agents

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

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

FAQ

Does fitclinear support multiclass classification?⌄

No. MATLAB's fitclinear is binary; RunMat requires exactly two observed classes and raises an explicit error otherwise.

What does predict return for ClassificationLinear?⌄

predict(Mdl,Xnew) returns predicted class labels. [label,score] = predict(Mdl,Xnew) also returns raw class scores for SVM models or posterior-style probabilities for logistic models.

Related Stats functions

Ml

bayesopt · classify · confusionmat · crossvalind · cvpartition · fitctree · 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 fitclinear is executed, line by line, in Rust.

  • View the source for fitclinear 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 fitclinear works
  • Examples
  • Fit and predict a logistic linear classifier
  • Use column-oriented observations
  • Fit a table-input classifier
  • Using fitclinear with coding agents
  • FAQ
  • Related Stats functions
  • Ml
  • Summary
  • Random
  • Hist
  • Options
  • Open-source implementation
  • About RunMat