seaborn-lite 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- seaborn_lite-0.1.0/PKG-INFO +159 -0
- seaborn_lite-0.1.0/README.md +148 -0
- seaborn_lite-0.1.0/pyproject.toml +26 -0
- seaborn_lite-0.1.0/seaborn_lite/__init__.py +85 -0
- seaborn_lite-0.1.0/seaborn_lite/__main__.py +3 -0
- seaborn_lite-0.1.0/seaborn_lite/cli.py +49 -0
- seaborn_lite-0.1.0/seaborn_lite/datasets/__init__.py +31 -0
- seaborn_lite-0.1.0/seaborn_lite/datasets/buy_computer.csv +15 -0
- seaborn_lite-0.1.0/seaborn_lite/datasets/customer_churn_raw.csv +105 -0
- seaborn_lite-0.1.0/seaborn_lite/datasets/diabetes_simple.csv +71 -0
- seaborn_lite-0.1.0/seaborn_lite/datasets/dwm_common_dataset.csv +13 -0
- seaborn_lite-0.1.0/seaborn_lite/datasets/food_delivery_olap.csv +385 -0
- seaborn_lite-0.1.0/seaborn_lite/datasets/housing_raw.csv +84 -0
- seaborn_lite-0.1.0/seaborn_lite/datasets/iris_simple.csv +91 -0
- seaborn_lite-0.1.0/seaborn_lite/datasets/mall_customers.csv +101 -0
- seaborn_lite-0.1.0/seaborn_lite/datasets/play_tennis.csv +15 -0
- seaborn_lite-0.1.0/seaborn_lite/datasets/sales_olap.csv +289 -0
- seaborn_lite-0.1.0/seaborn_lite/datasets/student_clustering.csv +81 -0
- seaborn_lite-0.1.0/seaborn_lite/datasets/transactions_delimiter.csv +9 -0
- seaborn_lite-0.1.0/seaborn_lite/datasets/transactions_list.csv +10 -0
- seaborn_lite-0.1.0/seaborn_lite/datasets/transactions_onehot.csv +8 -0
- seaborn_lite-0.1.0/seaborn_lite/demos.py +282 -0
- seaborn_lite-0.1.0/seaborn_lite/dwm/__init__.py +62 -0
- seaborn_lite-0.1.0/seaborn_lite/dwm/_utils.py +36 -0
- seaborn_lite-0.1.0/seaborn_lite/dwm/clustering.py +130 -0
- seaborn_lite-0.1.0/seaborn_lite/dwm/exploration.py +65 -0
- seaborn_lite-0.1.0/seaborn_lite/dwm/grouping.py +30 -0
- seaborn_lite-0.1.0/seaborn_lite/dwm/hierarchical.py +172 -0
- seaborn_lite-0.1.0/seaborn_lite/dwm/itemsets.py +120 -0
- seaborn_lite-0.1.0/seaborn_lite/dwm/naive_bayes.py +129 -0
- seaborn_lite-0.1.0/seaborn_lite/dwm/olap.py +55 -0
- seaborn_lite-0.1.0/seaborn_lite/dwm/preprocessing.py +60 -0
- seaborn_lite-0.1.0/seaborn_lite/dwm/ranking.py +65 -0
- seaborn_lite-0.1.0/seaborn_lite/dwm/visualisation.py +65 -0
- seaborn_lite-0.1.0/seaborn_lite/experiments/01_SQL_EXPERIMENTS.txt +130 -0
- seaborn_lite-0.1.0/seaborn_lite/experiments/02_STAR_SCHEMA_AND_15_QUERIES.txt +176 -0
- seaborn_lite-0.1.0/seaborn_lite/experiments/03_OLAP_OPERATIONS.txt +65 -0
- seaborn_lite-0.1.0/seaborn_lite/experiments/04_DATA_PREPROCESSING_AND_VISUALISATION.txt +85 -0
- seaborn_lite-0.1.0/seaborn_lite/experiments/05_APRIORI_FREQUENT_PATTERNS.txt +78 -0
- seaborn_lite-0.1.0/seaborn_lite/experiments/06_KMEANS_AND_KMEDOIDS.txt +76 -0
- seaborn_lite-0.1.0/seaborn_lite/experiments/07_HIERARCHICAL_CLUSTERING.txt +68 -0
- seaborn_lite-0.1.0/seaborn_lite/experiments/08_NAIVE_BAYES.txt +64 -0
- seaborn_lite-0.1.0/seaborn_lite/experiments/09_PAGERANK_AND_HITS.txt +63 -0
- seaborn_lite-0.1.0/seaborn_lite/experiments/DWM_ALL_EXPERIMENTS_ONE_FILE.txt +827 -0
- seaborn_lite-0.1.0/seaborn_lite/experiments/__init__.py +175 -0
- seaborn_lite-0.1.0/seaborn_lite/plotting.py +214 -0
- seaborn_lite-0.1.0/seaborn_lite.egg-info/PKG-INFO +159 -0
- seaborn_lite-0.1.0/seaborn_lite.egg-info/SOURCES.txt +51 -0
- seaborn_lite-0.1.0/seaborn_lite.egg-info/dependency_links.txt +1 -0
- seaborn_lite-0.1.0/seaborn_lite.egg-info/entry_points.txt +2 -0
- seaborn_lite-0.1.0/seaborn_lite.egg-info/requires.txt +3 -0
- seaborn_lite-0.1.0/seaborn_lite.egg-info/top_level.txt +1 -0
- seaborn_lite-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: seaborn-lite
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A tiny matplotlib-only seaborn subset plus the DWM practical-exam algorithms, from scratch.
|
|
5
|
+
License: MIT
|
|
6
|
+
Requires-Python: >=3.9
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: numpy>=1.24
|
|
9
|
+
Requires-Dist: pandas>=2.0
|
|
10
|
+
Requires-Dist: matplotlib>=3.7
|
|
11
|
+
|
|
12
|
+
# seaborn-lite
|
|
13
|
+
|
|
14
|
+
A tiny, matplotlib-only subset of seaborn **plus** every algorithm from the
|
|
15
|
+
DWM practical exam and every experiment write-up, packaged for direct use.
|
|
16
|
+
|
|
17
|
+
No seaborn, no scikit-learn, no scipy — just `numpy`, `pandas` and `matplotlib`.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install .
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
That installs the distribution `seaborn-lite` and the import package
|
|
26
|
+
`seaborn_lite`, bundles the 14 exam datasets, and adds the `seaborn-lite`
|
|
27
|
+
command. To publish it so `pip install seaborn-lite` works from anywhere, build
|
|
28
|
+
and upload it with `python -m build` + `twine upload dist/*`.
|
|
29
|
+
|
|
30
|
+
## Print an experiment write-up
|
|
31
|
+
|
|
32
|
+
Every experiment `.txt` is bundled. One function per experiment prints it
|
|
33
|
+
verbatim and returns the same text:
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
import seaborn_lite as snsl
|
|
37
|
+
|
|
38
|
+
snsl.apriori() # prints 05_APRIORI_FREQUENT_PATTERNS.txt
|
|
39
|
+
snsl.sql() # prints 01_SQL_EXPERIMENTS.txt
|
|
40
|
+
snsl.list() # shows every available function
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
| Function | Prints |
|
|
44
|
+
| :--- | :--- |
|
|
45
|
+
| `sql()` | `01_SQL_EXPERIMENTS.txt` |
|
|
46
|
+
| `star_schema()` | `02_STAR_SCHEMA_AND_15_QUERIES.txt` |
|
|
47
|
+
| `olap()` | `03_OLAP_OPERATIONS.txt` |
|
|
48
|
+
| `preprocessing()`, `data_preprocessing()` | `04_DATA_PREPROCESSING_AND_VISUALISATION.txt` |
|
|
49
|
+
| `apriori()`, `appriori()` | `05_APRIORI_FREQUENT_PATTERNS.txt` |
|
|
50
|
+
| `kmeans()`, `kmedoids()` | `06_KMEANS_AND_KMEDOIDS.txt` |
|
|
51
|
+
| `hierarchical()`, `hierarchical_clustering()` | `07_HIERARCHICAL_CLUSTERING.txt` |
|
|
52
|
+
| `naive_bayes()`, `categorical_naive_bayes()`, `gaussian_naive_bayes()` | `08_NAIVE_BAYES.txt` |
|
|
53
|
+
| `pagerank()`, `hits()` | `09_PAGERANK_AND_HITS.txt` |
|
|
54
|
+
| `all_experiments()` | `DWM_ALL_EXPERIMENTS_ONE_FILE.txt` |
|
|
55
|
+
|
|
56
|
+
`snsl.list()` prints this table with the exact function names and file names.
|
|
57
|
+
The algorithm implementations live under `seaborn_lite.dwm`, so
|
|
58
|
+
`snsl.kmeans()` prints the write-up while `seaborn_lite.dwm.kmeans(X, k=3)`
|
|
59
|
+
does the clustering.
|
|
60
|
+
|
|
61
|
+
## Plotting
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
import seaborn_lite as sns
|
|
65
|
+
from seaborn_lite import datasets
|
|
66
|
+
|
|
67
|
+
df = datasets.load("customer_churn_raw")
|
|
68
|
+
sns.set_theme()
|
|
69
|
+
sns.histplot(df, x="Age", kde=True)
|
|
70
|
+
sns.countplot(df, x="Contract_Type")
|
|
71
|
+
sns.heatmap(df.select_dtypes("number").corr(), annot=True)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Supported: `histplot`, `countplot`, `barplot`, `boxplot`, `scatterplot`,
|
|
75
|
+
`heatmap`, `pairplot`, `set_theme`. Same `data=` / `x=` / `y=` calling style as
|
|
76
|
+
seaborn; each returns the matplotlib `Axes` (except `pairplot`, which returns an
|
|
77
|
+
object with `.fig` and `.savefig`).
|
|
78
|
+
|
|
79
|
+
## Algorithms
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from seaborn_lite import datasets
|
|
83
|
+
from seaborn_lite.dwm import kmeans
|
|
84
|
+
from seaborn_lite.dwm.itemsets import apriori, transactions_from_dataframe
|
|
85
|
+
|
|
86
|
+
X = datasets.load("mall_customers").select_dtypes("number").to_numpy()
|
|
87
|
+
result = kmeans(X, k=3)
|
|
88
|
+
print(result.centroids, result.wcss)
|
|
89
|
+
|
|
90
|
+
tx = transactions_from_dataframe(datasets.load("transactions_list"))
|
|
91
|
+
frequent = apriori(tx, min_support=0.3)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### API by experiment
|
|
95
|
+
|
|
96
|
+
| Experiment | Import | Main callables |
|
|
97
|
+
| :--- | :--- | :--- |
|
|
98
|
+
| 3 · OLAP | `from seaborn_lite.dwm import olap` | `rollup`, `drilldown`, `slice_cube`, `dice_cube`, `pivot` |
|
|
99
|
+
| 4 · Explore | `from seaborn_lite.dwm import explore` | `explore(df) -> dict` |
|
|
100
|
+
| 4 · Clean | `from seaborn_lite.dwm import clean_dataframe` | `clean_dataframe(df, rename=...)` |
|
|
101
|
+
| 4 · Preprocess | `from seaborn_lite.dwm import preprocessing` | `discretize`, `label_encode`, `one_hot_encode`, `minmax_scale`, `zscore_scale`, `train_test_split` |
|
|
102
|
+
| 4 · Visualise | `from seaborn_lite.dwm import plot_all` | `plot_all(df, out_dir)` |
|
|
103
|
+
| 4 · Pivot | `from seaborn_lite.dwm import grouping` | `group_summary`, `multi_agg`, `pivot_table` |
|
|
104
|
+
| 5 · Apriori | `from seaborn_lite.dwm import apriori, association_rules` | `apriori(transactions, min_support)`, `association_rules(frequent, transactions, min_confidence)` |
|
|
105
|
+
| 6 · K-Means | `from seaborn_lite.dwm import kmeans, elbow` | `kmeans(X, k) -> KMeansResult`, `elbow(X, k_max)` |
|
|
106
|
+
| 6 · K-Medoids | `from seaborn_lite.dwm import kmedoids` | `kmedoids(X, k) -> KMedoidsResult` |
|
|
107
|
+
| 7 · Hierarchical | `from seaborn_lite.dwm import agglomerative, silhouette_score, plot_dendrogram` | four linkages (`single`/`complete`/`average`/`ward`), `scale=True` for StandardScaler behaviour |
|
|
108
|
+
| 8 · Naive Bayes | `from seaborn_lite.dwm import CategoricalNB, GaussianNB` | scikit-learn-shaped `fit` / `predict` / `predict_proba` |
|
|
109
|
+
| 9 · PageRank | `from seaborn_lite.dwm import pagerank, hits` | `pagerank(graph) -> dict`, `hits(graph) -> (hubs, authorities)` |
|
|
110
|
+
|
|
111
|
+
## Datasets
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
from seaborn_lite import datasets
|
|
115
|
+
|
|
116
|
+
datasets.available() # 14 names
|
|
117
|
+
datasets.load("play_tennis") # DataFrame
|
|
118
|
+
datasets.path("play_tennis") # Path to the bundled CSV
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## CLI
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
seaborn-lite list
|
|
125
|
+
seaborn-lite datasets
|
|
126
|
+
seaborn-lite run kmeans
|
|
127
|
+
seaborn-lite run visualise --out ./plots
|
|
128
|
+
seaborn-lite run apriori --data my_baskets.csv
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Demos: `apriori`, `kmeans`, `kmedoids`, `hierarchical`, `nb-categorical`,
|
|
132
|
+
`nb-gaussian`, `pagerank`, `hits`, `olap`, `explore`, `clean`, `preprocess`,
|
|
133
|
+
`pivot`, `visualise`.
|
|
134
|
+
|
|
135
|
+
## Layout
|
|
136
|
+
|
|
137
|
+
```text
|
|
138
|
+
seaborn-lite/
|
|
139
|
+
├── seaborn_lite/
|
|
140
|
+
│ ├── plotting.py # the seaborn subset
|
|
141
|
+
│ ├── experiments/ # the 10 bundled .txt write-ups + printers/list()
|
|
142
|
+
│ ├── datasets/ # bundled CSVs + loaders
|
|
143
|
+
│ ├── demos.py # what the CLI runs
|
|
144
|
+
│ ├── cli.py
|
|
145
|
+
│ └── dwm/ # the exam algorithms
|
|
146
|
+
├── tests/selfcheck.py # assert-based, no test framework
|
|
147
|
+
├── pyproject.toml
|
|
148
|
+
└── DWM_PRACTICAL_EXAM/ # original exam submission, left untouched
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Verify
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
python tests/selfcheck.py
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
This loads every dataset, checks known results (17 Apriori itemsets, Ward
|
|
158
|
+
silhouette 0.2352, 13/14 Tennis accuracy, PageRank ranking), writes all eight
|
|
159
|
+
plots, and runs every CLI demo.
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# seaborn-lite
|
|
2
|
+
|
|
3
|
+
A tiny, matplotlib-only subset of seaborn **plus** every algorithm from the
|
|
4
|
+
DWM practical exam and every experiment write-up, packaged for direct use.
|
|
5
|
+
|
|
6
|
+
No seaborn, no scikit-learn, no scipy — just `numpy`, `pandas` and `matplotlib`.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install .
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
That installs the distribution `seaborn-lite` and the import package
|
|
15
|
+
`seaborn_lite`, bundles the 14 exam datasets, and adds the `seaborn-lite`
|
|
16
|
+
command. To publish it so `pip install seaborn-lite` works from anywhere, build
|
|
17
|
+
and upload it with `python -m build` + `twine upload dist/*`.
|
|
18
|
+
|
|
19
|
+
## Print an experiment write-up
|
|
20
|
+
|
|
21
|
+
Every experiment `.txt` is bundled. One function per experiment prints it
|
|
22
|
+
verbatim and returns the same text:
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
import seaborn_lite as snsl
|
|
26
|
+
|
|
27
|
+
snsl.apriori() # prints 05_APRIORI_FREQUENT_PATTERNS.txt
|
|
28
|
+
snsl.sql() # prints 01_SQL_EXPERIMENTS.txt
|
|
29
|
+
snsl.list() # shows every available function
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
| Function | Prints |
|
|
33
|
+
| :--- | :--- |
|
|
34
|
+
| `sql()` | `01_SQL_EXPERIMENTS.txt` |
|
|
35
|
+
| `star_schema()` | `02_STAR_SCHEMA_AND_15_QUERIES.txt` |
|
|
36
|
+
| `olap()` | `03_OLAP_OPERATIONS.txt` |
|
|
37
|
+
| `preprocessing()`, `data_preprocessing()` | `04_DATA_PREPROCESSING_AND_VISUALISATION.txt` |
|
|
38
|
+
| `apriori()`, `appriori()` | `05_APRIORI_FREQUENT_PATTERNS.txt` |
|
|
39
|
+
| `kmeans()`, `kmedoids()` | `06_KMEANS_AND_KMEDOIDS.txt` |
|
|
40
|
+
| `hierarchical()`, `hierarchical_clustering()` | `07_HIERARCHICAL_CLUSTERING.txt` |
|
|
41
|
+
| `naive_bayes()`, `categorical_naive_bayes()`, `gaussian_naive_bayes()` | `08_NAIVE_BAYES.txt` |
|
|
42
|
+
| `pagerank()`, `hits()` | `09_PAGERANK_AND_HITS.txt` |
|
|
43
|
+
| `all_experiments()` | `DWM_ALL_EXPERIMENTS_ONE_FILE.txt` |
|
|
44
|
+
|
|
45
|
+
`snsl.list()` prints this table with the exact function names and file names.
|
|
46
|
+
The algorithm implementations live under `seaborn_lite.dwm`, so
|
|
47
|
+
`snsl.kmeans()` prints the write-up while `seaborn_lite.dwm.kmeans(X, k=3)`
|
|
48
|
+
does the clustering.
|
|
49
|
+
|
|
50
|
+
## Plotting
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
import seaborn_lite as sns
|
|
54
|
+
from seaborn_lite import datasets
|
|
55
|
+
|
|
56
|
+
df = datasets.load("customer_churn_raw")
|
|
57
|
+
sns.set_theme()
|
|
58
|
+
sns.histplot(df, x="Age", kde=True)
|
|
59
|
+
sns.countplot(df, x="Contract_Type")
|
|
60
|
+
sns.heatmap(df.select_dtypes("number").corr(), annot=True)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Supported: `histplot`, `countplot`, `barplot`, `boxplot`, `scatterplot`,
|
|
64
|
+
`heatmap`, `pairplot`, `set_theme`. Same `data=` / `x=` / `y=` calling style as
|
|
65
|
+
seaborn; each returns the matplotlib `Axes` (except `pairplot`, which returns an
|
|
66
|
+
object with `.fig` and `.savefig`).
|
|
67
|
+
|
|
68
|
+
## Algorithms
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from seaborn_lite import datasets
|
|
72
|
+
from seaborn_lite.dwm import kmeans
|
|
73
|
+
from seaborn_lite.dwm.itemsets import apriori, transactions_from_dataframe
|
|
74
|
+
|
|
75
|
+
X = datasets.load("mall_customers").select_dtypes("number").to_numpy()
|
|
76
|
+
result = kmeans(X, k=3)
|
|
77
|
+
print(result.centroids, result.wcss)
|
|
78
|
+
|
|
79
|
+
tx = transactions_from_dataframe(datasets.load("transactions_list"))
|
|
80
|
+
frequent = apriori(tx, min_support=0.3)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### API by experiment
|
|
84
|
+
|
|
85
|
+
| Experiment | Import | Main callables |
|
|
86
|
+
| :--- | :--- | :--- |
|
|
87
|
+
| 3 · OLAP | `from seaborn_lite.dwm import olap` | `rollup`, `drilldown`, `slice_cube`, `dice_cube`, `pivot` |
|
|
88
|
+
| 4 · Explore | `from seaborn_lite.dwm import explore` | `explore(df) -> dict` |
|
|
89
|
+
| 4 · Clean | `from seaborn_lite.dwm import clean_dataframe` | `clean_dataframe(df, rename=...)` |
|
|
90
|
+
| 4 · Preprocess | `from seaborn_lite.dwm import preprocessing` | `discretize`, `label_encode`, `one_hot_encode`, `minmax_scale`, `zscore_scale`, `train_test_split` |
|
|
91
|
+
| 4 · Visualise | `from seaborn_lite.dwm import plot_all` | `plot_all(df, out_dir)` |
|
|
92
|
+
| 4 · Pivot | `from seaborn_lite.dwm import grouping` | `group_summary`, `multi_agg`, `pivot_table` |
|
|
93
|
+
| 5 · Apriori | `from seaborn_lite.dwm import apriori, association_rules` | `apriori(transactions, min_support)`, `association_rules(frequent, transactions, min_confidence)` |
|
|
94
|
+
| 6 · K-Means | `from seaborn_lite.dwm import kmeans, elbow` | `kmeans(X, k) -> KMeansResult`, `elbow(X, k_max)` |
|
|
95
|
+
| 6 · K-Medoids | `from seaborn_lite.dwm import kmedoids` | `kmedoids(X, k) -> KMedoidsResult` |
|
|
96
|
+
| 7 · Hierarchical | `from seaborn_lite.dwm import agglomerative, silhouette_score, plot_dendrogram` | four linkages (`single`/`complete`/`average`/`ward`), `scale=True` for StandardScaler behaviour |
|
|
97
|
+
| 8 · Naive Bayes | `from seaborn_lite.dwm import CategoricalNB, GaussianNB` | scikit-learn-shaped `fit` / `predict` / `predict_proba` |
|
|
98
|
+
| 9 · PageRank | `from seaborn_lite.dwm import pagerank, hits` | `pagerank(graph) -> dict`, `hits(graph) -> (hubs, authorities)` |
|
|
99
|
+
|
|
100
|
+
## Datasets
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from seaborn_lite import datasets
|
|
104
|
+
|
|
105
|
+
datasets.available() # 14 names
|
|
106
|
+
datasets.load("play_tennis") # DataFrame
|
|
107
|
+
datasets.path("play_tennis") # Path to the bundled CSV
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## CLI
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
seaborn-lite list
|
|
114
|
+
seaborn-lite datasets
|
|
115
|
+
seaborn-lite run kmeans
|
|
116
|
+
seaborn-lite run visualise --out ./plots
|
|
117
|
+
seaborn-lite run apriori --data my_baskets.csv
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Demos: `apriori`, `kmeans`, `kmedoids`, `hierarchical`, `nb-categorical`,
|
|
121
|
+
`nb-gaussian`, `pagerank`, `hits`, `olap`, `explore`, `clean`, `preprocess`,
|
|
122
|
+
`pivot`, `visualise`.
|
|
123
|
+
|
|
124
|
+
## Layout
|
|
125
|
+
|
|
126
|
+
```text
|
|
127
|
+
seaborn-lite/
|
|
128
|
+
├── seaborn_lite/
|
|
129
|
+
│ ├── plotting.py # the seaborn subset
|
|
130
|
+
│ ├── experiments/ # the 10 bundled .txt write-ups + printers/list()
|
|
131
|
+
│ ├── datasets/ # bundled CSVs + loaders
|
|
132
|
+
│ ├── demos.py # what the CLI runs
|
|
133
|
+
│ ├── cli.py
|
|
134
|
+
│ └── dwm/ # the exam algorithms
|
|
135
|
+
├── tests/selfcheck.py # assert-based, no test framework
|
|
136
|
+
├── pyproject.toml
|
|
137
|
+
└── DWM_PRACTICAL_EXAM/ # original exam submission, left untouched
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Verify
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
python tests/selfcheck.py
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
This loads every dataset, checks known results (17 Apriori itemsets, Ward
|
|
147
|
+
silhouette 0.2352, 13/14 Tennis accuracy, PageRank ranking), writes all eight
|
|
148
|
+
plots, and runs every CLI demo.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "seaborn-lite"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A tiny matplotlib-only seaborn subset plus the DWM practical-exam algorithms, from scratch."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
dependencies = [
|
|
13
|
+
"numpy>=1.24",
|
|
14
|
+
"pandas>=2.0",
|
|
15
|
+
"matplotlib>=3.7",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.scripts]
|
|
19
|
+
seaborn-lite = "seaborn_lite.cli:main"
|
|
20
|
+
|
|
21
|
+
[tool.setuptools.packages.find]
|
|
22
|
+
include = ["seaborn_lite*"]
|
|
23
|
+
|
|
24
|
+
[tool.setuptools.package-data]
|
|
25
|
+
"seaborn_lite.datasets" = ["*.csv"]
|
|
26
|
+
"seaborn_lite.experiments" = ["*.txt"]
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""seaborn-lite: a tiny matplotlib-only seaborn subset plus the DWM toolkit.
|
|
2
|
+
|
|
3
|
+
Plot::
|
|
4
|
+
|
|
5
|
+
import seaborn_lite as snsl
|
|
6
|
+
snsl.histplot(df, x="Age", kde=True)
|
|
7
|
+
|
|
8
|
+
Print an experiment write-up verbatim::
|
|
9
|
+
|
|
10
|
+
snsl.apriori() # 05_APRIORI_FREQUENT_PATTERNS.txt
|
|
11
|
+
snsl.list() # every experiment function
|
|
12
|
+
|
|
13
|
+
Run an algorithm::
|
|
14
|
+
|
|
15
|
+
from seaborn_lite.dwm.itemsets import apriori, transactions_from_dataframe
|
|
16
|
+
from seaborn_lite import datasets
|
|
17
|
+
frequent = apriori(transactions_from_dataframe(datasets.load("transactions_list")), 0.3)
|
|
18
|
+
"""
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
from . import datasets, dwm, experiments, plotting
|
|
22
|
+
from .experiments import (
|
|
23
|
+
all_experiments,
|
|
24
|
+
apriori,
|
|
25
|
+
appriori,
|
|
26
|
+
categorical_naive_bayes,
|
|
27
|
+
data_preprocessing,
|
|
28
|
+
gaussian_naive_bayes,
|
|
29
|
+
hierarchical,
|
|
30
|
+
hierarchical_clustering,
|
|
31
|
+
hits,
|
|
32
|
+
kmeans,
|
|
33
|
+
kmedoids,
|
|
34
|
+
naive_bayes,
|
|
35
|
+
olap,
|
|
36
|
+
pagerank,
|
|
37
|
+
preprocessing,
|
|
38
|
+
sql,
|
|
39
|
+
star_schema,
|
|
40
|
+
)
|
|
41
|
+
from .experiments import list as list # noqa: A001 (snsl.list(), as requested)
|
|
42
|
+
from .plotting import (
|
|
43
|
+
barplot,
|
|
44
|
+
boxplot,
|
|
45
|
+
countplot,
|
|
46
|
+
heatmap,
|
|
47
|
+
histplot,
|
|
48
|
+
pairplot,
|
|
49
|
+
scatterplot,
|
|
50
|
+
set_theme,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
__version__ = "0.1.0"
|
|
54
|
+
|
|
55
|
+
__all__ = [
|
|
56
|
+
"datasets",
|
|
57
|
+
"dwm",
|
|
58
|
+
"experiments",
|
|
59
|
+
"plotting",
|
|
60
|
+
"set_theme",
|
|
61
|
+
"histplot",
|
|
62
|
+
"countplot",
|
|
63
|
+
"barplot",
|
|
64
|
+
"boxplot",
|
|
65
|
+
"scatterplot",
|
|
66
|
+
"heatmap",
|
|
67
|
+
"pairplot",
|
|
68
|
+
"sql",
|
|
69
|
+
"star_schema",
|
|
70
|
+
"olap",
|
|
71
|
+
"preprocessing",
|
|
72
|
+
"data_preprocessing",
|
|
73
|
+
"apriori",
|
|
74
|
+
"appriori",
|
|
75
|
+
"kmeans",
|
|
76
|
+
"kmedoids",
|
|
77
|
+
"hierarchical",
|
|
78
|
+
"hierarchical_clustering",
|
|
79
|
+
"naive_bayes",
|
|
80
|
+
"categorical_naive_bayes",
|
|
81
|
+
"gaussian_naive_bayes",
|
|
82
|
+
"pagerank",
|
|
83
|
+
"hits",
|
|
84
|
+
"all_experiments",
|
|
85
|
+
]
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""Command line entry point: ``seaborn-lite``."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
|
|
6
|
+
from . import __version__, datasets
|
|
7
|
+
from .demos import DEMOS, run_demo
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def main(argv=None) -> int:
|
|
11
|
+
parser = argparse.ArgumentParser(
|
|
12
|
+
prog="seaborn-lite",
|
|
13
|
+
description="Run the DWM practical-exam demos on bundled datasets.",
|
|
14
|
+
)
|
|
15
|
+
parser.add_argument("--version", action="version", version=f"seaborn-lite {__version__}")
|
|
16
|
+
sub = parser.add_subparsers(dest="command")
|
|
17
|
+
|
|
18
|
+
sub.add_parser("list", help="list available demos")
|
|
19
|
+
sub.add_parser("datasets", help="list bundled datasets")
|
|
20
|
+
|
|
21
|
+
run = sub.add_parser("run", help="run one demo")
|
|
22
|
+
run.add_argument("demo", choices=sorted(DEMOS), help="demo name")
|
|
23
|
+
run.add_argument("--data", help="path to a CSV (defaults to the bundled dataset)")
|
|
24
|
+
run.add_argument("--out", help="output directory or file for plots")
|
|
25
|
+
|
|
26
|
+
args = parser.parse_args(argv)
|
|
27
|
+
|
|
28
|
+
if args.command == "list":
|
|
29
|
+
print("Available demos:")
|
|
30
|
+
for name in sorted(DEMOS):
|
|
31
|
+
print(f" {name}")
|
|
32
|
+
return 0
|
|
33
|
+
|
|
34
|
+
if args.command == "datasets":
|
|
35
|
+
print("Bundled datasets:")
|
|
36
|
+
for name in datasets.available():
|
|
37
|
+
print(f" {name}")
|
|
38
|
+
return 0
|
|
39
|
+
|
|
40
|
+
if args.command == "run":
|
|
41
|
+
run_demo(args.demo, data=args.data, out=args.out)
|
|
42
|
+
return 0
|
|
43
|
+
|
|
44
|
+
parser.print_help()
|
|
45
|
+
return 0
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
if __name__ == "__main__":
|
|
49
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""Bundled sample datasets, loadable by short name."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
import pandas as pd
|
|
7
|
+
|
|
8
|
+
_DATA_DIR = Path(__file__).parent
|
|
9
|
+
|
|
10
|
+
__all__ = ["available", "path", "load"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def available() -> list[str]:
|
|
14
|
+
"""Names of every bundled dataset, without the ``.csv`` suffix."""
|
|
15
|
+
return sorted(p.stem for p in _DATA_DIR.glob("*.csv"))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def path(name: str) -> Path:
|
|
19
|
+
"""Absolute path of a bundled dataset; ``name`` may include ``.csv``."""
|
|
20
|
+
filename = name if name.endswith(".csv") else f"{name}.csv"
|
|
21
|
+
candidate = _DATA_DIR / filename
|
|
22
|
+
if not candidate.is_file():
|
|
23
|
+
raise FileNotFoundError(
|
|
24
|
+
f"Dataset {name!r} not found. Available: {', '.join(available())}"
|
|
25
|
+
)
|
|
26
|
+
return candidate
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def load(name: str, **kwargs) -> pd.DataFrame:
|
|
30
|
+
"""Read a bundled dataset into a DataFrame (extra kwargs go to read_csv)."""
|
|
31
|
+
return pd.read_csv(path(name), **kwargs)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
RID,Age_Group,Income,Student,Credit_Rating,Buy_Computer
|
|
2
|
+
1,Youth,High,No,Fair,No
|
|
3
|
+
2,Youth,High,No,Excellent,No
|
|
4
|
+
3,Middle_Aged,High,No,Fair,Yes
|
|
5
|
+
4,Senior,Medium,No,Fair,Yes
|
|
6
|
+
5,Senior,Low,Yes,Fair,Yes
|
|
7
|
+
6,Senior,Low,Yes,Excellent,No
|
|
8
|
+
7,Middle_Aged,Low,Yes,Excellent,Yes
|
|
9
|
+
8,Youth,Medium,No,Fair,No
|
|
10
|
+
9,Youth,Low,Yes,Fair,Yes
|
|
11
|
+
10,Senior,Medium,Yes,Fair,Yes
|
|
12
|
+
11,Youth,Medium,Yes,Excellent,Yes
|
|
13
|
+
12,Middle_Aged,Medium,No,Excellent,Yes
|
|
14
|
+
13,Middle_Aged,High,Yes,Fair,Yes
|
|
15
|
+
14,Senior,Medium,No,Excellent,No
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
CustomerID,Age,Tenure_Months,Monthly_Charges,Contract_Type,Payment_Method,Churn
|
|
2
|
+
CUST_0001,25.0,12.0,50.5,Month-to-month,Electronic check,No
|
|
3
|
+
CUST_0002,30.0,24.0,70.0,One year,Mailed check,No
|
|
4
|
+
CUST_0003,,36.0,85.2,Two year,Bank transfer,Yes
|
|
5
|
+
CUST_0004,45.0,,110.0,Month-to-month,Credit card,No
|
|
6
|
+
CUST_0005,22.0,6.0,,,Electronic check,Yes
|
|
7
|
+
CUST_0006,19.0,1.0,20.0,Month-to-month,Electronic check,Yes
|
|
8
|
+
CUST_0007,58.0,48.0,95.0,Two year,Mailed check,No
|
|
9
|
+
CUST_0008,62.0,60.0,105.0,One year,Bank transfer,No
|
|
10
|
+
CUST_0009,120.0,2.0,999.0,Month-to-month,Credit card,Yes
|
|
11
|
+
CUST_0010,28.0,18.0,45.0,One year,Electronic check,No
|
|
12
|
+
CUST_0011,35.0,20.0,65.0,Month-to-month,Electronic check,No
|
|
13
|
+
CUST_0012,42.0,,75.0,One year,Mailed check,No
|
|
14
|
+
CUST_0013,,5.0,80.0,Two year,Bank transfer,Yes
|
|
15
|
+
CUST_0014,31.0,14.0,,Month-to-month,Credit card,No
|
|
16
|
+
CUST_0015,29.0,28.0,55.0,,Electronic check,Yes
|
|
17
|
+
CUST_0016,25.0,12.0,50.5,Month-to-month,Electronic check,Yes
|
|
18
|
+
CUST_0017,30.0,24.0,70.0,Two year,Mailed check,No
|
|
19
|
+
CUST_0018,,36.0,85.2,One year,Bank transfer,No
|
|
20
|
+
CUST_0019,45.0,,110.0,Month-to-month,Credit card,Yes
|
|
21
|
+
CUST_0020,22.0,6.0,,One year,Electronic check,No
|
|
22
|
+
CUST_0021,19.0,1.0,20.0,Month-to-month,Electronic check,No
|
|
23
|
+
CUST_0022,58.0,48.0,95.0,One year,Mailed check,No
|
|
24
|
+
CUST_0023,62.0,60.0,105.0,Two year,Bank transfer,Yes
|
|
25
|
+
CUST_0024,120.0,2.0,999.0,Month-to-month,Credit card,No
|
|
26
|
+
CUST_0025,28.0,18.0,45.0,,Electronic check,Yes
|
|
27
|
+
CUST_0026,35.0,20.0,65.0,Month-to-month,Electronic check,Yes
|
|
28
|
+
CUST_0027,42.0,,75.0,Two year,Mailed check,No
|
|
29
|
+
CUST_0028,,5.0,80.0,One year,Bank transfer,No
|
|
30
|
+
CUST_0029,31.0,14.0,,Month-to-month,Credit card,Yes
|
|
31
|
+
CUST_0030,29.0,28.0,55.0,One year,Electronic check,No
|
|
32
|
+
CUST_0031,25.0,12.0,50.5,Month-to-month,Electronic check,No
|
|
33
|
+
CUST_0032,30.0,24.0,70.0,One year,Mailed check,No
|
|
34
|
+
CUST_0033,,36.0,85.2,Two year,Bank transfer,Yes
|
|
35
|
+
CUST_0034,45.0,,110.0,Month-to-month,Credit card,No
|
|
36
|
+
CUST_0035,22.0,6.0,,,Electronic check,Yes
|
|
37
|
+
CUST_0036,19.0,1.0,20.0,Month-to-month,Electronic check,Yes
|
|
38
|
+
CUST_0037,58.0,48.0,95.0,Two year,Mailed check,No
|
|
39
|
+
CUST_0038,62.0,60.0,105.0,One year,Bank transfer,No
|
|
40
|
+
CUST_0039,120.0,2.0,999.0,Month-to-month,Credit card,Yes
|
|
41
|
+
CUST_0040,28.0,18.0,45.0,One year,Electronic check,No
|
|
42
|
+
CUST_0041,35.0,20.0,65.0,Month-to-month,Electronic check,No
|
|
43
|
+
CUST_0042,42.0,,75.0,One year,Mailed check,No
|
|
44
|
+
CUST_0043,,5.0,80.0,Two year,Bank transfer,Yes
|
|
45
|
+
CUST_0044,31.0,14.0,,Month-to-month,Credit card,No
|
|
46
|
+
CUST_0045,29.0,28.0,55.0,,Electronic check,Yes
|
|
47
|
+
CUST_0046,25.0,12.0,50.5,Month-to-month,Electronic check,Yes
|
|
48
|
+
CUST_0047,30.0,24.0,70.0,Two year,Mailed check,No
|
|
49
|
+
CUST_0048,,36.0,85.2,One year,Bank transfer,No
|
|
50
|
+
CUST_0049,45.0,,110.0,Month-to-month,Credit card,Yes
|
|
51
|
+
CUST_0050,22.0,6.0,,One year,Electronic check,No
|
|
52
|
+
CUST_0051,19.0,1.0,20.0,Month-to-month,Electronic check,No
|
|
53
|
+
CUST_0052,58.0,48.0,95.0,One year,Mailed check,No
|
|
54
|
+
CUST_0053,62.0,60.0,105.0,Two year,Bank transfer,Yes
|
|
55
|
+
CUST_0054,120.0,2.0,999.0,Month-to-month,Credit card,No
|
|
56
|
+
CUST_0055,28.0,18.0,45.0,,Electronic check,Yes
|
|
57
|
+
CUST_0056,35.0,20.0,65.0,Month-to-month,Electronic check,Yes
|
|
58
|
+
CUST_0057,42.0,,75.0,Two year,Mailed check,No
|
|
59
|
+
CUST_0058,,5.0,80.0,One year,Bank transfer,No
|
|
60
|
+
CUST_0059,31.0,14.0,,Month-to-month,Credit card,Yes
|
|
61
|
+
CUST_0060,29.0,28.0,55.0,One year,Electronic check,No
|
|
62
|
+
CUST_0061,25.0,12.0,50.5,Month-to-month,Electronic check,No
|
|
63
|
+
CUST_0062,30.0,24.0,70.0,One year,Mailed check,No
|
|
64
|
+
CUST_0063,,36.0,85.2,Two year,Bank transfer,Yes
|
|
65
|
+
CUST_0064,45.0,,110.0,Month-to-month,Credit card,No
|
|
66
|
+
CUST_0065,22.0,6.0,,,Electronic check,Yes
|
|
67
|
+
CUST_0066,19.0,1.0,20.0,Month-to-month,Electronic check,Yes
|
|
68
|
+
CUST_0067,58.0,48.0,95.0,Two year,Mailed check,No
|
|
69
|
+
CUST_0068,62.0,60.0,105.0,One year,Bank transfer,No
|
|
70
|
+
CUST_0069,120.0,2.0,999.0,Month-to-month,Credit card,Yes
|
|
71
|
+
CUST_0070,28.0,18.0,45.0,One year,Electronic check,No
|
|
72
|
+
CUST_0071,35.0,20.0,65.0,Month-to-month,Electronic check,No
|
|
73
|
+
CUST_0072,42.0,,75.0,One year,Mailed check,No
|
|
74
|
+
CUST_0073,,5.0,80.0,Two year,Bank transfer,Yes
|
|
75
|
+
CUST_0074,31.0,14.0,,Month-to-month,Credit card,No
|
|
76
|
+
CUST_0075,29.0,28.0,55.0,,Electronic check,Yes
|
|
77
|
+
CUST_0076,25.0,12.0,50.5,Month-to-month,Electronic check,Yes
|
|
78
|
+
CUST_0077,30.0,24.0,70.0,Two year,Mailed check,No
|
|
79
|
+
CUST_0078,,36.0,85.2,One year,Bank transfer,No
|
|
80
|
+
CUST_0079,45.0,,110.0,Month-to-month,Credit card,Yes
|
|
81
|
+
CUST_0080,22.0,6.0,,One year,Electronic check,No
|
|
82
|
+
CUST_0081,19.0,1.0,20.0,Month-to-month,Electronic check,No
|
|
83
|
+
CUST_0082,58.0,48.0,95.0,One year,Mailed check,No
|
|
84
|
+
CUST_0083,62.0,60.0,105.0,Two year,Bank transfer,Yes
|
|
85
|
+
CUST_0084,120.0,2.0,999.0,Month-to-month,Credit card,No
|
|
86
|
+
CUST_0085,28.0,18.0,45.0,,Electronic check,Yes
|
|
87
|
+
CUST_0086,35.0,20.0,65.0,Month-to-month,Electronic check,Yes
|
|
88
|
+
CUST_0087,42.0,,75.0,Two year,Mailed check,No
|
|
89
|
+
CUST_0088,,5.0,80.0,One year,Bank transfer,No
|
|
90
|
+
CUST_0089,31.0,14.0,,Month-to-month,Credit card,Yes
|
|
91
|
+
CUST_0090,29.0,28.0,55.0,One year,Electronic check,No
|
|
92
|
+
CUST_0091,25.0,10.0,45.0,Month-to-month,Electronic check,No
|
|
93
|
+
CUST_0092,30.0,12.0,55.0,One year,Mailed check,No
|
|
94
|
+
CUST_0093,45.0,15.0,65.0,Two year,Bank transfer,Yes
|
|
95
|
+
CUST_0094,50.0,20.0,75.0,Month-to-month,Credit card,No
|
|
96
|
+
CUST_0095,22.0,25.0,85.0,,Electronic check,Yes
|
|
97
|
+
CUST_0096,29.0,30.0,95.0,Month-to-month,Electronic check,Yes
|
|
98
|
+
CUST_0097,31.0,35.0,60.0,Two year,Mailed check,No
|
|
99
|
+
CUST_0098,40.0,40.0,70.0,One year,Bank transfer,No
|
|
100
|
+
CUST_0099,38.0,45.0,80.0,Month-to-month,Credit card,Yes
|
|
101
|
+
CUST_0100,36.0,50.0,90.0,One year,Electronic check,No
|
|
102
|
+
CUST_0001,25.0,12.0,50.5,Month-to-month,Electronic check,No
|
|
103
|
+
CUST_0002,30.0,24.0,70.0,One year,Mailed check,No
|
|
104
|
+
CUST_0006,19.0,1.0,20.0,Month-to-month,Electronic check,Yes
|
|
105
|
+
CUST_0013,,5.0,80.0,Two year,Bank transfer,Yes
|