From 16266b18ab4e40f80e09d9769bbf6bdc718d1e3b Mon Sep 17 00:00:00 2001 From: ChrisW09 <50968720+ChrisW09@users.noreply.github.com> Date: Wed, 21 Oct 2026 21:44:38 +0200 Subject: [PATCH] docs: make the quickstart examples run in order The regression example rebound X_train/y_train, so the following config example fitted a classifier on continuous targets, and the LSS example started with an "X_train, ... = ..." placeholder that raises TypeError. Keep the regression split in its own *_reg variables and reuse it in the LSS example. Fixes #569 --- docs/getting_started/quickstart.md | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/docs/getting_started/quickstart.md b/docs/getting_started/quickstart.md index ba43d539..a7a49e05 100644 --- a/docs/getting_started/quickstart.md +++ b/docs/getting_started/quickstart.md @@ -68,29 +68,29 @@ Regression follows the same workflow with a different model class: from sklearn.datasets import make_regression from deeptab.models import FTTransformerRegressor -# Generate regression data -X, y = make_regression( +# Generate regression data (kept separate from the classification split above) +X_reg, y_reg = make_regression( n_samples=1000, n_features=10, noise=0.1, random_state=42, ) -X = pd.DataFrame(X, columns=[f"feature_{i}" for i in range(X.shape[1])]) +X_reg = pd.DataFrame(X_reg, columns=[f"feature_{i}" for i in range(X_reg.shape[1])]) -X_train, X_test, y_train, y_test = train_test_split( - X, y, test_size=0.2, random_state=42 +X_train_reg, X_test_reg, y_train_reg, y_test_reg = train_test_split( + X_reg, y_reg, test_size=0.2, random_state=42 ) # Use a different architecture model = FTTransformerRegressor() -model.fit(X_train, y_train, max_epochs=50) +model.fit(X_train_reg, y_train_reg, max_epochs=50) -metrics = model.evaluate(X_test, y_test) +metrics = model.evaluate(X_test_reg, y_test_reg) print(f"Test RMSE: {metrics['rmse']:.3f}") # Predict continuous values -predictions = model.predict(X_test) +predictions = model.predict(X_test_reg) ``` The only changes are the model class (`*Regressor`) and the interpretation of outputs. @@ -197,17 +197,14 @@ For uncertainty quantification, use `LSS` models: ```python from deeptab.models import MambularLSS -# Same data as regression example -X_train, X_test, y_train, y_test = ... - -# Initialize LSS model +# Reuse the train/test split from the regression example model = MambularLSS() # Fit with a parametric family -model.fit(X_train, y_train, family="normal", max_epochs=50) +model.fit(X_train_reg, y_train_reg, family="normal", max_epochs=50) # Predict distribution parameters -params = model.predict(X_test) +params = model.predict(X_test_reg) # For family="normal", params has shape (n_samples, 2) with columns [mean, std] mean_predictions = params[:, 0]