|
Download README.md from elvis-hf/ensemble: direct link, hf CLI and curl.
- Browser
- Download file 5.22 kB
-
https://huggingface.co/spaces/elvis-hf/ensemble/resolve/main/README.md
- Command line
-
hf download hf://spaces/elvis-hf/ensemble/README.md
-
curl -L -o README.md https://huggingface.co/spaces/elvis-hf/ensemble/resolve/main/README.md
5.22 kB
| title: Ensemble | |
| emoji: 📈 | |
| colorFrom: pink | |
| colorTo: gray | |
| sdk: static | |
| pinned: false | |
| # Ensemble playground | |
| Serve this directory over HTTP, for example with `python3 -m http.server 8000`, then open http://localhost:8000. Opening `index.html` directly as a file is no longer supported because the app loads a Python web worker. | |
| The first visit downloads Pyodide 314.0.6 (scikit-learn 1.8.0) and its bundled scikit-learn dependencies from jsDelivr. An internet connection is required for that download. All training then runs locally in the browser, in a worker that keeps drawing responsive. | |
| Choose Custom under Data → Type to draw any of three classes on the left plot, select bagging or boosting, and choose a scikit-learn classifier. The dropdown includes decision trees, SVC, linear classifiers, GaussianNB, nearest neighbors, discriminant analysis, and MLPClassifier. Classifiers without `sample_weight` support are available only for bagging; compatibility is detected from the installed sklearn version. | |
| Built-in datasets include Half circles (the original example), XOR (four corner points), Circles, Blobs (three classes), and Spirals. Presets load immediately and disable drawing, undo, and clear. Switching back to Custom restores your drawing. Changing the dataset resets the ensemble. For XOR with AdaBoost decision trees, use `{"max_depth": 2}`; a depth-1 stump cannot beat chance. | |
| Random seed defaults to 42 and controls model initialization and bootstrap sampling. The same dataset, settings, seed, and runtime reproduce the ensemble, including removing and re-adding a model. Changing the seed resets the ensemble. Acceptable seeds are integers from 0 to 4294967295. An explicit non-null `random_state` in the JSON arguments overrides model initialization; the seed field still controls bagging samples. | |
| Enter non-default constructor arguments as a JSON object: | |
| - DecisionTreeClassifier: `{"max_depth": 2, "min_samples_leaf": 3}` | |
| - SVC: `{"C": 0.5, "kernel": "rbf", "gamma": "scale"}` | |
| - LogisticRegression: `{"C": 2, "max_iter": 500}` | |
| - KNeighborsClassifier (bagging): `{"n_neighbors": 3}` | |
| Use `{}` or an empty box for sklearn defaults. Use JSON `true`, `false`, and `null` for booleans and None. Switching classifiers clears the arguments. Invalid arguments and sklearn training errors appear below the model controls. The initial decision tree uses the visible override `{"max_depth": 1}`. | |
| Each Add trains one real sklearn estimator. Python implements the incremental ensemble orchestration so removal restores the retained ensemble exactly, and additions remain possible after a perfect learner. Bagging trains on bootstrap samples and combines majority votes. Multiclass AdaBoost (SAMME) trains with sample weights, computes weighted votes, and rejects learners that cannot beat chance. Perfect learners receive a finite capped vote weight. Some classifiers require both classes or enough samples in each bootstrap sample; sklearn reports a training error if a sample does not meet those requirements. | |
| Dot area represents the sample weight for the next boosting step. Hover a point for its coordinates and weight. Hover or keyboard-focus a model chip to temporarily replace the ensemble boundary with that learner’s filled decision regions, using the same colors. Moving away restores the ensemble. Grid predictions are computed in Python on a 160 × 160 mesh; training accuracy and sample weights use exact training predictions. Arrow keys and Space/Enter add points on the focused canvas. | |
| Editing data or configuration clears the ensemble. Results from an in-progress fit are discarded if the data or settings change. Limits: 1,500 points and 100 learners. Accuracy is training accuracy, not held-out accuracy. | |
| Run JavaScript regression checks with `node --test *.test.js`. | |
| References: [Pyodide worker documentation](https://pyodide.org/en/0.27.7/usage/webworker.html), [bundled packages](https://pyodide.org/en/0.27.7/usage/packages-in-pyodide.html), [sklearn AdaBoost requirements](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.AdaBoostClassifier.html). Drawing interaction inspired by https://huggingface.co/spaces/elvis-hf/decision_boundary. | |
| Random Forest and Extra Trees are ensemble methods. Their base learners are decision trees, so the classifier dropdown is fixed in that mode. Each Add appends one sklearn forest tree using warm start; Remove restores the retained forest. Predictions average tree probabilities. The JSON box accepts forest arguments such as `{"max_depth": 3, "max_features": "sqrt", "random_state": 42}`. The controls manage `n_estimators` and `warm_start`; omit these from the arguments. | |
| Class A, B, and C are supported by all ensemble methods; any two classes are sufficient to train. SAMME updates weights for misclassified samples and uses class votes. Forests average per-class probabilities. Extra Trees uses sklearn ExtraTreesClassifier with its default randomized splits and no bootstrap unless requested. MLPClassifier is available for boosting with genuine sample_weight support in sklearn 1.8. | |
| Run backend reproducibility checks with `python3 -m unittest backend_test.py` (requires NumPy and scikit-learn). | |