Skip to content

Commit 87a51b5

Browse files
Parthibwhoseoyster
authored andcommitted
Added support for interacting with projects; model and dataset creation can now only happen in a project - UNB-1570
1 parent 8a93047 commit 87a51b5

File tree

16 files changed

+334
-735
lines changed

16 files changed

+334
-735
lines changed

examples/tabular-classification/churn-classifier/churn-classifier-sklearn.ipynb

Lines changed: 40 additions & 696 deletions
Large diffs are not rendered by default.

examples/tabular-classification/fetal-health/fetal-health-sklearn.ipynb

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,20 @@
179179
"metadata": {},
180180
"outputs": [],
181181
"source": [
182-
"from unboxapi.tasks import TaskType\n",
182+
"# Comment this out and uncomment the next section to load the project\n",
183+
"project = client.create_project(\n",
184+
" name=\"Sklearn Fetal Health Project\",\n",
185+
" description=\"Project for predicting fetal health\"\n",
186+
")\n",
187+
"\n",
188+
"# Use this for loading the project on subsequent runs\n",
189+
"'''\n",
190+
"project = client.load_project(\n",
191+
" name=\"Sklearn Fetal Health Project\"\n",
192+
")\n",
193+
"'''\n",
183194
"\n",
184-
"dataset = client.add_dataframe(\n",
195+
"dataset = project.add_dataframe(\n",
185196
" df=test,\n",
186197
" class_names=class_names,\n",
187198
" label_column_name='fetal_health',\n",
@@ -199,7 +210,7 @@
199210
"metadata": {},
200211
"outputs": [],
201212
"source": [
202-
"model = client.add_model(\n",
213+
"model = project.add_model(\n",
203214
" function=predict_proba, \n",
204215
" model=clf,\n",
205216
" model_type=ModelType.sklearn,\n",
@@ -231,7 +242,7 @@
231242
"name": "python",
232243
"nbconvert_exporter": "python",
233244
"pygments_lexer": "ipython3",
234-
"version": "3.8.10"
245+
"version": "3.8.12"
235246
}
236247
},
237248
"nbformat": 4,

examples/tabular-classification/fraud-detection/fraud-classifier-sklearn.ipynb

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,20 @@
250250
"metadata": {},
251251
"outputs": [],
252252
"source": [
253-
"from unboxapi.tasks import TaskType\n",
253+
"# Comment this out and uncomment the next section to load the project\n",
254+
"project = client.create_project(\n",
255+
" name=\"Sklearn Fraud Classifier\",\n",
256+
" description=\"Project for Classifying Fraud\"\n",
257+
")\n",
258+
"\n",
259+
"# Use this for loading the project on subsequent runs\n",
260+
"'''\n",
261+
"project = client.load_project(\n",
262+
" name=\"Sklearn Fraud Classifier\"\n",
263+
")\n",
264+
"'''\n",
254265
"\n",
255-
"dataset = client.add_dataframe(\n",
266+
"dataset = project.add_dataframe(\n",
256267
" df=x_val.sample(1000),\n",
257268
" class_names=class_names,\n",
258269
" label_column_name='is_fraud',\n",
@@ -272,7 +283,7 @@
272283
"metadata": {},
273284
"outputs": [],
274285
"source": [
275-
"model = client.add_model(\n",
286+
"model = project.add_model(\n",
276287
" function=predict_proba, \n",
277288
" model=sklearn_model,\n",
278289
" model_type=ModelType.sklearn,\n",
@@ -308,7 +319,7 @@
308319
"name": "python",
309320
"nbconvert_exporter": "python",
310321
"pygments_lexer": "ipython3",
311-
"version": "3.8.10"
322+
"version": "3.8.12"
312323
}
313324
},
314325
"nbformat": 4,

examples/tabular-classification/iris-classifier/iris-tabular-sklearn.ipynb

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,20 @@
154154
"metadata": {},
155155
"outputs": [],
156156
"source": [
157-
"from unboxapi.tasks import TaskType\n",
157+
"# Comment this out and uncomment the next section to load the project\n",
158+
"project = client.create_project(\n",
159+
" name=\"Sklearn Iris Tabular\",\n",
160+
" description=\"Project for Iris Tabular data\"\n",
161+
")\n",
162+
"\n",
163+
"# Use this for loading the project on subsequent runs\n",
164+
"'''\n",
165+
"project = client.load_project(\n",
166+
" name=\"Sklearn Iris Tabular\"\n",
167+
")\n",
168+
"'''\n",
158169
"\n",
159-
"dataset = client.add_dataframe(\n",
170+
"dataset = project.add_dataframe(\n",
160171
" df=df,\n",
161172
" class_names=class_names,\n",
162173
" label_column_name='target',\n",
@@ -174,7 +185,7 @@
174185
"metadata": {},
175186
"outputs": [],
176187
"source": [
177-
"model = client.add_model(\n",
188+
"model = project.add_model(\n",
178189
" function=predict_proba, \n",
179190
" model=classifiers['L1 logistic'],\n",
180191
" model_type=ModelType.sklearn,\n",
@@ -206,7 +217,7 @@
206217
"name": "python",
207218
"nbconvert_exporter": "python",
208219
"pygments_lexer": "ipython3",
209-
"version": "3.8.10"
220+
"version": "3.8.12"
210221
}
211222
},
212223
"nbformat": 4,

