Getting Started
Overview
Beginner-first machine learning. Train a model in 3 lines.
fling wraps scikit-learn behind a clean, safe API designed for people learning ML. It handles data splitting, preprocessing, missing values, and encoding automatically - and explains every decision in plain English.
Install
Quick reference
| Task | Code |
|---|---|
| Classify (predict a category) | Classifier(data=..., target=...) |
| Regress (predict a number) | Regressor(data=..., target=...) |
| Train | .train() |
| Evaluate on test set | .evaluate() |
| Predict new rows | .predict(new_df) |
| Visualize results | .visualize() |
| Explain feature importance | .explain() |
| Compare 5 models | .compare() |
| Get algorithm recommendations | .recommend() |
| See the raw sklearn code | .show_sklearn_code() |
| Escape to sklearn | .to_sklearn() / .get_splits() |
What fling handles automatically
| Problem | What fling does |
|---|---|
| Text / categorical columns | OneHotEncodes them |
| Missing numeric values | Fills with column median |
| Missing categorical values | Fills with most frequent value |
| Columns with > 50% missing | Drops them, logs in report |
| ID-like columns (all unique) | Drops them automatically |
| Choosing a model | Picks based on dataset size |
| Train/test split ordering | Always splits before preprocessing |
How fling prevents data leakage
Data leakage is the #1 silent bug in beginner ML. It happens when test data influences the training process - making accuracy look better than it really is.
The wrong way (what most tutorials show)
⚠The scaler's mean and std were computed using test rows. Your accuracy score is optimistic - it won't hold up on truly new data.
The right way (what fling always does)
You can verify this yourself:
Requirements
- Python 3.8+
- scikit-learn ≥ 1.0
- pandas ≥ 1.3
- numpy ≥ 1.21
- matplotlib ≥ 3.4 (optional - only needed for
.visualize())
Examples
The examples/ folder has four runnable scripts:
| File | What it shows |
|---|---|
01_your_first_classifier.py | Basic 3-line classifier |
02_your_first_regressor.py | Basic 3-line regressor |
03_compare_models.py | recommend → train → compare → explain → visualize |
04_graduate_to_sklearn.py | show_sklearn_code → to_sklearn → get_splits |
Next steps
- Classifier reference - full parameter docs, all algorithm strings, auto-selection logic
- .train() / .evaluate() - output format, R² interpretation, classification report
- .visualize() - 4-panel figures for classifiers and regressors
- Data leakage - why fling splits before preprocessing and how to verify it
- Extended API - clustering, text, neural networks, ensembles, and more
- GitHub ↗ - source code, issues, contributing