Skip to content

Commit 2bacd90

Browse files
Update notebook examples with task_type in project and description->commit_message
1 parent 5140f56 commit 2bacd90

File tree

10 files changed

+933
-1904
lines changed

10 files changed

+933
-1904
lines changed

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

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
},
3131
{
3232
"cell_type": "code",
33-
"execution_count": 4,
33+
"execution_count": 1,
3434
"metadata": {},
3535
"outputs": [],
3636
"source": [
@@ -52,7 +52,7 @@
5252
},
5353
{
5454
"cell_type": "code",
55-
"execution_count": 5,
55+
"execution_count": 2,
5656
"metadata": {},
5757
"outputs": [],
5858
"source": [
@@ -61,7 +61,7 @@
6161
},
6262
{
6363
"cell_type": "code",
64-
"execution_count": 6,
64+
"execution_count": 3,
6565
"metadata": {},
6666
"outputs": [],
6767
"source": [
@@ -70,7 +70,7 @@
7070
},
7171
{
7272
"cell_type": "code",
73-
"execution_count": 7,
73+
"execution_count": 4,
7474
"metadata": {},
7575
"outputs": [],
7676
"source": [
@@ -80,7 +80,7 @@
8080
},
8181
{
8282
"cell_type": "code",
83-
"execution_count": 8,
83+
"execution_count": 5,
8484
"metadata": {},
8585
"outputs": [
8686
{
@@ -492,7 +492,7 @@
492492
"[2126 rows x 22 columns]"
493493
]
494494
},
495-
"execution_count": 8,
495+
"execution_count": 5,
496496
"metadata": {},
497497
"output_type": "execute_result"
498498
}
@@ -510,7 +510,7 @@
510510
},
511511
{
512512
"cell_type": "code",
513-
"execution_count": 7,
513+
"execution_count": 6,
514514
"metadata": {},
515515
"outputs": [],
516516
"source": [
@@ -519,7 +519,7 @@
519519
},
520520
{
521521
"cell_type": "code",
522-
"execution_count": 8,
522+
"execution_count": 7,
523523
"metadata": {},
524524
"outputs": [],
525525
"source": [
@@ -538,7 +538,7 @@
538538
},
539539
{
540540
"cell_type": "code",
541-
"execution_count": 9,
541+
"execution_count": 8,
542542
"metadata": {},
543543
"outputs": [],
544544
"source": [
@@ -551,22 +551,17 @@
551551
},
552552
{
553553
"cell_type": "code",
554-
"execution_count": 10,
554+
"execution_count": 9,
555555
"metadata": {},
556556
"outputs": [
557557
{
558558
"data": {
559-
"text/html": [
560-
"<style>#sk-container-id-1 {color: black;background-color: white;}#sk-container-id-1 pre{padding: 0;}#sk-container-id-1 div.sk-toggleable {background-color: white;}#sk-container-id-1 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-container-id-1 label.sk-toggleable__label-arrow:before {content: \"▸\";float: left;margin-right: 0.25em;color: #696969;}#sk-container-id-1 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-container-id-1 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-container-id-1 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-container-id-1 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-container-id-1 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-container-id-1 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"▾\";}#sk-container-id-1 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-container-id-1 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-container-id-1 div.sk-estimator:hover {background-color: #d4ebff;}#sk-container-id-1 div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-container-id-1 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: 0;}#sk-container-id-1 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;position: relative;}#sk-container-id-1 div.sk-item {position: relative;z-index: 1;}#sk-container-id-1 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;position: relative;}#sk-container-id-1 div.sk-item::before, #sk-container-id-1 div.sk-parallel-item::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: -1;}#sk-container-id-1 div.sk-parallel-item {display: flex;flex-direction: column;z-index: 1;position: relative;background-color: white;}#sk-container-id-1 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-container-id-1 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-container-id-1 div.sk-parallel-item:only-child::after {width: 0;}#sk-container-id-1 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;}#sk-container-id-1 div.sk-label label {font-family: monospace;font-weight: bold;display: inline-block;line-height: 1.2em;}#sk-container-id-1 div.sk-label-container {text-align: center;}#sk-container-id-1 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-container-id-1 div.sk-text-repr-fallback {display: none;}</style><div id=\"sk-container-id-1\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>LogisticRegression(C=10, max_iter=10000, multi_class=&#x27;multinomial&#x27;,\n",
561-
" penalty=&#x27;l1&#x27;, solver=&#x27;saga&#x27;)</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 sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-1\" type=\"checkbox\" checked><label for=\"sk-estimator-id-1\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">LogisticRegression</label><div class=\"sk-toggleable__content\"><pre>LogisticRegression(C=10, max_iter=10000, multi_class=&#x27;multinomial&#x27;,\n",
562-
" penalty=&#x27;l1&#x27;, solver=&#x27;saga&#x27;)</pre></div></div></div></div></div>"
563-
],
564559
"text/plain": [
565560
"LogisticRegression(C=10, max_iter=10000, multi_class='multinomial',\n",
566561
" penalty='l1', solver='saga')"
567562
]
568563
},
569-
"execution_count": 10,
564+
"execution_count": 9,
570565
"metadata": {},
571566
"output_type": "execute_result"
572567
}
@@ -577,7 +572,7 @@
577572
},
578573
{
579574
"cell_type": "code",
580-
"execution_count": 11,
575+
"execution_count": 10,
581576
"metadata": {},
582577
"outputs": [
583578
{
@@ -586,13 +581,13 @@
586581
"text": [
587582
" precision recall f1-score support\n",
588583
"\n",
589-
" 0 0.91 0.74 0.82 39\n",
590-
" 1 0.91 0.98 0.94 330\n",
591-
" 2 0.71 0.51 0.59 57\n",
584+
" 0 0.81 0.65 0.72 34\n",
585+
" 1 0.89 0.98 0.94 325\n",
586+
" 2 0.74 0.46 0.57 67\n",
592587
"\n",
593-
" accuracy 0.89 426\n",
594-
" macro avg 0.84 0.74 0.78 426\n",
595-
"weighted avg 0.88 0.89 0.88 426\n",
588+
" accuracy 0.87 426\n",
589+
" macro avg 0.82 0.70 0.74 426\n",
590+
"weighted avg 0.86 0.87 0.86 426\n",
596591
"\n"
597592
]
598593
}
@@ -612,7 +607,7 @@
612607
},
613608
{
614609
"cell_type": "code",
615-
"execution_count": 12,
610+
"execution_count": 11,
616611
"metadata": {},
617612
"outputs": [],
618613
"source": [
@@ -630,19 +625,22 @@
630625
},
631626
{
632627
"cell_type": "code",
633-
"execution_count": 13,
628+
"execution_count": 14,
634629
"metadata": {},
635630
"outputs": [
636631
{
637632
"name": "stdout",
638633
"output_type": "stream",
639634
"text": [
640-
"Creating project on Unbox! Check out https://unbox.ai/projects to have a look!\n"
635+
"Created your project. Check out https://unbox.ai/projects!\n"
641636
]
642637
}
643638
],
644639
"source": [
645-
"project = client.create_project(name=\"Fetal Health Prediction\", \n",
640+
"from unboxapi.tasks import TaskType\n",
641+
"\n",
642+
"project = client.create_project(name=\"Fetal Health Prediction\",\n",
643+
" task_type=TaskType.TabularClassification,\n",
646644
" description=\"Evaluation of ML approaches to predict health\")"
647645
]
648646
},
@@ -655,7 +653,7 @@
655653
},
656654
{
657655
"cell_type": "code",
658-
"execution_count": 19,
656+
"execution_count": 15,
659657
"metadata": {},
660658
"outputs": [
661659
{
@@ -667,15 +665,11 @@
667665
}
668666
],
669667
"source": [
670-
"from unboxapi.tasks import TaskType\n",
671-
"\n",
672668
"dataset = project.add_dataframe(\n",
673669
" df=test,\n",
674670
" class_names=[\"Pathological\", \"Normal\", \"Suspect\"],\n",
675671
" label_column_name='fetal_health',\n",
676-
" name=\"Fetal health validation set\",\n",
677-
" description='this is my fetal health validation dataset',\n",
678-
" task_type=TaskType.TabularClassification,\n",
672+
" commit_message='this is my fetal health validation dataset',\n",
679673
" feature_names=test.loc[:, test.columns != 'fetal_health'].columns.values.tolist(),\n",
680674
")"
681675
]
@@ -691,7 +685,7 @@
691685
},
692686
{
693687
"cell_type": "code",
694-
"execution_count": 15,
688+
"execution_count": 16,
695689
"metadata": {},
696690
"outputs": [],
697691
"source": [
@@ -708,26 +702,18 @@
708702
},
709703
{
710704
"cell_type": "code",
711-
"execution_count": 18,
705+
"execution_count": 17,
712706
"metadata": {},
713707
"outputs": [
714-
{
715-
"name": "stderr",
716-
"output_type": "stream",
717-
"text": [
718-
"/Users/gustavocid/miniconda3/envs/unbox-examples/lib/python3.8/site-packages/sklearn/base.py:443: UserWarning: X has feature names, but LogisticRegression was fitted without feature names\n",
719-
" warnings.warn(\n"
720-
]
721-
},
722708
{
723709
"data": {
724710
"text/plain": [
725-
"array([[1.30716901e-06, 9.88941660e-01, 1.10570332e-02],\n",
726-
" [7.73506281e-03, 6.72233264e-01, 3.20031674e-01],\n",
727-
" [1.05907808e-04, 9.79362816e-01, 2.05312764e-02]])"
711+
"array([[2.05737599e-02, 3.78148952e-01, 6.01277288e-01],\n",
712+
" [2.12130596e-06, 9.99412193e-01, 5.85685717e-04],\n",
713+
" [3.56683608e-03, 8.50312336e-01, 1.46120828e-01]])"
728714
]
729715
},
730-
"execution_count": 18,
716+
"execution_count": 17,
731717
"metadata": {},
732718
"output_type": "execute_result"
733719
}
@@ -745,7 +731,7 @@
745731
},
746732
{
747733
"cell_type": "code",
748-
"execution_count": 21,
734+
"execution_count": 18,
749735
"metadata": {},
750736
"outputs": [
751737
{
@@ -755,6 +741,14 @@
755741
"Bundling model and artifacts...\n",
756742
"Uploading model to Unbox! Check out https://unbox.ai/models to have a look!\n"
757743
]
744+
},
745+
{
746+
"name": "stderr",
747+
"output_type": "stream",
748+
"text": [
749+
"/Users/gustavocid/miniconda3/envs/unbox-examples/lib/python3.8/site-packages/joblib/numpy_pickle.py:103: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.\n",
750+
" pickler.file_handle.write(chunk.tostring('C'))\n"
751+
]
758752
}
759753
],
760754
"source": [
@@ -764,15 +758,21 @@
764758
" function=predict_proba, \n",
765759
" model=sklearn_model,\n",
766760
" model_type=ModelType.sklearn,\n",
767-
" task_type=TaskType.TabularClassification,\n",
768761
" class_names=[\"Pathological\", \"Normal\", \"Suspect\"],\n",
769762
" name='Fetal Classifier - N3',\n",
770-
" description='this is my first tabular classification model',\n",
763+
" commit_message='this is my first tabular classification model',\n",
771764
" feature_names=test.loc[:, test.columns != 'fetal_health'].columns.values.tolist(),\n",
772765
" train_sample_df=train[:100],\n",
773766
" train_sample_label_column_name='fetal_health',\n",
774767
")"
775768
]
769+
},
770+
{
771+
"cell_type": "code",
772+
"execution_count": null,
773+
"metadata": {},
774+
"outputs": [],
775+
"source": []
776776
}
777777
],
778778
"metadata": {

0 commit comments

Comments
 (0)