examples/text-classification/fasttext/fasttext.ipynb

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,20 @@
176176
"metadata": {},
177177
"outputs": [],
178178
"source": [
179-
"ml_model = client.add_model(\n",
179+
"# Comment this out and uncomment the next section to load the project\n",
180+
"project = client.create_project(\n",
181+
" name=\"Fasttext Demo\",\n",
182+
" description=\"Fasttext Demo Project\"\n",
183+
")\n",
184+
"\n",
185+
"# Use this for loading the project on subsequent runs\n",
186+
"'''\n",
187+
"project = client.load_project(\n",
188+
" name=\"Fasttext Demo\"\n",
189+
")\n",
190+
"'''\n",
191+
"\n",
192+
"ml_model = project.add_model(\n",
180193
" function=get_predictions, \n",
181194
" model=model,\n",
182195
" model_type=ModelType.fasttext,\n",
@@ -205,7 +218,7 @@
205218
"name": "python",
206219
"nbconvert_exporter": "python",
207220
"pygments_lexer": "ipython3",
208-
"version": "3.8.10"
221+
"version": "3.8.12"
209222
}
210223
},
211224
"nbformat": 4,

examples/text-classification/pytorch/pytorch.ipynb

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,20 @@
346346
"source": [
347347
"from unboxapi.models import ModelType\n",
348348
"\n",
349-
"model = client.add_model(\n",
349+
"# Comment this out and uncomment the next section to load the project\n",
350+
"project = client.create_project(\n",
351+
" name=\"Pytorch\",\n",
352+
" description=\"Pytorch project\"\n",
353+
")\n",
354+
"\n",
355+
"# Use this for loading the project on subsequent runs\n",
356+
"'''\n",
357+
"project = client.load_project(\n",
358+
" name=\"Pytorch\"\n",
359+
")\n",
360+
"'''\n",
361+
"\n",
362+
"model = project.add_model(\n",
350363
" function=predict_fn, \n",
351364
" model=model,\n",
352365
" model_type=ModelType.pytorch,\n",
@@ -386,7 +399,7 @@
386399
"metadata": {},
387400
"outputs": [],
388401
"source": [
389-
"dataset = client.add_dataframe(\n",
402+
"dataset = project.add_dataframe(\n",
390403
" df=df,\n",
391404
" class_names=['world', 'sports', 'business', 'sci/tec'],\n",
392405
" label_column_name='label',\n",
@@ -414,7 +427,7 @@
414427
"name": "python",
415428
"nbconvert_exporter": "python",
416429
"pygments_lexer": "ipython3",
417-
"version": "3.8.10"
430+
"version": "3.8.12"
418431
}
419432
},
420433
"nbformat": 4,

examples/text-classification/rasa/diet.ipynb

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,22 @@
150150
}
151151
],
152152
"source": [
153+
"# Comment this out and uncomment the next section to load the project\n",
154+
"project = client.create_project(\n",
155+
" name=\"Rasa Model\",\n",
156+
" description=\"Project That Uses Rasa\"\n",
157+
")\n",
158+
"\n",
159+
"# Use this for loading the project on subsequent runs\n",
160+
"'''\n",
161+
"project = client.load_project(\n",
162+
" name=\"Rasa Model\"\n",
163+
")\n",
164+
"'''\n",
165+
"\n",
153166
"from unboxapi.models import ModelType\n",
154167
"\n",
155-
"model_path = client.add_model(\n",
168+
"model_path = project.add_model(\n",
156169
" function=predict_proba, \n",
157170
" model=model,\n",
158171
" model_type=ModelType.rasa,\n",
@@ -328,7 +341,7 @@
328341
"name": "python",
329342
"nbconvert_exporter": "python",
330343
"pygments_lexer": "ipython3",
331-
"version": "3.7.10"
344+
"version": "3.8.12"
332345
}
333346
},
334347
"nbformat": 4,

