Initializing playground…
← Back to roadmap

Regression

Simple linear regression, polynomial fitting, and multiple OLS — mirrors scipy.stats.linregress, numpy.polyfit, and statsmodels.OLS.

1 — Simple Linear Regression

linregress(x, y) returns slope, intercept, Pearson r, p-value, and standard error.

JavaScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

2 — Polynomial Fitting

polyfit(x, y, deg) fits a polynomial of degree deg. Use polyval to evaluate it.

JavaScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

3 — Multiple OLS Regression

new OLS().fit(X, y) fits multiple linear regression, returning params, R², F-statistic, and a formatted summary.

JavaScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

4 — Prediction

Use result.predict(Xnew) to generate predictions for new observations.

JavaScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent