Skip to content

Latest commit

 

History

History
214 lines (151 loc) · 5.5 KB

File metadata and controls

214 lines (151 loc) · 5.5 KB

flow-scikit Demos

Each demo runs from the terminal via ./flow run examples/<name>.flow. The gifs below show the expected terminal output.

Table of Contents

  1. Iris Classification
  2. Regression Demo
  3. Grid Search Demo
  4. Full API Demo
  5. New Modules Demo
  6. Clustering Demo
  7. Ensemble Comparison
  8. SVM Demo
  9. Preprocessing Demo

Iris Classification

Trains a LogisticRegression on synthetic iris-like data. Shows the predict/decide split, structured classification report, and Pipeline with clone-in-init.

./flow run examples/iris_classification.flow

Iris Classification

What it shows:

  • train_test_split with auto-stratify
  • StandardScaler preprocessing
  • LogisticRegression with predict_proba (probabilities) and decide (classes)
  • classification_report with structured output
  • Pipeline with clone-in-init

Regression Demo

Fits a LinearRegression with polynomial TermSpec on synthetic data. Prints MSE, RMSE, MAE, and R2.

./flow run examples/regression_demo.flow

Regression Demo

What it shows:

  • TermSpec for polynomial features
  • Regression metrics (MSE, RMSE, MAE, R2)
  • StandardScaler in a pipeline
  • Weight printing

Grid Search Demo

Runs GridSearchCV over hyperparameter grid with the ConsoleProgress capability for a live progress bar.

./flow run examples/grid_search_demo.flow

Grid Search Demo

What it shows:

  • GridSearchCV with progress effect system
  • ConsoleProgress capability (progress bar)
  • SilentProgress capability (no output)
  • Best params and best score output

Full API Demo

End-to-end pipeline covering preprocessing, PCA, feature selection, train/test split, multi-class logistic, confusion matrix, decision tree, random forest, gradient boosting, Gaussian NB, LinearSVC, KMeans, DBSCAN, regression, and learning curve.

./flow run examples/full_demo.flow

Full API Demo

What it shows:

  • StandardScaler + PCA dimensionality reduction
  • SelectKBest feature selection
  • MultiClassLogisticRegression (softmax)
  • ConfusionMatrix with formatted printing
  • DecisionTree, RandomForest, GradientBoosting, GaussianNB, LinearSVC
  • KMeans and DBSCAN clustering
  • Ridge, Lasso, GradientBoostingRegressor
  • learning_curve with progress reporting
  • Cohen's kappa and balanced accuracy

New Modules Demo

Showcases the newer modules: IsotonicRegression, KernelRidge (RBF and linear), PLSRegression, NMF, TSNE, and extended metrics.

./flow run examples/new_modules_demo.flow

New Modules Demo

What it shows:

  • IsotonicRegression with monotonic fitting
  • KernelRidge with RBF and linear kernels
  • PLSRegression (NIPALS algorithm) for multi-target
  • NMF with reconstruction error
  • TSNE dimensionality reduction
  • median_absolute_error, max_error, mean_squared_log_error

Clustering Demo

Compares KMeans, MiniBatchKMeans, DBSCAN, and AgglomerativeClustering on 3 Gaussian blobs. Prints cluster labels and silhouette score.

./flow run examples/clustering_demo.flow

Clustering Demo

What it shows:

  • KMeans with inertia and centroid printing
  • MiniBatchKMeans with mini-batch updates
  • DBSCAN with noise point detection
  • AgglomerativeClustering with single linkage
  • silhouette_score for cluster quality

Ensemble Comparison

Trains six classifiers on the same dataset and prints a summary table comparing accuracy.

./flow run examples/ensemble_comparison.flow

Ensemble Comparison

What it shows:

  • DecisionTreeClassifier (baseline)
  • RandomForestClassifier
  • GradientBoostingClassifier
  • AdaBoostClassifier
  • BaggingClassifier
  • VotingClassifier
  • Summary table with all accuracies

SVM Demo

Demonstrates LinearSVC, KernelSVC with RBF kernel, and LinearSVR. Prints weights, support vectors, and hinge loss.

./flow run examples/svm_demo.flow

SVM Demo

What it shows:

  • LinearSVC with weight and bias printing
  • KernelSVC with RBF kernel and support vector count
  • LinearSVR for regression with R2
  • hinge_loss metric

Preprocessing Demo

Walks through every preprocessing transformer with before/after output.

./flow run examples/preprocessing_demo.flow

Preprocessing Demo

What it shows:

  • StandardScaler with mean/std
  • MinMaxScaler with min/max
  • RobustScaler with median
  • MaxAbsScaler
  • Normalizer (L2)
  • Binarizer
  • KBinsDiscretizer
  • PolynomialFeatures (shape change)
  • LabelEncoder
  • SimpleImputer (before/after)

Recording Gifs

The gifs referenced above live in gifs/. To record them:

# Using asciinema
asciinema rec gifs/iris_classification.cast --command "./flow run examples/iris_classification.flow"
# Then convert to gif:
agg gifs/iris_classification.cast gifs/iris_classification.gif

# Or using terminalizer
terminalizer record -k "./flow run examples/iris_classification.flow" -o gifs/iris_classification.yml
terminalizer render gifs/iris_classification.yml -o gifs/iris_classification.gif

Each gif should be 800x600 or smaller, under 5 MB, and loop seamlessly.