Upload 8 files
Browse files- .gitattributes +1 -0
- supplementary/Readme.md +1 -0
- supplementary/appendix.pdf +3 -0
- supplementary/code/Readme.md +3 -0
- supplementary/code/classification_cnn.ipynb +208 -0
- supplementary/code/classification_lstm.ipynb +191 -0
- supplementary/code/classification_mlp.ipynb +512 -0
- supplementary/code/classification_rf.ipynb +91 -0
- supplementary/code/classification_svm.ipynb +506 -0
.gitattributes
CHANGED
@@ -57,3 +57,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
57 |
# Video files - compressed
|
58 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
59 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
|
|
|
57 |
# Video files - compressed
|
58 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
59 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
60 |
+
supplementary/appendix.pdf filter=lfs diff=lfs merge=lfs -text
|
supplementary/Readme.md
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Supplementary materials for paper: BasketHAR: A Multimodal Dataset for Human Activity Recognition and Sport Analysis in Basketball Training Scenarios.
|
supplementary/appendix.pdf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:02bb974950f4defcf9c8c6df2f82d6e33c2bcc0e3feb14066ccc8ce74ad50309
|
3 |
+
size 575918
|
supplementary/code/Readme.md
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
Code for paper: BasketHAR: A Multimodal Dataset for Human Activity Recognition and Sport Analysis in Basketball Training Scenarios.
|
2 |
+
|
3 |
+
The multimodal method can be implemented using [Imagebind-LoRA](https://github.com/fabawi/ImageBind-LoRA).
|
supplementary/code/classification_cnn.ipynb
ADDED
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 81,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"import numpy as np\n",
|
10 |
+
"import torch\n",
|
11 |
+
"import torch.nn as nn\n",
|
12 |
+
"import torch.optim as optim\n",
|
13 |
+
"from sklearn.model_selection import train_test_split\n",
|
14 |
+
"from sklearn.preprocessing import LabelEncoder\n",
|
15 |
+
"from torch.utils.data import DataLoader, TensorDataset"
|
16 |
+
]
|
17 |
+
},
|
18 |
+
{
|
19 |
+
"cell_type": "code",
|
20 |
+
"execution_count": 82,
|
21 |
+
"metadata": {},
|
22 |
+
"outputs": [],
|
23 |
+
"source": [
|
24 |
+
"X = np.load('./signal_X.npy') \n",
|
25 |
+
"y = np.load('./signal_y.npy') \n",
|
26 |
+
"\n",
|
27 |
+
"X = X[:, :, :]\n",
|
28 |
+
"\n",
|
29 |
+
"\n",
|
30 |
+
"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42, stratify=y)"
|
31 |
+
]
|
32 |
+
},
|
33 |
+
{
|
34 |
+
"cell_type": "code",
|
35 |
+
"execution_count": 85,
|
36 |
+
"metadata": {},
|
37 |
+
"outputs": [],
|
38 |
+
"source": [
|
39 |
+
"X_train = X_train.transpose(0, 2, 1).reshape(-1, 12, 1, 200) \n",
|
40 |
+
"X_test = X_test.transpose(0, 2, 1).reshape(-1, 12, 1, 200)\n",
|
41 |
+
"\n",
|
42 |
+
"\n",
|
43 |
+
"torch_X_train = torch.tensor(X_train, dtype=torch.float32)\n",
|
44 |
+
"torch_y_train = torch.tensor(y_train, dtype=torch.long)\n",
|
45 |
+
"torch_X_test = torch.tensor(X_test, dtype=torch.float32)\n",
|
46 |
+
"torch_y_test = torch.tensor(y_test, dtype=torch.long)\n"
|
47 |
+
]
|
48 |
+
},
|
49 |
+
{
|
50 |
+
"cell_type": "code",
|
51 |
+
"execution_count": 87,
|
52 |
+
"metadata": {},
|
53 |
+
"outputs": [],
|
54 |
+
"source": [
|
55 |
+
"batch_size = 16384\n",
|
56 |
+
"train_dataset = TensorDataset(torch_X_train, torch_y_train)\n",
|
57 |
+
"test_dataset = TensorDataset(torch_X_test, torch_y_test)\n",
|
58 |
+
"train_loader = DataLoader(train_dataset, batch_size=batch_size, shuffle=True)\n",
|
59 |
+
"test_loader = DataLoader(test_dataset, batch_size=2828, shuffle=False)"
|
60 |
+
]
|
61 |
+
},
|
62 |
+
{
|
63 |
+
"cell_type": "code",
|
64 |
+
"execution_count": 88,
|
65 |
+
"metadata": {},
|
66 |
+
"outputs": [],
|
67 |
+
"source": [
|
68 |
+
"class CNN(nn.Module):\n",
|
69 |
+
" def __init__(self, num_classes):\n",
|
70 |
+
" super(CNN, self).__init__()\n",
|
71 |
+
" self.conv1 = nn.Conv2d(12, 32, kernel_size=(1, 3), padding=(0, 1))\n",
|
72 |
+
" self.pool1 = nn.MaxPool2d(kernel_size=(1, 2))\n",
|
73 |
+
" self.bn1 = nn.BatchNorm2d(32)\n",
|
74 |
+
" self.conv2 = nn.Conv2d(32, 64, kernel_size=(1, 3), padding=(0, 1))\n",
|
75 |
+
" self.pool2 = nn.MaxPool2d(kernel_size=(1, 2))\n",
|
76 |
+
" self.bn2 = nn.BatchNorm2d(64)\n",
|
77 |
+
" self.flatten = nn.Flatten()\n",
|
78 |
+
" # self.dropout = nn.Dropout(0.5)\n",
|
79 |
+
" self.fc1 = nn.Linear(64 * 1 * 50, 128) \n",
|
80 |
+
" self.fc2 = nn.Linear(128, num_classes)\n",
|
81 |
+
" self.bn3 = nn.BatchNorm1d(128) \n",
|
82 |
+
" self._initialize_weights()\n",
|
83 |
+
"\n",
|
84 |
+
" def _initialize_weights(self):\n",
|
85 |
+
" for m in self.modules():\n",
|
86 |
+
" if isinstance(m, nn.Conv2d) or isinstance(m, nn.Linear):\n",
|
87 |
+
" nn.init.xavier_uniform_(m.weight)\n",
|
88 |
+
" if m.bias is not None:\n",
|
89 |
+
" nn.init.constant_(m.bias, 0)\n",
|
90 |
+
" \n",
|
91 |
+
" def forward(self, x):\n",
|
92 |
+
" x = self.pool1(torch.relu(self.bn1(self.conv1(x))))\n",
|
93 |
+
"\n",
|
94 |
+
" x = self.pool2(torch.relu(self.bn2(self.conv2(x))))\n",
|
95 |
+
"\n",
|
96 |
+
" # x = self.dropout(x)\n",
|
97 |
+
" x = self.flatten(x)\n",
|
98 |
+
" x = torch.relu(self.bn3(self.fc1(x)))\n",
|
99 |
+
" x = self.fc2(x)\n",
|
100 |
+
" return x"
|
101 |
+
]
|
102 |
+
},
|
103 |
+
{
|
104 |
+
"cell_type": "code",
|
105 |
+
"execution_count": 90,
|
106 |
+
"metadata": {},
|
107 |
+
"outputs": [],
|
108 |
+
"source": [
|
109 |
+
"model = CNN(14)"
|
110 |
+
]
|
111 |
+
},
|
112 |
+
{
|
113 |
+
"cell_type": "code",
|
114 |
+
"execution_count": 91,
|
115 |
+
"metadata": {},
|
116 |
+
"outputs": [],
|
117 |
+
"source": [
|
118 |
+
"criterion = nn.CrossEntropyLoss()\n",
|
119 |
+
"optimizer = optim.Adam(model.parameters(), lr=0.001, weight_decay=1e-4)\n",
|
120 |
+
"scheduler = optim.lr_scheduler.StepLR(optimizer, step_size=25, gamma=0.9)"
|
121 |
+
]
|
122 |
+
},
|
123 |
+
{
|
124 |
+
"cell_type": "code",
|
125 |
+
"execution_count": null,
|
126 |
+
"metadata": {},
|
127 |
+
"outputs": [],
|
128 |
+
"source": [
|
129 |
+
"epochs = 100\n",
|
130 |
+
"model.to('cuda:1')\n",
|
131 |
+
"for epoch in range(epochs):\n",
|
132 |
+
" model.train()\n",
|
133 |
+
" running_loss = 0.0\n",
|
134 |
+
" for inputs, labels in train_loader:\n",
|
135 |
+
" inputs = inputs.float().to('cuda:1') \n",
|
136 |
+
" optimizer.zero_grad()\n",
|
137 |
+
" outputs = model(inputs).to('cpu')\n",
|
138 |
+
" _, predicted = torch.max(outputs, 1)\n",
|
139 |
+
" # print(accuracy_score(labels, predicted))\n",
|
140 |
+
" loss = criterion(outputs, labels)\n",
|
141 |
+
" loss.backward()\n",
|
142 |
+
" optimizer.step()\n",
|
143 |
+
" running_loss += loss.item()\n",
|
144 |
+
" scheduler.step() \n",
|
145 |
+
" print(f\"Epoch {epoch + 1}/{epochs}, Loss: {running_loss / len(train_loader):.4f}\")"
|
146 |
+
]
|
147 |
+
},
|
148 |
+
{
|
149 |
+
"cell_type": "code",
|
150 |
+
"execution_count": null,
|
151 |
+
"metadata": {},
|
152 |
+
"outputs": [],
|
153 |
+
"source": [
|
154 |
+
"model.eval()\n",
|
155 |
+
"correct = 0\n",
|
156 |
+
"total = 0\n",
|
157 |
+
"with torch.no_grad():\n",
|
158 |
+
" for inputs, labels in test_loader:\n",
|
159 |
+
" outputs = model(inputs.to('cuda:1')).to('cpu')\n",
|
160 |
+
" _, predicted = torch.max(outputs, 1)\n",
|
161 |
+
" total += labels.size(0)\n",
|
162 |
+
" correct += (predicted == labels).sum().item()\n",
|
163 |
+
"\n",
|
164 |
+
"accuracy = correct / total\n",
|
165 |
+
"print(f\"Test Accuracy: {accuracy:.4f}\")"
|
166 |
+
]
|
167 |
+
},
|
168 |
+
{
|
169 |
+
"cell_type": "code",
|
170 |
+
"execution_count": 95,
|
171 |
+
"metadata": {},
|
172 |
+
"outputs": [],
|
173 |
+
"source": [
|
174 |
+
"from sklearn.metrics import classification_report, accuracy_score, confusion_matrix"
|
175 |
+
]
|
176 |
+
},
|
177 |
+
{
|
178 |
+
"cell_type": "code",
|
179 |
+
"execution_count": null,
|
180 |
+
"metadata": {},
|
181 |
+
"outputs": [],
|
182 |
+
"source": [
|
183 |
+
"print(classification_report(y_test, predicted))"
|
184 |
+
]
|
185 |
+
}
|
186 |
+
],
|
187 |
+
"metadata": {
|
188 |
+
"kernelspec": {
|
189 |
+
"display_name": "imu",
|
190 |
+
"language": "python",
|
191 |
+
"name": "python3"
|
192 |
+
},
|
193 |
+
"language_info": {
|
194 |
+
"codemirror_mode": {
|
195 |
+
"name": "ipython",
|
196 |
+
"version": 3
|
197 |
+
},
|
198 |
+
"file_extension": ".py",
|
199 |
+
"mimetype": "text/x-python",
|
200 |
+
"name": "python",
|
201 |
+
"nbconvert_exporter": "python",
|
202 |
+
"pygments_lexer": "ipython3",
|
203 |
+
"version": "3.9.19"
|
204 |
+
}
|
205 |
+
},
|
206 |
+
"nbformat": 4,
|
207 |
+
"nbformat_minor": 2
|
208 |
+
}
|
supplementary/code/classification_lstm.ipynb
ADDED
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 112,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"import torch\n",
|
10 |
+
"import torch.nn as nn\n",
|
11 |
+
"import torch.optim as optim\n",
|
12 |
+
"import numpy as np\n",
|
13 |
+
"from sklearn.model_selection import train_test_split\n",
|
14 |
+
"from sklearn.preprocessing import LabelEncoder\n",
|
15 |
+
"from torch.utils.data import DataLoader, TensorDataset"
|
16 |
+
]
|
17 |
+
},
|
18 |
+
{
|
19 |
+
"cell_type": "code",
|
20 |
+
"execution_count": 113,
|
21 |
+
"metadata": {},
|
22 |
+
"outputs": [],
|
23 |
+
"source": [
|
24 |
+
"X = np.load('./signal_X.npy') \n",
|
25 |
+
"y = np.load('./signal_y.npy') "
|
26 |
+
]
|
27 |
+
},
|
28 |
+
{
|
29 |
+
"cell_type": "code",
|
30 |
+
"execution_count": 114,
|
31 |
+
"metadata": {},
|
32 |
+
"outputs": [],
|
33 |
+
"source": [
|
34 |
+
"X = torch.tensor(X, dtype=torch.float32)\n",
|
35 |
+
"y = torch.tensor(y, dtype=torch.long)"
|
36 |
+
]
|
37 |
+
},
|
38 |
+
{
|
39 |
+
"cell_type": "code",
|
40 |
+
"execution_count": 115,
|
41 |
+
"metadata": {},
|
42 |
+
"outputs": [],
|
43 |
+
"source": [
|
44 |
+
"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42, stratify=y)"
|
45 |
+
]
|
46 |
+
},
|
47 |
+
{
|
48 |
+
"cell_type": "code",
|
49 |
+
"execution_count": 116,
|
50 |
+
"metadata": {},
|
51 |
+
"outputs": [],
|
52 |
+
"source": [
|
53 |
+
"batch_size = 2048\n",
|
54 |
+
"train_dataset = TensorDataset(X_train, y_train)\n",
|
55 |
+
"test_dataset = TensorDataset(X_test, y_test)\n",
|
56 |
+
"train_loader = DataLoader(train_dataset, batch_size=batch_size, shuffle=True)\n",
|
57 |
+
"test_loader = DataLoader(test_dataset, batch_size=16384, shuffle=False)\n"
|
58 |
+
]
|
59 |
+
},
|
60 |
+
{
|
61 |
+
"cell_type": "code",
|
62 |
+
"execution_count": 117,
|
63 |
+
"metadata": {},
|
64 |
+
"outputs": [],
|
65 |
+
"source": [
|
66 |
+
"class LSTMClassifier(nn.Module):\n",
|
67 |
+
" def __init__(self, input_size, hidden_size, num_layers, num_classes, dropout=0.3):\n",
|
68 |
+
" super(LSTMClassifier, self).__init__()\n",
|
69 |
+
" self.lstm = nn.LSTM(input_size, hidden_size, num_layers, batch_first=True, dropout=dropout)\n",
|
70 |
+
" self.fc = nn.Linear(hidden_size, num_classes)\n",
|
71 |
+
" self.dropout = nn.Dropout(dropout)\n",
|
72 |
+
"\n",
|
73 |
+
" def forward(self, x):\n",
|
74 |
+
" out, _ = self.lstm(x)\n",
|
75 |
+
" out = out[:, -1, :]\n",
|
76 |
+
" out = self.fc(self.dropout(out))\n",
|
77 |
+
" return out"
|
78 |
+
]
|
79 |
+
},
|
80 |
+
{
|
81 |
+
"cell_type": "code",
|
82 |
+
"execution_count": 118,
|
83 |
+
"metadata": {},
|
84 |
+
"outputs": [],
|
85 |
+
"source": [
|
86 |
+
"input_size = 12 \n",
|
87 |
+
"hidden_size = 128 \n",
|
88 |
+
"num_layers = 3 \n",
|
89 |
+
"num_classes = 14 "
|
90 |
+
]
|
91 |
+
},
|
92 |
+
{
|
93 |
+
"cell_type": "code",
|
94 |
+
"execution_count": 119,
|
95 |
+
"metadata": {},
|
96 |
+
"outputs": [],
|
97 |
+
"source": [
|
98 |
+
"model = LSTMClassifier(input_size, hidden_size, num_layers, num_classes)\n",
|
99 |
+
"\n",
|
100 |
+
"criterion = nn.CrossEntropyLoss()\n",
|
101 |
+
"optimizer = optim.Adam(model.parameters(), lr=0.001, weight_decay=1e-4)\n",
|
102 |
+
"scheduler = optim.lr_scheduler.StepLR(optimizer, step_size=5, gamma=0.9)\n",
|
103 |
+
"\n",
|
104 |
+
"device = torch.device('cuda:3' if torch.cuda.is_available() else 'cpu')\n",
|
105 |
+
"model = model.to(device)"
|
106 |
+
]
|
107 |
+
},
|
108 |
+
{
|
109 |
+
"cell_type": "code",
|
110 |
+
"execution_count": null,
|
111 |
+
"metadata": {},
|
112 |
+
"outputs": [],
|
113 |
+
"source": [
|
114 |
+
"num_epochs = 100\n",
|
115 |
+
"for epoch in range(num_epochs):\n",
|
116 |
+
" model.train()\n",
|
117 |
+
" total_loss = 0\n",
|
118 |
+
" for batch_X, batch_y in train_loader:\n",
|
119 |
+
" batch_X, batch_y = batch_X.to(device), batch_y.to(device)\n",
|
120 |
+
"\n",
|
121 |
+
" outputs = model(batch_X)\n",
|
122 |
+
" loss = criterion(outputs, batch_y)\n",
|
123 |
+
" \n",
|
124 |
+
" optimizer.zero_grad()\n",
|
125 |
+
" loss.backward()\n",
|
126 |
+
" optimizer.step()\n",
|
127 |
+
" \n",
|
128 |
+
" total_loss += loss.item()\n",
|
129 |
+
" scheduler.step()\n",
|
130 |
+
" print(f\"Epoch {epoch + 1}/{num_epochs}, Loss: {total_loss / len(train_loader):.4f}\")"
|
131 |
+
]
|
132 |
+
},
|
133 |
+
{
|
134 |
+
"cell_type": "code",
|
135 |
+
"execution_count": null,
|
136 |
+
"metadata": {},
|
137 |
+
"outputs": [],
|
138 |
+
"source": [
|
139 |
+
"model.eval()\n",
|
140 |
+
"with torch.no_grad():\n",
|
141 |
+
" correct = 0\n",
|
142 |
+
" total = 0\n",
|
143 |
+
" for batch_X, batch_y in test_loader:\n",
|
144 |
+
" batch_X, batch_y = batch_X.to(device), batch_y.to(device)\n",
|
145 |
+
" outputs = model(batch_X)\n",
|
146 |
+
" _, predicted = torch.max(outputs.data, 1)\n",
|
147 |
+
" total += batch_y.size(0)\n",
|
148 |
+
" correct += (predicted == batch_y).sum().item()"
|
149 |
+
]
|
150 |
+
},
|
151 |
+
{
|
152 |
+
"cell_type": "code",
|
153 |
+
"execution_count": null,
|
154 |
+
"metadata": {},
|
155 |
+
"outputs": [],
|
156 |
+
"source": [
|
157 |
+
"from sklearn.metrics import classification_report, accuracy_score, confusion_matrix"
|
158 |
+
]
|
159 |
+
},
|
160 |
+
{
|
161 |
+
"cell_type": "code",
|
162 |
+
"execution_count": null,
|
163 |
+
"metadata": {},
|
164 |
+
"outputs": [],
|
165 |
+
"source": [
|
166 |
+
"print(classification_report(y_test, predicted.cpu()))"
|
167 |
+
]
|
168 |
+
}
|
169 |
+
],
|
170 |
+
"metadata": {
|
171 |
+
"kernelspec": {
|
172 |
+
"display_name": "imu",
|
173 |
+
"language": "python",
|
174 |
+
"name": "python3"
|
175 |
+
},
|
176 |
+
"language_info": {
|
177 |
+
"codemirror_mode": {
|
178 |
+
"name": "ipython",
|
179 |
+
"version": 3
|
180 |
+
},
|
181 |
+
"file_extension": ".py",
|
182 |
+
"mimetype": "text/x-python",
|
183 |
+
"name": "python",
|
184 |
+
"nbconvert_exporter": "python",
|
185 |
+
"pygments_lexer": "ipython3",
|
186 |
+
"version": "3.9.19"
|
187 |
+
}
|
188 |
+
},
|
189 |
+
"nbformat": 4,
|
190 |
+
"nbformat_minor": 2
|
191 |
+
}
|
supplementary/code/classification_mlp.ipynb
ADDED
@@ -0,0 +1,512 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"import numpy as np\n",
|
10 |
+
"from sklearn.model_selection import train_test_split\n",
|
11 |
+
"from sklearn.ensemble import RandomForestClassifier\n",
|
12 |
+
"import matplotlib.pyplot as plt\n",
|
13 |
+
"from sklearn.metrics import classification_report, accuracy_score, confusion_matrix, ConfusionMatrixDisplay\n",
|
14 |
+
"import numpy as np\n",
|
15 |
+
"from sklearn.model_selection import train_test_split\n",
|
16 |
+
"from sklearn.svm import SVC\n",
|
17 |
+
"from sklearn.metrics import classification_report, accuracy_score\n",
|
18 |
+
"from sklearn.preprocessing import StandardScaler\n",
|
19 |
+
"import numpy as np\n",
|
20 |
+
"from sklearn.model_selection import train_test_split\n",
|
21 |
+
"from sklearn.neural_network import MLPClassifier\n",
|
22 |
+
"from sklearn.metrics import classification_report, accuracy_score\n",
|
23 |
+
"from sklearn.preprocessing import StandardScaler"
|
24 |
+
]
|
25 |
+
},
|
26 |
+
{
|
27 |
+
"cell_type": "code",
|
28 |
+
"execution_count": 2,
|
29 |
+
"metadata": {},
|
30 |
+
"outputs": [],
|
31 |
+
"source": [
|
32 |
+
"data = np.load('./signal_X.npy') \n",
|
33 |
+
"labels = np.load('./signal_y.npy') \n",
|
34 |
+
"\n",
|
35 |
+
"\n",
|
36 |
+
"data_flattened = data.reshape(data.shape[0], -1)"
|
37 |
+
]
|
38 |
+
},
|
39 |
+
{
|
40 |
+
"cell_type": "code",
|
41 |
+
"execution_count": 123,
|
42 |
+
"metadata": {},
|
43 |
+
"outputs": [
|
44 |
+
{
|
45 |
+
"data": {
|
46 |
+
"text/html": [
|
47 |
+
"<style>#sk-container-id-6 {\n",
|
48 |
+
" /* Definition of color scheme common for light and dark mode */\n",
|
49 |
+
" --sklearn-color-text: black;\n",
|
50 |
+
" --sklearn-color-line: gray;\n",
|
51 |
+
" /* Definition of color scheme for unfitted estimators */\n",
|
52 |
+
" --sklearn-color-unfitted-level-0: #fff5e6;\n",
|
53 |
+
" --sklearn-color-unfitted-level-1: #f6e4d2;\n",
|
54 |
+
" --sklearn-color-unfitted-level-2: #ffe0b3;\n",
|
55 |
+
" --sklearn-color-unfitted-level-3: chocolate;\n",
|
56 |
+
" /* Definition of color scheme for fitted estimators */\n",
|
57 |
+
" --sklearn-color-fitted-level-0: #f0f8ff;\n",
|
58 |
+
" --sklearn-color-fitted-level-1: #d4ebff;\n",
|
59 |
+
" --sklearn-color-fitted-level-2: #b3dbfd;\n",
|
60 |
+
" --sklearn-color-fitted-level-3: cornflowerblue;\n",
|
61 |
+
"\n",
|
62 |
+
" /* Specific color for light theme */\n",
|
63 |
+
" --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
|
64 |
+
" --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, white)));\n",
|
65 |
+
" --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
|
66 |
+
" --sklearn-color-icon: #696969;\n",
|
67 |
+
"\n",
|
68 |
+
" @media (prefers-color-scheme: dark) {\n",
|
69 |
+
" /* Redefinition of color scheme for dark theme */\n",
|
70 |
+
" --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
|
71 |
+
" --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, #111)));\n",
|
72 |
+
" --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
|
73 |
+
" --sklearn-color-icon: #878787;\n",
|
74 |
+
" }\n",
|
75 |
+
"}\n",
|
76 |
+
"\n",
|
77 |
+
"#sk-container-id-6 {\n",
|
78 |
+
" color: var(--sklearn-color-text);\n",
|
79 |
+
"}\n",
|
80 |
+
"\n",
|
81 |
+
"#sk-container-id-6 pre {\n",
|
82 |
+
" padding: 0;\n",
|
83 |
+
"}\n",
|
84 |
+
"\n",
|
85 |
+
"#sk-container-id-6 input.sk-hidden--visually {\n",
|
86 |
+
" border: 0;\n",
|
87 |
+
" clip: rect(1px 1px 1px 1px);\n",
|
88 |
+
" clip: rect(1px, 1px, 1px, 1px);\n",
|
89 |
+
" height: 1px;\n",
|
90 |
+
" margin: -1px;\n",
|
91 |
+
" overflow: hidden;\n",
|
92 |
+
" padding: 0;\n",
|
93 |
+
" position: absolute;\n",
|
94 |
+
" width: 1px;\n",
|
95 |
+
"}\n",
|
96 |
+
"\n",
|
97 |
+
"#sk-container-id-6 div.sk-dashed-wrapped {\n",
|
98 |
+
" border: 1px dashed var(--sklearn-color-line);\n",
|
99 |
+
" margin: 0 0.4em 0.5em 0.4em;\n",
|
100 |
+
" box-sizing: border-box;\n",
|
101 |
+
" padding-bottom: 0.4em;\n",
|
102 |
+
" background-color: var(--sklearn-color-background);\n",
|
103 |
+
"}\n",
|
104 |
+
"\n",
|
105 |
+
"#sk-container-id-6 div.sk-container {\n",
|
106 |
+
" /* jupyter's `normalize.less` sets `[hidden] { display: none; }`\n",
|
107 |
+
" but bootstrap.min.css set `[hidden] { display: none !important; }`\n",
|
108 |
+
" so we also need the `!important` here to be able to override the\n",
|
109 |
+
" default hidden behavior on the sphinx rendered scikit-learn.org.\n",
|
110 |
+
" See: https://github.com/scikit-learn/scikit-learn/issues/21755 */\n",
|
111 |
+
" display: inline-block !important;\n",
|
112 |
+
" position: relative;\n",
|
113 |
+
"}\n",
|
114 |
+
"\n",
|
115 |
+
"#sk-container-id-6 div.sk-text-repr-fallback {\n",
|
116 |
+
" display: none;\n",
|
117 |
+
"}\n",
|
118 |
+
"\n",
|
119 |
+
"div.sk-parallel-item,\n",
|
120 |
+
"div.sk-serial,\n",
|
121 |
+
"div.sk-item {\n",
|
122 |
+
" /* draw centered vertical line to link estimators */\n",
|
123 |
+
" background-image: linear-gradient(var(--sklearn-color-text-on-default-background), var(--sklearn-color-text-on-default-background));\n",
|
124 |
+
" background-size: 2px 100%;\n",
|
125 |
+
" background-repeat: no-repeat;\n",
|
126 |
+
" background-position: center center;\n",
|
127 |
+
"}\n",
|
128 |
+
"\n",
|
129 |
+
"/* Parallel-specific style estimator block */\n",
|
130 |
+
"\n",
|
131 |
+
"#sk-container-id-6 div.sk-parallel-item::after {\n",
|
132 |
+
" content: \"\";\n",
|
133 |
+
" width: 100%;\n",
|
134 |
+
" border-bottom: 2px solid var(--sklearn-color-text-on-default-background);\n",
|
135 |
+
" flex-grow: 1;\n",
|
136 |
+
"}\n",
|
137 |
+
"\n",
|
138 |
+
"#sk-container-id-6 div.sk-parallel {\n",
|
139 |
+
" display: flex;\n",
|
140 |
+
" align-items: stretch;\n",
|
141 |
+
" justify-content: center;\n",
|
142 |
+
" background-color: var(--sklearn-color-background);\n",
|
143 |
+
" position: relative;\n",
|
144 |
+
"}\n",
|
145 |
+
"\n",
|
146 |
+
"#sk-container-id-6 div.sk-parallel-item {\n",
|
147 |
+
" display: flex;\n",
|
148 |
+
" flex-direction: column;\n",
|
149 |
+
"}\n",
|
150 |
+
"\n",
|
151 |
+
"#sk-container-id-6 div.sk-parallel-item:first-child::after {\n",
|
152 |
+
" align-self: flex-end;\n",
|
153 |
+
" width: 50%;\n",
|
154 |
+
"}\n",
|
155 |
+
"\n",
|
156 |
+
"#sk-container-id-6 div.sk-parallel-item:last-child::after {\n",
|
157 |
+
" align-self: flex-start;\n",
|
158 |
+
" width: 50%;\n",
|
159 |
+
"}\n",
|
160 |
+
"\n",
|
161 |
+
"#sk-container-id-6 div.sk-parallel-item:only-child::after {\n",
|
162 |
+
" width: 0;\n",
|
163 |
+
"}\n",
|
164 |
+
"\n",
|
165 |
+
"/* Serial-specific style estimator block */\n",
|
166 |
+
"\n",
|
167 |
+
"#sk-container-id-6 div.sk-serial {\n",
|
168 |
+
" display: flex;\n",
|
169 |
+
" flex-direction: column;\n",
|
170 |
+
" align-items: center;\n",
|
171 |
+
" background-color: var(--sklearn-color-background);\n",
|
172 |
+
" padding-right: 1em;\n",
|
173 |
+
" padding-left: 1em;\n",
|
174 |
+
"}\n",
|
175 |
+
"\n",
|
176 |
+
"\n",
|
177 |
+
"/* Toggleable style: style used for estimator/Pipeline/ColumnTransformer box that is\n",
|
178 |
+
"clickable and can be expanded/collapsed.\n",
|
179 |
+
"- Pipeline and ColumnTransformer use this feature and define the default style\n",
|
180 |
+
"- Estimators will overwrite some part of the style using the `sk-estimator` class\n",
|
181 |
+
"*/\n",
|
182 |
+
"\n",
|
183 |
+
"/* Pipeline and ColumnTransformer style (default) */\n",
|
184 |
+
"\n",
|
185 |
+
"#sk-container-id-6 div.sk-toggleable {\n",
|
186 |
+
" /* Default theme specific background. It is overwritten whether we have a\n",
|
187 |
+
" specific estimator or a Pipeline/ColumnTransformer */\n",
|
188 |
+
" background-color: var(--sklearn-color-background);\n",
|
189 |
+
"}\n",
|
190 |
+
"\n",
|
191 |
+
"/* Toggleable label */\n",
|
192 |
+
"#sk-container-id-6 label.sk-toggleable__label {\n",
|
193 |
+
" cursor: pointer;\n",
|
194 |
+
" display: block;\n",
|
195 |
+
" width: 100%;\n",
|
196 |
+
" margin-bottom: 0;\n",
|
197 |
+
" padding: 0.5em;\n",
|
198 |
+
" box-sizing: border-box;\n",
|
199 |
+
" text-align: center;\n",
|
200 |
+
"}\n",
|
201 |
+
"\n",
|
202 |
+
"#sk-container-id-6 label.sk-toggleable__label-arrow:before {\n",
|
203 |
+
" /* Arrow on the left of the label */\n",
|
204 |
+
" content: \"▸\";\n",
|
205 |
+
" float: left;\n",
|
206 |
+
" margin-right: 0.25em;\n",
|
207 |
+
" color: var(--sklearn-color-icon);\n",
|
208 |
+
"}\n",
|
209 |
+
"\n",
|
210 |
+
"#sk-container-id-6 label.sk-toggleable__label-arrow:hover:before {\n",
|
211 |
+
" color: var(--sklearn-color-text);\n",
|
212 |
+
"}\n",
|
213 |
+
"\n",
|
214 |
+
"/* Toggleable content - dropdown */\n",
|
215 |
+
"\n",
|
216 |
+
"#sk-container-id-6 div.sk-toggleable__content {\n",
|
217 |
+
" max-height: 0;\n",
|
218 |
+
" max-width: 0;\n",
|
219 |
+
" overflow: hidden;\n",
|
220 |
+
" text-align: left;\n",
|
221 |
+
" /* unfitted */\n",
|
222 |
+
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
223 |
+
"}\n",
|
224 |
+
"\n",
|
225 |
+
"#sk-container-id-6 div.sk-toggleable__content.fitted {\n",
|
226 |
+
" /* fitted */\n",
|
227 |
+
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
228 |
+
"}\n",
|
229 |
+
"\n",
|
230 |
+
"#sk-container-id-6 div.sk-toggleable__content pre {\n",
|
231 |
+
" margin: 0.2em;\n",
|
232 |
+
" border-radius: 0.25em;\n",
|
233 |
+
" color: var(--sklearn-color-text);\n",
|
234 |
+
" /* unfitted */\n",
|
235 |
+
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
236 |
+
"}\n",
|
237 |
+
"\n",
|
238 |
+
"#sk-container-id-6 div.sk-toggleable__content.fitted pre {\n",
|
239 |
+
" /* unfitted */\n",
|
240 |
+
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
241 |
+
"}\n",
|
242 |
+
"\n",
|
243 |
+
"#sk-container-id-6 input.sk-toggleable__control:checked~div.sk-toggleable__content {\n",
|
244 |
+
" /* Expand drop-down */\n",
|
245 |
+
" max-height: 200px;\n",
|
246 |
+
" max-width: 100%;\n",
|
247 |
+
" overflow: auto;\n",
|
248 |
+
"}\n",
|
249 |
+
"\n",
|
250 |
+
"#sk-container-id-6 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {\n",
|
251 |
+
" content: \"▾\";\n",
|
252 |
+
"}\n",
|
253 |
+
"\n",
|
254 |
+
"/* Pipeline/ColumnTransformer-specific style */\n",
|
255 |
+
"\n",
|
256 |
+
"#sk-container-id-6 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
257 |
+
" color: var(--sklearn-color-text);\n",
|
258 |
+
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
259 |
+
"}\n",
|
260 |
+
"\n",
|
261 |
+
"#sk-container-id-6 div.sk-label.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
262 |
+
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
263 |
+
"}\n",
|
264 |
+
"\n",
|
265 |
+
"/* Estimator-specific style */\n",
|
266 |
+
"\n",
|
267 |
+
"/* Colorize estimator box */\n",
|
268 |
+
"#sk-container-id-6 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
269 |
+
" /* unfitted */\n",
|
270 |
+
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
271 |
+
"}\n",
|
272 |
+
"\n",
|
273 |
+
"#sk-container-id-6 div.sk-estimator.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
274 |
+
" /* fitted */\n",
|
275 |
+
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
276 |
+
"}\n",
|
277 |
+
"\n",
|
278 |
+
"#sk-container-id-6 div.sk-label label.sk-toggleable__label,\n",
|
279 |
+
"#sk-container-id-6 div.sk-label label {\n",
|
280 |
+
" /* The background is the default theme color */\n",
|
281 |
+
" color: var(--sklearn-color-text-on-default-background);\n",
|
282 |
+
"}\n",
|
283 |
+
"\n",
|
284 |
+
"/* On hover, darken the color of the background */\n",
|
285 |
+
"#sk-container-id-6 div.sk-label:hover label.sk-toggleable__label {\n",
|
286 |
+
" color: var(--sklearn-color-text);\n",
|
287 |
+
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
288 |
+
"}\n",
|
289 |
+
"\n",
|
290 |
+
"/* Label box, darken color on hover, fitted */\n",
|
291 |
+
"#sk-container-id-6 div.sk-label.fitted:hover label.sk-toggleable__label.fitted {\n",
|
292 |
+
" color: var(--sklearn-color-text);\n",
|
293 |
+
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
294 |
+
"}\n",
|
295 |
+
"\n",
|
296 |
+
"/* Estimator label */\n",
|
297 |
+
"\n",
|
298 |
+
"#sk-container-id-6 div.sk-label label {\n",
|
299 |
+
" font-family: monospace;\n",
|
300 |
+
" font-weight: bold;\n",
|
301 |
+
" display: inline-block;\n",
|
302 |
+
" line-height: 1.2em;\n",
|
303 |
+
"}\n",
|
304 |
+
"\n",
|
305 |
+
"#sk-container-id-6 div.sk-label-container {\n",
|
306 |
+
" text-align: center;\n",
|
307 |
+
"}\n",
|
308 |
+
"\n",
|
309 |
+
"/* Estimator-specific */\n",
|
310 |
+
"#sk-container-id-6 div.sk-estimator {\n",
|
311 |
+
" font-family: monospace;\n",
|
312 |
+
" border: 1px dotted var(--sklearn-color-border-box);\n",
|
313 |
+
" border-radius: 0.25em;\n",
|
314 |
+
" box-sizing: border-box;\n",
|
315 |
+
" margin-bottom: 0.5em;\n",
|
316 |
+
" /* unfitted */\n",
|
317 |
+
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
318 |
+
"}\n",
|
319 |
+
"\n",
|
320 |
+
"#sk-container-id-6 div.sk-estimator.fitted {\n",
|
321 |
+
" /* fitted */\n",
|
322 |
+
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
323 |
+
"}\n",
|
324 |
+
"\n",
|
325 |
+
"/* on hover */\n",
|
326 |
+
"#sk-container-id-6 div.sk-estimator:hover {\n",
|
327 |
+
" /* unfitted */\n",
|
328 |
+
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
329 |
+
"}\n",
|
330 |
+
"\n",
|
331 |
+
"#sk-container-id-6 div.sk-estimator.fitted:hover {\n",
|
332 |
+
" /* fitted */\n",
|
333 |
+
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
334 |
+
"}\n",
|
335 |
+
"\n",
|
336 |
+
"/* Specification for estimator info (e.g. \"i\" and \"?\") */\n",
|
337 |
+
"\n",
|
338 |
+
"/* Common style for \"i\" and \"?\" */\n",
|
339 |
+
"\n",
|
340 |
+
".sk-estimator-doc-link,\n",
|
341 |
+
"a:link.sk-estimator-doc-link,\n",
|
342 |
+
"a:visited.sk-estimator-doc-link {\n",
|
343 |
+
" float: right;\n",
|
344 |
+
" font-size: smaller;\n",
|
345 |
+
" line-height: 1em;\n",
|
346 |
+
" font-family: monospace;\n",
|
347 |
+
" background-color: var(--sklearn-color-background);\n",
|
348 |
+
" border-radius: 1em;\n",
|
349 |
+
" height: 1em;\n",
|
350 |
+
" width: 1em;\n",
|
351 |
+
" text-decoration: none !important;\n",
|
352 |
+
" margin-left: 1ex;\n",
|
353 |
+
" /* unfitted */\n",
|
354 |
+
" border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
|
355 |
+
" color: var(--sklearn-color-unfitted-level-1);\n",
|
356 |
+
"}\n",
|
357 |
+
"\n",
|
358 |
+
".sk-estimator-doc-link.fitted,\n",
|
359 |
+
"a:link.sk-estimator-doc-link.fitted,\n",
|
360 |
+
"a:visited.sk-estimator-doc-link.fitted {\n",
|
361 |
+
" /* fitted */\n",
|
362 |
+
" border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
|
363 |
+
" color: var(--sklearn-color-fitted-level-1);\n",
|
364 |
+
"}\n",
|
365 |
+
"\n",
|
366 |
+
"/* On hover */\n",
|
367 |
+
"div.sk-estimator:hover .sk-estimator-doc-link:hover,\n",
|
368 |
+
".sk-estimator-doc-link:hover,\n",
|
369 |
+
"div.sk-label-container:hover .sk-estimator-doc-link:hover,\n",
|
370 |
+
".sk-estimator-doc-link:hover {\n",
|
371 |
+
" /* unfitted */\n",
|
372 |
+
" background-color: var(--sklearn-color-unfitted-level-3);\n",
|
373 |
+
" color: var(--sklearn-color-background);\n",
|
374 |
+
" text-decoration: none;\n",
|
375 |
+
"}\n",
|
376 |
+
"\n",
|
377 |
+
"div.sk-estimator.fitted:hover .sk-estimator-doc-link.fitted:hover,\n",
|
378 |
+
".sk-estimator-doc-link.fitted:hover,\n",
|
379 |
+
"div.sk-label-container:hover .sk-estimator-doc-link.fitted:hover,\n",
|
380 |
+
".sk-estimator-doc-link.fitted:hover {\n",
|
381 |
+
" /* fitted */\n",
|
382 |
+
" background-color: var(--sklearn-color-fitted-level-3);\n",
|
383 |
+
" color: var(--sklearn-color-background);\n",
|
384 |
+
" text-decoration: none;\n",
|
385 |
+
"}\n",
|
386 |
+
"\n",
|
387 |
+
"/* Span, style for the box shown on hovering the info icon */\n",
|
388 |
+
".sk-estimator-doc-link span {\n",
|
389 |
+
" display: none;\n",
|
390 |
+
" z-index: 9999;\n",
|
391 |
+
" position: relative;\n",
|
392 |
+
" font-weight: normal;\n",
|
393 |
+
" right: .2ex;\n",
|
394 |
+
" padding: .5ex;\n",
|
395 |
+
" margin: .5ex;\n",
|
396 |
+
" width: min-content;\n",
|
397 |
+
" min-width: 20ex;\n",
|
398 |
+
" max-width: 50ex;\n",
|
399 |
+
" color: var(--sklearn-color-text);\n",
|
400 |
+
" box-shadow: 2pt 2pt 4pt #999;\n",
|
401 |
+
" /* unfitted */\n",
|
402 |
+
" background: var(--sklearn-color-unfitted-level-0);\n",
|
403 |
+
" border: .5pt solid var(--sklearn-color-unfitted-level-3);\n",
|
404 |
+
"}\n",
|
405 |
+
"\n",
|
406 |
+
".sk-estimator-doc-link.fitted span {\n",
|
407 |
+
" /* fitted */\n",
|
408 |
+
" background: var(--sklearn-color-fitted-level-0);\n",
|
409 |
+
" border: var(--sklearn-color-fitted-level-3);\n",
|
410 |
+
"}\n",
|
411 |
+
"\n",
|
412 |
+
".sk-estimator-doc-link:hover span {\n",
|
413 |
+
" display: block;\n",
|
414 |
+
"}\n",
|
415 |
+
"\n",
|
416 |
+
"/* \"?\"-specific style due to the `<a>` HTML tag */\n",
|
417 |
+
"\n",
|
418 |
+
"#sk-container-id-6 a.estimator_doc_link {\n",
|
419 |
+
" float: right;\n",
|
420 |
+
" font-size: 1rem;\n",
|
421 |
+
" line-height: 1em;\n",
|
422 |
+
" font-family: monospace;\n",
|
423 |
+
" background-color: var(--sklearn-color-background);\n",
|
424 |
+
" border-radius: 1rem;\n",
|
425 |
+
" height: 1rem;\n",
|
426 |
+
" width: 1rem;\n",
|
427 |
+
" text-decoration: none;\n",
|
428 |
+
" /* unfitted */\n",
|
429 |
+
" color: var(--sklearn-color-unfitted-level-1);\n",
|
430 |
+
" border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
|
431 |
+
"}\n",
|
432 |
+
"\n",
|
433 |
+
"#sk-container-id-6 a.estimator_doc_link.fitted {\n",
|
434 |
+
" /* fitted */\n",
|
435 |
+
" border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
|
436 |
+
" color: var(--sklearn-color-fitted-level-1);\n",
|
437 |
+
"}\n",
|
438 |
+
"\n",
|
439 |
+
"/* On hover */\n",
|
440 |
+
"#sk-container-id-6 a.estimator_doc_link:hover {\n",
|
441 |
+
" /* unfitted */\n",
|
442 |
+
" background-color: var(--sklearn-color-unfitted-level-3);\n",
|
443 |
+
" color: var(--sklearn-color-background);\n",
|
444 |
+
" text-decoration: none;\n",
|
445 |
+
"}\n",
|
446 |
+
"\n",
|
447 |
+
"#sk-container-id-6 a.estimator_doc_link.fitted:hover {\n",
|
448 |
+
" /* fitted */\n",
|
449 |
+
" background-color: var(--sklearn-color-fitted-level-3);\n",
|
450 |
+
"}\n",
|
451 |
+
"</style><div id=\"sk-container-id-6\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>MLPClassifier(hidden_layer_sizes=(128, 64), random_state=42)</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator fitted sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-6\" type=\"checkbox\" checked><label for=\"sk-estimator-id-6\" class=\"sk-toggleable__label fitted sk-toggleable__label-arrow fitted\"> MLPClassifier<a class=\"sk-estimator-doc-link fitted\" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.5/modules/generated/sklearn.neural_network.MLPClassifier.html\">?<span>Documentation for MLPClassifier</span></a><span class=\"sk-estimator-doc-link fitted\">i<span>Fitted</span></span></label><div class=\"sk-toggleable__content fitted\"><pre>MLPClassifier(hidden_layer_sizes=(128, 64), random_state=42)</pre></div> </div></div></div></div>"
|
452 |
+
],
|
453 |
+
"text/plain": [
|
454 |
+
"MLPClassifier(hidden_layer_sizes=(128, 64), random_state=42)"
|
455 |
+
]
|
456 |
+
},
|
457 |
+
"execution_count": 123,
|
458 |
+
"metadata": {},
|
459 |
+
"output_type": "execute_result"
|
460 |
+
}
|
461 |
+
],
|
462 |
+
"source": [
|
463 |
+
"scaler = StandardScaler()\n",
|
464 |
+
"data_flattened = scaler.fit_transform(data_flattened)\n",
|
465 |
+
"\n",
|
466 |
+
"X_train, X_test, y_train, y_test = train_test_split(data_flattened, labels, test_size=0.2, random_state=42, stratify=labels)\n",
|
467 |
+
"\n",
|
468 |
+
"mlp_classifier = MLPClassifier(\n",
|
469 |
+
" hidden_layer_sizes=(128, 64), \n",
|
470 |
+
" activation='relu', \n",
|
471 |
+
" solver='adam', \n",
|
472 |
+
" max_iter=200, \n",
|
473 |
+
" random_state=42\n",
|
474 |
+
")\n",
|
475 |
+
"\n",
|
476 |
+
"\n",
|
477 |
+
"mlp_classifier.fit(X_train, y_train)"
|
478 |
+
]
|
479 |
+
},
|
480 |
+
{
|
481 |
+
"cell_type": "code",
|
482 |
+
"execution_count": null,
|
483 |
+
"metadata": {},
|
484 |
+
"outputs": [],
|
485 |
+
"source": [
|
486 |
+
"y_pred = mlp_classifier.predict(X_test)\n",
|
487 |
+
"print(classification_report(y_test, y_pred))"
|
488 |
+
]
|
489 |
+
}
|
490 |
+
],
|
491 |
+
"metadata": {
|
492 |
+
"kernelspec": {
|
493 |
+
"display_name": "imu",
|
494 |
+
"language": "python",
|
495 |
+
"name": "python3"
|
496 |
+
},
|
497 |
+
"language_info": {
|
498 |
+
"codemirror_mode": {
|
499 |
+
"name": "ipython",
|
500 |
+
"version": 3
|
501 |
+
},
|
502 |
+
"file_extension": ".py",
|
503 |
+
"mimetype": "text/x-python",
|
504 |
+
"name": "python",
|
505 |
+
"nbconvert_exporter": "python",
|
506 |
+
"pygments_lexer": "ipython3",
|
507 |
+
"version": "3.9.19"
|
508 |
+
}
|
509 |
+
},
|
510 |
+
"nbformat": 4,
|
511 |
+
"nbformat_minor": 2
|
512 |
+
}
|
supplementary/code/classification_rf.ipynb
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 117,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"import numpy as np\n",
|
10 |
+
"from sklearn.model_selection import train_test_split\n",
|
11 |
+
"from sklearn.ensemble import RandomForestClassifier\n",
|
12 |
+
"import matplotlib.pyplot as plt\n",
|
13 |
+
"from sklearn.metrics import classification_report, accuracy_score, confusion_matrix, ConfusionMatrixDisplay"
|
14 |
+
]
|
15 |
+
},
|
16 |
+
{
|
17 |
+
"cell_type": "code",
|
18 |
+
"execution_count": 118,
|
19 |
+
"metadata": {},
|
20 |
+
"outputs": [],
|
21 |
+
"source": [
|
22 |
+
"from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier, AdaBoostClassifier"
|
23 |
+
]
|
24 |
+
},
|
25 |
+
{
|
26 |
+
"cell_type": "code",
|
27 |
+
"execution_count": 119,
|
28 |
+
"metadata": {},
|
29 |
+
"outputs": [],
|
30 |
+
"source": [
|
31 |
+
"data = np.load('./signal_X.npy') \n",
|
32 |
+
"labels = np.load('./signal_y.npy') "
|
33 |
+
]
|
34 |
+
},
|
35 |
+
{
|
36 |
+
"cell_type": "code",
|
37 |
+
"execution_count": 120,
|
38 |
+
"metadata": {},
|
39 |
+
"outputs": [],
|
40 |
+
"source": [
|
41 |
+
"X_train, X_test, y_train, y_test = train_test_split(data, labels, test_size=0.2, random_state=42, stratify=labels)\n"
|
42 |
+
]
|
43 |
+
},
|
44 |
+
{
|
45 |
+
"cell_type": "code",
|
46 |
+
"execution_count": 122,
|
47 |
+
"metadata": {},
|
48 |
+
"outputs": [],
|
49 |
+
"source": [
|
50 |
+
"X_train = X_train.reshape(X_train.shape[0], -1)\n",
|
51 |
+
"X_test = X_test.reshape(X_test.shape[0], -1)\n",
|
52 |
+
"\n",
|
53 |
+
"classifier = RandomForestClassifier(n_estimators=100, random_state=42)\n",
|
54 |
+
"\n",
|
55 |
+
"classifier.fit(X_train, y_train)\n",
|
56 |
+
"\n",
|
57 |
+
"y_pred = classifier.predict(X_test)"
|
58 |
+
]
|
59 |
+
},
|
60 |
+
{
|
61 |
+
"cell_type": "code",
|
62 |
+
"execution_count": null,
|
63 |
+
"metadata": {},
|
64 |
+
"outputs": [],
|
65 |
+
"source": [
|
66 |
+
"print(classification_report(y_test, y_pred))"
|
67 |
+
]
|
68 |
+
}
|
69 |
+
],
|
70 |
+
"metadata": {
|
71 |
+
"kernelspec": {
|
72 |
+
"display_name": "imu",
|
73 |
+
"language": "python",
|
74 |
+
"name": "python3"
|
75 |
+
},
|
76 |
+
"language_info": {
|
77 |
+
"codemirror_mode": {
|
78 |
+
"name": "ipython",
|
79 |
+
"version": 3
|
80 |
+
},
|
81 |
+
"file_extension": ".py",
|
82 |
+
"mimetype": "text/x-python",
|
83 |
+
"name": "python",
|
84 |
+
"nbconvert_exporter": "python",
|
85 |
+
"pygments_lexer": "ipython3",
|
86 |
+
"version": "3.9.19"
|
87 |
+
}
|
88 |
+
},
|
89 |
+
"nbformat": 4,
|
90 |
+
"nbformat_minor": 2
|
91 |
+
}
|
supplementary/code/classification_svm.ipynb
ADDED
@@ -0,0 +1,506 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 39,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"import numpy as np\n",
|
10 |
+
"from sklearn.model_selection import train_test_split\n",
|
11 |
+
"from sklearn.ensemble import RandomForestClassifier\n",
|
12 |
+
"import matplotlib.pyplot as plt\n",
|
13 |
+
"from sklearn.metrics import classification_report, accuracy_score, confusion_matrix, ConfusionMatrixDisplay\n",
|
14 |
+
"import numpy as np\n",
|
15 |
+
"from sklearn.model_selection import train_test_split\n",
|
16 |
+
"from sklearn.svm import SVC\n",
|
17 |
+
"from sklearn.metrics import classification_report, accuracy_score\n",
|
18 |
+
"from sklearn.preprocessing import StandardScaler"
|
19 |
+
]
|
20 |
+
},
|
21 |
+
{
|
22 |
+
"cell_type": "code",
|
23 |
+
"execution_count": 40,
|
24 |
+
"metadata": {},
|
25 |
+
"outputs": [],
|
26 |
+
"source": [
|
27 |
+
"data = np.load('./signal_X.npy') \n",
|
28 |
+
"labels = np.load('./signal_y.npy') \n",
|
29 |
+
"\n",
|
30 |
+
"data_flattened = data.reshape(data.shape[0], -1)"
|
31 |
+
]
|
32 |
+
},
|
33 |
+
{
|
34 |
+
"cell_type": "code",
|
35 |
+
"execution_count": 41,
|
36 |
+
"metadata": {},
|
37 |
+
"outputs": [
|
38 |
+
{
|
39 |
+
"data": {
|
40 |
+
"text/html": [
|
41 |
+
"<style>#sk-container-id-6 {\n",
|
42 |
+
" /* Definition of color scheme common for light and dark mode */\n",
|
43 |
+
" --sklearn-color-text: black;\n",
|
44 |
+
" --sklearn-color-line: gray;\n",
|
45 |
+
" /* Definition of color scheme for unfitted estimators */\n",
|
46 |
+
" --sklearn-color-unfitted-level-0: #fff5e6;\n",
|
47 |
+
" --sklearn-color-unfitted-level-1: #f6e4d2;\n",
|
48 |
+
" --sklearn-color-unfitted-level-2: #ffe0b3;\n",
|
49 |
+
" --sklearn-color-unfitted-level-3: chocolate;\n",
|
50 |
+
" /* Definition of color scheme for fitted estimators */\n",
|
51 |
+
" --sklearn-color-fitted-level-0: #f0f8ff;\n",
|
52 |
+
" --sklearn-color-fitted-level-1: #d4ebff;\n",
|
53 |
+
" --sklearn-color-fitted-level-2: #b3dbfd;\n",
|
54 |
+
" --sklearn-color-fitted-level-3: cornflowerblue;\n",
|
55 |
+
"\n",
|
56 |
+
" /* Specific color for light theme */\n",
|
57 |
+
" --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
|
58 |
+
" --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, white)));\n",
|
59 |
+
" --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
|
60 |
+
" --sklearn-color-icon: #696969;\n",
|
61 |
+
"\n",
|
62 |
+
" @media (prefers-color-scheme: dark) {\n",
|
63 |
+
" /* Redefinition of color scheme for dark theme */\n",
|
64 |
+
" --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
|
65 |
+
" --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, #111)));\n",
|
66 |
+
" --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
|
67 |
+
" --sklearn-color-icon: #878787;\n",
|
68 |
+
" }\n",
|
69 |
+
"}\n",
|
70 |
+
"\n",
|
71 |
+
"#sk-container-id-6 {\n",
|
72 |
+
" color: var(--sklearn-color-text);\n",
|
73 |
+
"}\n",
|
74 |
+
"\n",
|
75 |
+
"#sk-container-id-6 pre {\n",
|
76 |
+
" padding: 0;\n",
|
77 |
+
"}\n",
|
78 |
+
"\n",
|
79 |
+
"#sk-container-id-6 input.sk-hidden--visually {\n",
|
80 |
+
" border: 0;\n",
|
81 |
+
" clip: rect(1px 1px 1px 1px);\n",
|
82 |
+
" clip: rect(1px, 1px, 1px, 1px);\n",
|
83 |
+
" height: 1px;\n",
|
84 |
+
" margin: -1px;\n",
|
85 |
+
" overflow: hidden;\n",
|
86 |
+
" padding: 0;\n",
|
87 |
+
" position: absolute;\n",
|
88 |
+
" width: 1px;\n",
|
89 |
+
"}\n",
|
90 |
+
"\n",
|
91 |
+
"#sk-container-id-6 div.sk-dashed-wrapped {\n",
|
92 |
+
" border: 1px dashed var(--sklearn-color-line);\n",
|
93 |
+
" margin: 0 0.4em 0.5em 0.4em;\n",
|
94 |
+
" box-sizing: border-box;\n",
|
95 |
+
" padding-bottom: 0.4em;\n",
|
96 |
+
" background-color: var(--sklearn-color-background);\n",
|
97 |
+
"}\n",
|
98 |
+
"\n",
|
99 |
+
"#sk-container-id-6 div.sk-container {\n",
|
100 |
+
" /* jupyter's `normalize.less` sets `[hidden] { display: none; }`\n",
|
101 |
+
" but bootstrap.min.css set `[hidden] { display: none !important; }`\n",
|
102 |
+
" so we also need the `!important` here to be able to override the\n",
|
103 |
+
" default hidden behavior on the sphinx rendered scikit-learn.org.\n",
|
104 |
+
" See: https://github.com/scikit-learn/scikit-learn/issues/21755 */\n",
|
105 |
+
" display: inline-block !important;\n",
|
106 |
+
" position: relative;\n",
|
107 |
+
"}\n",
|
108 |
+
"\n",
|
109 |
+
"#sk-container-id-6 div.sk-text-repr-fallback {\n",
|
110 |
+
" display: none;\n",
|
111 |
+
"}\n",
|
112 |
+
"\n",
|
113 |
+
"div.sk-parallel-item,\n",
|
114 |
+
"div.sk-serial,\n",
|
115 |
+
"div.sk-item {\n",
|
116 |
+
" /* draw centered vertical line to link estimators */\n",
|
117 |
+
" background-image: linear-gradient(var(--sklearn-color-text-on-default-background), var(--sklearn-color-text-on-default-background));\n",
|
118 |
+
" background-size: 2px 100%;\n",
|
119 |
+
" background-repeat: no-repeat;\n",
|
120 |
+
" background-position: center center;\n",
|
121 |
+
"}\n",
|
122 |
+
"\n",
|
123 |
+
"/* Parallel-specific style estimator block */\n",
|
124 |
+
"\n",
|
125 |
+
"#sk-container-id-6 div.sk-parallel-item::after {\n",
|
126 |
+
" content: \"\";\n",
|
127 |
+
" width: 100%;\n",
|
128 |
+
" border-bottom: 2px solid var(--sklearn-color-text-on-default-background);\n",
|
129 |
+
" flex-grow: 1;\n",
|
130 |
+
"}\n",
|
131 |
+
"\n",
|
132 |
+
"#sk-container-id-6 div.sk-parallel {\n",
|
133 |
+
" display: flex;\n",
|
134 |
+
" align-items: stretch;\n",
|
135 |
+
" justify-content: center;\n",
|
136 |
+
" background-color: var(--sklearn-color-background);\n",
|
137 |
+
" position: relative;\n",
|
138 |
+
"}\n",
|
139 |
+
"\n",
|
140 |
+
"#sk-container-id-6 div.sk-parallel-item {\n",
|
141 |
+
" display: flex;\n",
|
142 |
+
" flex-direction: column;\n",
|
143 |
+
"}\n",
|
144 |
+
"\n",
|
145 |
+
"#sk-container-id-6 div.sk-parallel-item:first-child::after {\n",
|
146 |
+
" align-self: flex-end;\n",
|
147 |
+
" width: 50%;\n",
|
148 |
+
"}\n",
|
149 |
+
"\n",
|
150 |
+
"#sk-container-id-6 div.sk-parallel-item:last-child::after {\n",
|
151 |
+
" align-self: flex-start;\n",
|
152 |
+
" width: 50%;\n",
|
153 |
+
"}\n",
|
154 |
+
"\n",
|
155 |
+
"#sk-container-id-6 div.sk-parallel-item:only-child::after {\n",
|
156 |
+
" width: 0;\n",
|
157 |
+
"}\n",
|
158 |
+
"\n",
|
159 |
+
"/* Serial-specific style estimator block */\n",
|
160 |
+
"\n",
|
161 |
+
"#sk-container-id-6 div.sk-serial {\n",
|
162 |
+
" display: flex;\n",
|
163 |
+
" flex-direction: column;\n",
|
164 |
+
" align-items: center;\n",
|
165 |
+
" background-color: var(--sklearn-color-background);\n",
|
166 |
+
" padding-right: 1em;\n",
|
167 |
+
" padding-left: 1em;\n",
|
168 |
+
"}\n",
|
169 |
+
"\n",
|
170 |
+
"\n",
|
171 |
+
"/* Toggleable style: style used for estimator/Pipeline/ColumnTransformer box that is\n",
|
172 |
+
"clickable and can be expanded/collapsed.\n",
|
173 |
+
"- Pipeline and ColumnTransformer use this feature and define the default style\n",
|
174 |
+
"- Estimators will overwrite some part of the style using the `sk-estimator` class\n",
|
175 |
+
"*/\n",
|
176 |
+
"\n",
|
177 |
+
"/* Pipeline and ColumnTransformer style (default) */\n",
|
178 |
+
"\n",
|
179 |
+
"#sk-container-id-6 div.sk-toggleable {\n",
|
180 |
+
" /* Default theme specific background. It is overwritten whether we have a\n",
|
181 |
+
" specific estimator or a Pipeline/ColumnTransformer */\n",
|
182 |
+
" background-color: var(--sklearn-color-background);\n",
|
183 |
+
"}\n",
|
184 |
+
"\n",
|
185 |
+
"/* Toggleable label */\n",
|
186 |
+
"#sk-container-id-6 label.sk-toggleable__label {\n",
|
187 |
+
" cursor: pointer;\n",
|
188 |
+
" display: block;\n",
|
189 |
+
" width: 100%;\n",
|
190 |
+
" margin-bottom: 0;\n",
|
191 |
+
" padding: 0.5em;\n",
|
192 |
+
" box-sizing: border-box;\n",
|
193 |
+
" text-align: center;\n",
|
194 |
+
"}\n",
|
195 |
+
"\n",
|
196 |
+
"#sk-container-id-6 label.sk-toggleable__label-arrow:before {\n",
|
197 |
+
" /* Arrow on the left of the label */\n",
|
198 |
+
" content: \"▸\";\n",
|
199 |
+
" float: left;\n",
|
200 |
+
" margin-right: 0.25em;\n",
|
201 |
+
" color: var(--sklearn-color-icon);\n",
|
202 |
+
"}\n",
|
203 |
+
"\n",
|
204 |
+
"#sk-container-id-6 label.sk-toggleable__label-arrow:hover:before {\n",
|
205 |
+
" color: var(--sklearn-color-text);\n",
|
206 |
+
"}\n",
|
207 |
+
"\n",
|
208 |
+
"/* Toggleable content - dropdown */\n",
|
209 |
+
"\n",
|
210 |
+
"#sk-container-id-6 div.sk-toggleable__content {\n",
|
211 |
+
" max-height: 0;\n",
|
212 |
+
" max-width: 0;\n",
|
213 |
+
" overflow: hidden;\n",
|
214 |
+
" text-align: left;\n",
|
215 |
+
" /* unfitted */\n",
|
216 |
+
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
217 |
+
"}\n",
|
218 |
+
"\n",
|
219 |
+
"#sk-container-id-6 div.sk-toggleable__content.fitted {\n",
|
220 |
+
" /* fitted */\n",
|
221 |
+
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
222 |
+
"}\n",
|
223 |
+
"\n",
|
224 |
+
"#sk-container-id-6 div.sk-toggleable__content pre {\n",
|
225 |
+
" margin: 0.2em;\n",
|
226 |
+
" border-radius: 0.25em;\n",
|
227 |
+
" color: var(--sklearn-color-text);\n",
|
228 |
+
" /* unfitted */\n",
|
229 |
+
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
230 |
+
"}\n",
|
231 |
+
"\n",
|
232 |
+
"#sk-container-id-6 div.sk-toggleable__content.fitted pre {\n",
|
233 |
+
" /* unfitted */\n",
|
234 |
+
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
235 |
+
"}\n",
|
236 |
+
"\n",
|
237 |
+
"#sk-container-id-6 input.sk-toggleable__control:checked~div.sk-toggleable__content {\n",
|
238 |
+
" /* Expand drop-down */\n",
|
239 |
+
" max-height: 200px;\n",
|
240 |
+
" max-width: 100%;\n",
|
241 |
+
" overflow: auto;\n",
|
242 |
+
"}\n",
|
243 |
+
"\n",
|
244 |
+
"#sk-container-id-6 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {\n",
|
245 |
+
" content: \"▾\";\n",
|
246 |
+
"}\n",
|
247 |
+
"\n",
|
248 |
+
"/* Pipeline/ColumnTransformer-specific style */\n",
|
249 |
+
"\n",
|
250 |
+
"#sk-container-id-6 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
251 |
+
" color: var(--sklearn-color-text);\n",
|
252 |
+
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
253 |
+
"}\n",
|
254 |
+
"\n",
|
255 |
+
"#sk-container-id-6 div.sk-label.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
256 |
+
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
257 |
+
"}\n",
|
258 |
+
"\n",
|
259 |
+
"/* Estimator-specific style */\n",
|
260 |
+
"\n",
|
261 |
+
"/* Colorize estimator box */\n",
|
262 |
+
"#sk-container-id-6 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
263 |
+
" /* unfitted */\n",
|
264 |
+
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
265 |
+
"}\n",
|
266 |
+
"\n",
|
267 |
+
"#sk-container-id-6 div.sk-estimator.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
268 |
+
" /* fitted */\n",
|
269 |
+
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
270 |
+
"}\n",
|
271 |
+
"\n",
|
272 |
+
"#sk-container-id-6 div.sk-label label.sk-toggleable__label,\n",
|
273 |
+
"#sk-container-id-6 div.sk-label label {\n",
|
274 |
+
" /* The background is the default theme color */\n",
|
275 |
+
" color: var(--sklearn-color-text-on-default-background);\n",
|
276 |
+
"}\n",
|
277 |
+
"\n",
|
278 |
+
"/* On hover, darken the color of the background */\n",
|
279 |
+
"#sk-container-id-6 div.sk-label:hover label.sk-toggleable__label {\n",
|
280 |
+
" color: var(--sklearn-color-text);\n",
|
281 |
+
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
282 |
+
"}\n",
|
283 |
+
"\n",
|
284 |
+
"/* Label box, darken color on hover, fitted */\n",
|
285 |
+
"#sk-container-id-6 div.sk-label.fitted:hover label.sk-toggleable__label.fitted {\n",
|
286 |
+
" color: var(--sklearn-color-text);\n",
|
287 |
+
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
288 |
+
"}\n",
|
289 |
+
"\n",
|
290 |
+
"/* Estimator label */\n",
|
291 |
+
"\n",
|
292 |
+
"#sk-container-id-6 div.sk-label label {\n",
|
293 |
+
" font-family: monospace;\n",
|
294 |
+
" font-weight: bold;\n",
|
295 |
+
" display: inline-block;\n",
|
296 |
+
" line-height: 1.2em;\n",
|
297 |
+
"}\n",
|
298 |
+
"\n",
|
299 |
+
"#sk-container-id-6 div.sk-label-container {\n",
|
300 |
+
" text-align: center;\n",
|
301 |
+
"}\n",
|
302 |
+
"\n",
|
303 |
+
"/* Estimator-specific */\n",
|
304 |
+
"#sk-container-id-6 div.sk-estimator {\n",
|
305 |
+
" font-family: monospace;\n",
|
306 |
+
" border: 1px dotted var(--sklearn-color-border-box);\n",
|
307 |
+
" border-radius: 0.25em;\n",
|
308 |
+
" box-sizing: border-box;\n",
|
309 |
+
" margin-bottom: 0.5em;\n",
|
310 |
+
" /* unfitted */\n",
|
311 |
+
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
312 |
+
"}\n",
|
313 |
+
"\n",
|
314 |
+
"#sk-container-id-6 div.sk-estimator.fitted {\n",
|
315 |
+
" /* fitted */\n",
|
316 |
+
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
317 |
+
"}\n",
|
318 |
+
"\n",
|
319 |
+
"/* on hover */\n",
|
320 |
+
"#sk-container-id-6 div.sk-estimator:hover {\n",
|
321 |
+
" /* unfitted */\n",
|
322 |
+
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
323 |
+
"}\n",
|
324 |
+
"\n",
|
325 |
+
"#sk-container-id-6 div.sk-estimator.fitted:hover {\n",
|
326 |
+
" /* fitted */\n",
|
327 |
+
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
328 |
+
"}\n",
|
329 |
+
"\n",
|
330 |
+
"/* Specification for estimator info (e.g. \"i\" and \"?\") */\n",
|
331 |
+
"\n",
|
332 |
+
"/* Common style for \"i\" and \"?\" */\n",
|
333 |
+
"\n",
|
334 |
+
".sk-estimator-doc-link,\n",
|
335 |
+
"a:link.sk-estimator-doc-link,\n",
|
336 |
+
"a:visited.sk-estimator-doc-link {\n",
|
337 |
+
" float: right;\n",
|
338 |
+
" font-size: smaller;\n",
|
339 |
+
" line-height: 1em;\n",
|
340 |
+
" font-family: monospace;\n",
|
341 |
+
" background-color: var(--sklearn-color-background);\n",
|
342 |
+
" border-radius: 1em;\n",
|
343 |
+
" height: 1em;\n",
|
344 |
+
" width: 1em;\n",
|
345 |
+
" text-decoration: none !important;\n",
|
346 |
+
" margin-left: 1ex;\n",
|
347 |
+
" /* unfitted */\n",
|
348 |
+
" border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
|
349 |
+
" color: var(--sklearn-color-unfitted-level-1);\n",
|
350 |
+
"}\n",
|
351 |
+
"\n",
|
352 |
+
".sk-estimator-doc-link.fitted,\n",
|
353 |
+
"a:link.sk-estimator-doc-link.fitted,\n",
|
354 |
+
"a:visited.sk-estimator-doc-link.fitted {\n",
|
355 |
+
" /* fitted */\n",
|
356 |
+
" border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
|
357 |
+
" color: var(--sklearn-color-fitted-level-1);\n",
|
358 |
+
"}\n",
|
359 |
+
"\n",
|
360 |
+
"/* On hover */\n",
|
361 |
+
"div.sk-estimator:hover .sk-estimator-doc-link:hover,\n",
|
362 |
+
".sk-estimator-doc-link:hover,\n",
|
363 |
+
"div.sk-label-container:hover .sk-estimator-doc-link:hover,\n",
|
364 |
+
".sk-estimator-doc-link:hover {\n",
|
365 |
+
" /* unfitted */\n",
|
366 |
+
" background-color: var(--sklearn-color-unfitted-level-3);\n",
|
367 |
+
" color: var(--sklearn-color-background);\n",
|
368 |
+
" text-decoration: none;\n",
|
369 |
+
"}\n",
|
370 |
+
"\n",
|
371 |
+
"div.sk-estimator.fitted:hover .sk-estimator-doc-link.fitted:hover,\n",
|
372 |
+
".sk-estimator-doc-link.fitted:hover,\n",
|
373 |
+
"div.sk-label-container:hover .sk-estimator-doc-link.fitted:hover,\n",
|
374 |
+
".sk-estimator-doc-link.fitted:hover {\n",
|
375 |
+
" /* fitted */\n",
|
376 |
+
" background-color: var(--sklearn-color-fitted-level-3);\n",
|
377 |
+
" color: var(--sklearn-color-background);\n",
|
378 |
+
" text-decoration: none;\n",
|
379 |
+
"}\n",
|
380 |
+
"\n",
|
381 |
+
"/* Span, style for the box shown on hovering the info icon */\n",
|
382 |
+
".sk-estimator-doc-link span {\n",
|
383 |
+
" display: none;\n",
|
384 |
+
" z-index: 9999;\n",
|
385 |
+
" position: relative;\n",
|
386 |
+
" font-weight: normal;\n",
|
387 |
+
" right: .2ex;\n",
|
388 |
+
" padding: .5ex;\n",
|
389 |
+
" margin: .5ex;\n",
|
390 |
+
" width: min-content;\n",
|
391 |
+
" min-width: 20ex;\n",
|
392 |
+
" max-width: 50ex;\n",
|
393 |
+
" color: var(--sklearn-color-text);\n",
|
394 |
+
" box-shadow: 2pt 2pt 4pt #999;\n",
|
395 |
+
" /* unfitted */\n",
|
396 |
+
" background: var(--sklearn-color-unfitted-level-0);\n",
|
397 |
+
" border: .5pt solid var(--sklearn-color-unfitted-level-3);\n",
|
398 |
+
"}\n",
|
399 |
+
"\n",
|
400 |
+
".sk-estimator-doc-link.fitted span {\n",
|
401 |
+
" /* fitted */\n",
|
402 |
+
" background: var(--sklearn-color-fitted-level-0);\n",
|
403 |
+
" border: var(--sklearn-color-fitted-level-3);\n",
|
404 |
+
"}\n",
|
405 |
+
"\n",
|
406 |
+
".sk-estimator-doc-link:hover span {\n",
|
407 |
+
" display: block;\n",
|
408 |
+
"}\n",
|
409 |
+
"\n",
|
410 |
+
"/* \"?\"-specific style due to the `<a>` HTML tag */\n",
|
411 |
+
"\n",
|
412 |
+
"#sk-container-id-6 a.estimator_doc_link {\n",
|
413 |
+
" float: right;\n",
|
414 |
+
" font-size: 1rem;\n",
|
415 |
+
" line-height: 1em;\n",
|
416 |
+
" font-family: monospace;\n",
|
417 |
+
" background-color: var(--sklearn-color-background);\n",
|
418 |
+
" border-radius: 1rem;\n",
|
419 |
+
" height: 1rem;\n",
|
420 |
+
" width: 1rem;\n",
|
421 |
+
" text-decoration: none;\n",
|
422 |
+
" /* unfitted */\n",
|
423 |
+
" color: var(--sklearn-color-unfitted-level-1);\n",
|
424 |
+
" border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
|
425 |
+
"}\n",
|
426 |
+
"\n",
|
427 |
+
"#sk-container-id-6 a.estimator_doc_link.fitted {\n",
|
428 |
+
" /* fitted */\n",
|
429 |
+
" border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
|
430 |
+
" color: var(--sklearn-color-fitted-level-1);\n",
|
431 |
+
"}\n",
|
432 |
+
"\n",
|
433 |
+
"/* On hover */\n",
|
434 |
+
"#sk-container-id-6 a.estimator_doc_link:hover {\n",
|
435 |
+
" /* unfitted */\n",
|
436 |
+
" background-color: var(--sklearn-color-unfitted-level-3);\n",
|
437 |
+
" color: var(--sklearn-color-background);\n",
|
438 |
+
" text-decoration: none;\n",
|
439 |
+
"}\n",
|
440 |
+
"\n",
|
441 |
+
"#sk-container-id-6 a.estimator_doc_link.fitted:hover {\n",
|
442 |
+
" /* fitted */\n",
|
443 |
+
" background-color: var(--sklearn-color-fitted-level-3);\n",
|
444 |
+
"}\n",
|
445 |
+
"</style><div id=\"sk-container-id-6\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>SVC(random_state=42)</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator fitted sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-6\" type=\"checkbox\" checked><label for=\"sk-estimator-id-6\" class=\"sk-toggleable__label fitted sk-toggleable__label-arrow fitted\"> SVC<a class=\"sk-estimator-doc-link fitted\" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.5/modules/generated/sklearn.svm.SVC.html\">?<span>Documentation for SVC</span></a><span class=\"sk-estimator-doc-link fitted\">i<span>Fitted</span></span></label><div class=\"sk-toggleable__content fitted\"><pre>SVC(random_state=42)</pre></div> </div></div></div></div>"
|
446 |
+
],
|
447 |
+
"text/plain": [
|
448 |
+
"SVC(random_state=42)"
|
449 |
+
]
|
450 |
+
},
|
451 |
+
"execution_count": 41,
|
452 |
+
"metadata": {},
|
453 |
+
"output_type": "execute_result"
|
454 |
+
}
|
455 |
+
],
|
456 |
+
"source": [
|
457 |
+
"scaler = StandardScaler()\n",
|
458 |
+
"data_flattened = scaler.fit_transform(data_flattened)\n",
|
459 |
+
"\n",
|
460 |
+
"X_train, X_test, y_train, y_test = train_test_split(data_flattened, labels, test_size=0.2, random_state=42, stratify=labels)\n",
|
461 |
+
"svm_classifier = SVC(kernel='rbf', C=1.0, gamma='scale', random_state=42)\n",
|
462 |
+
"\n",
|
463 |
+
"svm_classifier.fit(X_train, y_train)"
|
464 |
+
]
|
465 |
+
},
|
466 |
+
{
|
467 |
+
"cell_type": "code",
|
468 |
+
"execution_count": 43,
|
469 |
+
"metadata": {},
|
470 |
+
"outputs": [],
|
471 |
+
"source": [
|
472 |
+
"y_pred = svm_classifier.predict(X_test)"
|
473 |
+
]
|
474 |
+
},
|
475 |
+
{
|
476 |
+
"cell_type": "code",
|
477 |
+
"execution_count": null,
|
478 |
+
"metadata": {},
|
479 |
+
"outputs": [],
|
480 |
+
"source": [
|
481 |
+
"print(classification_report(y_test, y_pred))"
|
482 |
+
]
|
483 |
+
}
|
484 |
+
],
|
485 |
+
"metadata": {
|
486 |
+
"kernelspec": {
|
487 |
+
"display_name": "imu",
|
488 |
+
"language": "python",
|
489 |
+
"name": "python3"
|
490 |
+
},
|
491 |
+
"language_info": {
|
492 |
+
"codemirror_mode": {
|
493 |
+
"name": "ipython",
|
494 |
+
"version": 3
|
495 |
+
},
|
496 |
+
"file_extension": ".py",
|
497 |
+
"mimetype": "text/x-python",
|
498 |
+
"name": "python",
|
499 |
+
"nbconvert_exporter": "python",
|
500 |
+
"pygments_lexer": "ipython3",
|
501 |
+
"version": "3.9.19"
|
502 |
+
}
|
503 |
+
},
|
504 |
+
"nbformat": 4,
|
505 |
+
"nbformat_minor": 2
|
506 |
+
}
|