Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Seyamalam/bun-scikit/llms.txt
Use this file to discover all available pages before exploring further.
Overview
LinearRegression fits a linear model with coefficients to minimize the residual sum of squares between the observed targets and the predictions. This implementation uses the normal equation method with native Zig acceleration.
Constructor
Parameters
Configuration options for the model
Methods
fit
Fit the linear model using training data.X: Training data matrix of shape[nSamples, nFeatures]y: Target values vector of lengthnSamplessampleWeight: Optional sample weights (not currently used)
predict
Predict using the linear model.X: Samples matrix of shape[nSamples, nFeatures]
nSamples
Example:
score
Return the coefficient of determination (R² score) of the prediction.X: Test samples matrixy: True target values
Attributes
After fitting, the following attributes are available:Estimated coefficients for the linear regression problem
Independent term in the linear model
The backend used for fitting (always
'zig' for LinearRegression)Path to the native library used for fitting
Complete Example
Notes
- LinearRegression requires native Zig kernels. Build them with
bun run native:buildif not using prebuilt binaries. - The normal equation solver has O(n³) time complexity for feature count n, so may be slow for very high-dimensional data.
- For regularized linear regression, see Ridge, Lasso, or ElasticNet.