examples/text-classification/sklearn/banking/demo-banking.ipynb

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,20 @@
194194
},
195195
"outputs": [],
196196
"source": [
197-
"unbox_model = client.add_model(\n",
197+
"# Comment this out and uncomment the next section to load the project\n",
198+
"project = client.create_project(\n",
199+
" name=\"Sklearn Banking Project\",\n",
200+
" description=\"Project to Demo Sklearn with Unbox\"\n",
201+
")\n",
202+
"\n",
203+
"# Use this for loading the project on subsequent runs\n",
204+
"'''\n",
205+
"project = client.load_project(\n",
206+
" name=\"Sklearn Banking Project\"\n",
207+
")\n",
208+
"'''\n",
209+
"\n",
210+
"unbox_model = project.add_model(\n",
198211
" function=predict_function, \n",
199212
" model=model,\n",
200213
" model_type=ModelType.sklearn,\n",
@@ -213,7 +226,7 @@
213226
"metadata": {},
214227
"outputs": [],
215228
"source": [
216-
"dataset = client.add_dataframe(\n",
229+
"dataset = project.add_dataframe(\n",
217230
" df=df_test,\n",
218231
" class_names=label_list,\n",
219232
" label_column_name=\"label_code\",\n",
@@ -242,7 +255,7 @@
242255
"name": "python",
243256
"nbconvert_exporter": "python",
244257
"pygments_lexer": "ipython3",
245-
"version": "3.8.10"
258+
"version": "3.8.12"
246259
}
247260
},
248261
"nbformat": 4,

examples/text-classification/sklearn/sentiment-analysis/sentiment-sklearn.ipynb

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,43 @@
206206
"# Package & Upload to Unbox"
207207
]
208208
},
209+
{
210+
"cell_type": "markdown",
211+
"id": "25d7b5f5",
212+
"metadata": {},
213+
"source": [
214+
"## Create/Load Project"
215+
]
216+
},
217+
{
218+
"cell_type": "markdown",
219+
"id": "d17aa3fc",
220+
"metadata": {},
221+
"source": [
222+
"### Create Project"
223+
]
224+
},
225+
{
226+
"cell_type": "code",
227+
"execution_count": null,
228+
"id": "750132b8",
229+
"metadata": {},
230+
"outputs": [],
231+
"source": [
232+
"# Comment this out and uncomment the next section to load the project\n",
233+
"project = client.create_project(\n",
234+
" name=\"Sentiment Analysis Sklearn Model\",\n",
235+
" description=\"Project to Demo Sklearn Sentiment Analysis with Unbox\"\n",
236+
")\n",
237+
"\n",
238+
"# Use this for loading the project on subsequent runs\n",
239+
"'''\n",
240+
"project = client.load_project(\n",
241+
" name=\"Sentiment Analysis Sklearn Model\"\n",
242+
")\n",
243+
"'''"
244+
]
245+
},
209246
{
210247
"cell_type": "markdown",
211248
"id": "binding-polymer",
@@ -221,7 +258,7 @@
221258
"metadata": {},
222259
"outputs": [],
223260
"source": [
224-
"dataset = client.add_dataframe(\n",
261+
"dataset = project.add_dataframe(\n",
225262
" df=df_test,\n",
226263
" class_names=['negative', 'positive'],\n",
227264
" label_column_name='polarity',\n",
@@ -251,7 +288,7 @@
251288
"source": [
252289
"from unboxapi.models import ModelType\n",
253290
"\n",
254-
"model = client.add_model(\n",
291+
"model = project.add_model(\n",
255292
" function=predict_function, \n",
256293
" model=sentiment_lr,\n",
257294
" model_type=ModelType.sklearn,\n",
@@ -279,7 +316,7 @@
279316
"name": "python",
280317
"nbconvert_exporter": "python",
281318
"pygments_lexer": "ipython3",
282-
"version": "3.8.10"
319+
"version": "3.8.12"
283320
}
284321
},
285322
"nbformat": 4,

examples/text-classification/sklearn/stacked-models/fastttext-stacked.ipynb

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,27 @@
215215
"client = unboxapi.UnboxClient(\"YOUR_API_KEY_HERE\")"
216216
]
217217
},
218+
{
219+
"cell_type": "code",
220+
"execution_count": null,
221+
"id": "75a77aa7",
222+
"metadata": {},
223+
"outputs": [],
224+
"source": [
225+
"# Comment this out and uncomment the next section to load the project\n",
226+
"project = client.create_project(\n",
227+
" name=\"Fasttext Stacked Model\",\n",
228+
" description=\"Project to Demo Fasttext Stacked\"\n",
229+
")\n",
230+
"\n",
231+
"# Use this for loading the project on subsequent runs\n",
232+
"'''\n",
233+
"project = client.load_project(\n",
234+
" name=\"Fasttext Stacked Model\"\n",
235+
")\n",
236+
"'''"
237+
]
238+
},
218239
{
219240
"cell_type": "code",
220241
"execution_count": null,
@@ -230,7 +251,7 @@
230251
"model = (rec_model, rec_type_model)\n",
231252
"\"\"\"\n",
232253
"\n",
233-
"ml_model = client.add_model(\n",
254+
"ml_model = project.add_model(\n",
234255
" function=get_predictions, \n",
235256
" model=None,\n",
236257
" dependent_dir=folder_name,\n",
@@ -262,7 +283,7 @@
262283
"name": "python",
263284
"nbconvert_exporter": "python",
264285
"pygments_lexer": "ipython3",
265-
"version": "3.8.10"
286+
"version": "3.8.12"
266287
}
267288
},
268289
"nbformat": 4,

0 commit comments

Comments
 (0)