Skip to content

Commit 9f1fd11

Browse files
committed
fixed lint
1 parent 3b47c5f commit 9f1fd11

File tree

3 files changed

+1010
-161
lines changed

3 files changed

+1010
-161
lines changed

examples/limix_classification_example.ipynb

Lines changed: 80 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@
2424
},
2525
{
2626
"cell_type": "code",
27+
"execution_count": 30,
2728
"metadata": {
2829
"ExecuteTime": {
2930
"end_time": "2025-12-17T19:13:35.353551Z",
3031
"start_time": "2025-12-17T19:13:35.349651Z"
3132
}
3233
},
34+
"outputs": [],
3335
"source": [
3436
"import os\n",
3537
"\n",
@@ -38,9 +40,7 @@
3840
"from sklearn.model_selection import train_test_split\n",
3941
"\n",
4042
"from faim_sdk import LimiXPredictRequest, TabularClient"
41-
],
42-
"outputs": [],
43-
"execution_count": 30
43+
]
4444
},
4545
{
4646
"cell_type": "markdown",
@@ -53,12 +53,25 @@
5353
},
5454
{
5555
"cell_type": "code",
56+
"execution_count": 31,
5657
"metadata": {
5758
"ExecuteTime": {
5859
"end_time": "2025-12-17T19:13:35.382612Z",
5960
"start_time": "2025-12-17T19:13:35.367160Z"
6061
}
6162
},
63+
"outputs": [
64+
{
65+
"name": "stdout",
66+
"output_type": "stream",
67+
"text": [
68+
"Training set size: (426, 30)\n",
69+
"Test set size: (143, 30)\n",
70+
"Number of features: 30\n",
71+
"Classes: [0. 1.]\n"
72+
]
73+
}
74+
],
6275
"source": [
6376
"# Load breast cancer dataset\n",
6477
"X, y = load_breast_cancer(return_X_y=True)\n",
@@ -76,20 +89,7 @@
7689
"print(f\"Test set size: {X_test.shape}\")\n",
7790
"print(f\"Number of features: {X_train.shape[1]}\")\n",
7891
"print(f\"Classes: {np.unique(y_train)}\")"
79-
],
80-
"outputs": [
81-
{
82-
"name": "stdout",
83-
"output_type": "stream",
84-
"text": [
85-
"Training set size: (426, 30)\n",
86-
"Test set size: (143, 30)\n",
87-
"Number of features: 30\n",
88-
"Classes: [0. 1.]\n"
89-
]
90-
}
91-
],
92-
"execution_count": 31
92+
]
9393
},
9494
{
9595
"cell_type": "markdown",
@@ -102,22 +102,13 @@
102102
},
103103
{
104104
"cell_type": "code",
105+
"execution_count": 32,
105106
"metadata": {
106107
"ExecuteTime": {
107108
"end_time": "2025-12-17T19:13:35.415414Z",
108109
"start_time": "2025-12-17T19:13:35.410396Z"
109110
}
110111
},
111-
"source": [
112-
"# Initialize the client\n",
113-
"client = TabularClient(\n",
114-
" base_url=\"https://api.faim.it.com\",\n",
115-
" api_key=os.environ.get(\"FAIM_API_KEY\"), # Replace with your actual API key\n",
116-
" timeout=120.0,\n",
117-
")\n",
118-
"\n",
119-
"print(\"TabularClient initialized!\")"
120-
],
121112
"outputs": [
122113
{
123114
"name": "stdout",
@@ -127,7 +118,16 @@
127118
]
128119
}
129120
],
130-
"execution_count": 32
121+
"source": [
122+
"# Initialize the client\n",
123+
"client = TabularClient(\n",
124+
" base_url=\"https://api.faim.it.com\",\n",
125+
" api_key=os.environ.get(\"FAIM_API_KEY\"), # Replace with your actual API key\n",
126+
" timeout=120.0,\n",
127+
")\n",
128+
"\n",
129+
"print(\"TabularClient initialized!\")"
130+
]
131131
},
132132
{
133133
"cell_type": "markdown",
@@ -140,23 +140,13 @@
140140
},
141141
{
142142
"cell_type": "code",
143+
"execution_count": 33,
143144
"metadata": {
144145
"ExecuteTime": {
145146
"end_time": "2025-12-17T19:13:35.443478Z",
146147
"start_time": "2025-12-17T19:13:35.441032Z"
147148
}
148149
},
149-
"source": [
150-
"# Create a LimiX classification request\n",
151-
"request = LimiXPredictRequest(\n",
152-
" X_train=X_train, y_train=y_train, X_test=X_test, task_type=\"Classification\",\n",
153-
")\n",
154-
"\n",
155-
"print(\"Request prepared:\")\n",
156-
"print(f\" X_train shape: {request.X_train.shape}\")\n",
157-
"print(f\" X_test shape: {request.X_test.shape}\")\n",
158-
"print(f\" Task type: {request.task_type}\")"
159-
],
160150
"outputs": [
161151
{
162152
"name": "stdout",
@@ -169,7 +159,20 @@
169159
]
170160
}
171161
],
172-
"execution_count": 33
162+
"source": [
163+
"# Create a LimiX classification request\n",
164+
"request = LimiXPredictRequest(\n",
165+
" X_train=X_train,\n",
166+
" y_train=y_train,\n",
167+
" X_test=X_test,\n",
168+
" task_type=\"Classification\",\n",
169+
")\n",
170+
"\n",
171+
"print(\"Request prepared:\")\n",
172+
"print(f\" X_train shape: {request.X_train.shape}\")\n",
173+
"print(f\" X_test shape: {request.X_test.shape}\")\n",
174+
"print(f\" Task type: {request.task_type}\")"
175+
]
173176
},
174177
{
175178
"cell_type": "markdown",
@@ -182,33 +185,13 @@
182185
},
183186
{
184187
"cell_type": "code",
188+
"execution_count": 34,
185189
"metadata": {
186190
"ExecuteTime": {
187191
"end_time": "2025-12-17T19:13:36.431619Z",
188192
"start_time": "2025-12-17T19:13:35.466839Z"
189193
}
190194
},
191-
"source": [
192-
"try:\n",
193-
" # Make predictions\n",
194-
" response = client.predict(request)\n",
195-
"\n",
196-
" print(f\"Predictions shape: {response.predictions.shape}\")\n",
197-
" print(f\"First 10 predictions: {response.predictions[:10]}\")\n",
198-
"\n",
199-
" if response.probabilities is not None:\n",
200-
" print(f\"\\nClass probabilities shape: {response.probabilities.shape}\")\n",
201-
" print(f\"First 3 samples probabilities:\\n{response.probabilities[:3]}\")\n",
202-
"\n",
203-
" print(\"\\nMetadata:\")\n",
204-
" for key, value in response.metadata.items():\n",
205-
" if key == 'cost_amount':\n",
206-
" value = float(value)/1e6\n",
207-
" print(f\" {key}: {value}\")\n",
208-
"\n",
209-
"except Exception as e:\n",
210-
" print(f\"Error: {e}\")"
211-
],
212195
"outputs": [
213196
{
214197
"name": "stdout",
@@ -233,7 +216,27 @@
233216
]
234217
}
235218
],
236-
"execution_count": 34
219+
"source": [
220+
"try:\n",
221+
" # Make predictions\n",
222+
" response = client.predict(request)\n",
223+
"\n",
224+
" print(f\"Predictions shape: {response.predictions.shape}\")\n",
225+
" print(f\"First 10 predictions: {response.predictions[:10]}\")\n",
226+
"\n",
227+
" if response.probabilities is not None:\n",
228+
" print(f\"\\nClass probabilities shape: {response.probabilities.shape}\")\n",
229+
" print(f\"First 3 samples probabilities:\\n{response.probabilities[:3]}\")\n",
230+
"\n",
231+
" print(\"\\nMetadata:\")\n",
232+
" for key, value in response.metadata.items():\n",
233+
" if key == \"cost_amount\":\n",
234+
" value = float(value) / 1e6\n",
235+
" print(f\" {key}: {value}\")\n",
236+
"\n",
237+
"except Exception as e:\n",
238+
" print(f\"Error: {e}\")"
239+
]
237240
},
238241
{
239242
"cell_type": "markdown",
@@ -246,12 +249,26 @@
246249
},
247250
{
248251
"cell_type": "code",
252+
"execution_count": 35,
249253
"metadata": {
250254
"ExecuteTime": {
251255
"end_time": "2025-12-17T19:13:36.461088Z",
252256
"start_time": "2025-12-17T19:13:36.450764Z"
253257
}
254258
},
259+
"outputs": [
260+
{
261+
"name": "stdout",
262+
"output_type": "stream",
263+
"text": [
264+
"Classification Metrics:\n",
265+
" Accuracy: 0.9860\n",
266+
" Precision: 0.9888\n",
267+
" Recall: 0.9888\n",
268+
" F1-Score: 0.9888\n"
269+
]
270+
}
271+
],
255272
"source": [
256273
"from sklearn.metrics import accuracy_score, f1_score, precision_score, recall_score\n",
257274
"\n",
@@ -270,21 +287,7 @@
270287
" print(f\" F1-Score: {f1:.4f}\")\n",
271288
"except NameError:\n",
272289
" print(\"Run prediction cell first to evaluate metrics.\")"
273-
],
274-
"outputs": [
275-
{
276-
"name": "stdout",
277-
"output_type": "stream",
278-
"text": [
279-
"Classification Metrics:\n",
280-
" Accuracy: 0.9860\n",
281-
" Precision: 0.9888\n",
282-
" Recall: 0.9888\n",
283-
" F1-Score: 0.9888\n"
284-
]
285-
}
286-
],
287-
"execution_count": 35
290+
]
288291
}
289292
],
290293
"metadata": {

0 commit comments

Comments
 (0)