Skip to content

Commit 8c799b8

Browse files
committed
examples: Add wine dataset
1 parent 9015978 commit 8c799b8

5 files changed

Lines changed: 33 additions & 0 deletions

File tree

examples/datasets/wine/X_test.npy

2.41 KB
Binary file not shown.

examples/datasets/wine/X_train.npy

6.88 KB
Binary file not shown.

examples/datasets/wine/prepare.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
import os.path
3+
4+
import numpy as np
5+
from sklearn.datasets import load_wine
6+
from sklearn.model_selection import train_test_split
7+
from sklearn.preprocessing import StandardScaler
8+
9+
def main():
10+
11+
here = os.path.dirname(__file__)
12+
out_dir = here
13+
14+
wine = load_wine()
15+
X = wine.data.astype(np.float32)
16+
y = wine.target.astype(np.float32)
17+
18+
scaler = StandardScaler()
19+
X = scaler.fit_transform(X).astype(np.float32)
20+
21+
X_train, X_test, y_train, y_test = train_test_split(
22+
X, y, test_size=0.25, random_state=42, stratify=y
23+
)
24+
25+
np.save(os.path.join(out_dir, 'X_train.npy'), X_train)
26+
np.save(os.path.join(out_dir, 'X_test.npy'), X_test)
27+
np.save(os.path.join(out_dir, 'y_train.npy'), y_train)
28+
np.save(os.path.join(out_dir, 'y_test.npy'), y_test)
29+
30+
print('Wrote to', out_dir)
31+
32+
if __name__ == '__main__':
33+
main()

examples/datasets/wine/y_test.npy

308 Bytes
Binary file not shown.

examples/datasets/wine/y_train.npy

660 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)