|
2 | 2 | "cells": [ |
3 | 3 | { |
4 | 4 | "cell_type": "code", |
5 | | - "execution_count": 12, |
| 5 | + "execution_count": 1, |
6 | 6 | "id": "33179b0c", |
7 | 7 | "metadata": {}, |
8 | 8 | "outputs": [], |
|
28 | 28 | }, |
29 | 29 | { |
30 | 30 | "cell_type": "code", |
31 | | - "execution_count": 13, |
| 31 | + "execution_count": 2, |
32 | 32 | "id": "40472b51", |
33 | 33 | "metadata": {}, |
34 | 34 | "outputs": [], |
|
38 | 38 | }, |
39 | 39 | { |
40 | 40 | "cell_type": "code", |
41 | | - "execution_count": 14, |
| 41 | + "execution_count": 3, |
42 | 42 | "id": "679e0b36", |
43 | 43 | "metadata": {}, |
44 | 44 | "outputs": [ |
|
254 | 254 | "[10000 rows x 10 columns]" |
255 | 255 | ] |
256 | 256 | }, |
257 | | - "execution_count": 14, |
| 257 | + "execution_count": 3, |
258 | 258 | "metadata": {}, |
259 | 259 | "output_type": "execute_result" |
260 | 260 | } |
|
275 | 275 | }, |
276 | 276 | { |
277 | 277 | "cell_type": "code", |
278 | | - "execution_count": 15, |
279 | | - "id": "d0e728a9", |
280 | | - "metadata": {}, |
281 | | - "outputs": [ |
282 | | - { |
283 | | - "data": { |
284 | | - "text/plain": [ |
285 | | - "{'Gender': ['Female', 'Male'], 'Geography': ['France', 'Spain', 'Germany']}" |
286 | | - ] |
287 | | - }, |
288 | | - "execution_count": 15, |
289 | | - "metadata": {}, |
290 | | - "output_type": "execute_result" |
291 | | - } |
292 | | - ], |
293 | | - "source": [ |
294 | | - "categorical_map = {feature: list(X[feature].unique()) for feature in [\"Gender\", \"Geography\"]}\n", |
295 | | - "categorical_map" |
296 | | - ] |
297 | | - }, |
298 | | - { |
299 | | - "cell_type": "code", |
300 | | - "execution_count": 16, |
| 278 | + "execution_count": 4, |
301 | 279 | "id": "708ade4c", |
302 | 280 | "metadata": {}, |
303 | 281 | "outputs": [], |
|
316 | 294 | }, |
317 | 295 | { |
318 | 296 | "cell_type": "code", |
319 | | - "execution_count": 17, |
| 297 | + "execution_count": 5, |
320 | 298 | "id": "e0a1b4b0", |
321 | 299 | "metadata": {}, |
322 | 300 | "outputs": [], |
|
336 | 314 | }, |
337 | 315 | { |
338 | 316 | "cell_type": "code", |
339 | | - "execution_count": 18, |
| 317 | + "execution_count": 6, |
340 | 318 | "id": "248556af", |
341 | 319 | "metadata": {}, |
342 | 320 | "outputs": [ |
|
348 | 326 | "encoding Gender\n" |
349 | 327 | ] |
350 | 328 | }, |
| 329 | + { |
| 330 | + "name": "stderr", |
| 331 | + "output_type": "stream", |
| 332 | + "text": [ |
| 333 | + "/Users/gustavocid/miniconda3/envs/unbox-examples/lib/python3.8/site-packages/sklearn/utils/deprecation.py:87: FutureWarning: Function get_feature_names is deprecated; get_feature_names is deprecated in 1.0 and will be removed in 1.2. Please use get_feature_names_out instead.\n", |
| 334 | + " warnings.warn(msg, category=FutureWarning)\n", |
| 335 | + "/Users/gustavocid/miniconda3/envs/unbox-examples/lib/python3.8/site-packages/sklearn/utils/deprecation.py:87: FutureWarning: Function get_feature_names is deprecated; get_feature_names is deprecated in 1.0 and will be removed in 1.2. Please use get_feature_names_out instead.\n", |
| 336 | + " warnings.warn(msg, category=FutureWarning)\n" |
| 337 | + ] |
| 338 | + }, |
351 | 339 | { |
352 | 340 | "data": { |
353 | 341 | "text/html": [ |
|
609 | 597 | "[10000 rows x 13 columns]" |
610 | 598 | ] |
611 | 599 | }, |
612 | | - "execution_count": 18, |
| 600 | + "execution_count": 6, |
613 | 601 | "metadata": {}, |
614 | 602 | "output_type": "execute_result" |
615 | 603 | } |
|
623 | 611 | }, |
624 | 612 | { |
625 | 613 | "cell_type": "code", |
626 | | - "execution_count": 19, |
| 614 | + "execution_count": 7, |
627 | 615 | "id": "b76d541a", |
628 | 616 | "metadata": {}, |
629 | 617 | "outputs": [ |
|
636 | 624 | "encoding Geography\n", |
637 | 625 | "encoding Gender\n" |
638 | 626 | ] |
| 627 | + }, |
| 628 | + { |
| 629 | + "name": "stderr", |
| 630 | + "output_type": "stream", |
| 631 | + "text": [ |
| 632 | + "/Users/gustavocid/miniconda3/envs/unbox-examples/lib/python3.8/site-packages/sklearn/utils/deprecation.py:87: FutureWarning: Function get_feature_names is deprecated; get_feature_names is deprecated in 1.0 and will be removed in 1.2. Please use get_feature_names_out instead.\n", |
| 633 | + " warnings.warn(msg, category=FutureWarning)\n", |
| 634 | + "/Users/gustavocid/miniconda3/envs/unbox-examples/lib/python3.8/site-packages/sklearn/utils/deprecation.py:87: FutureWarning: Function get_feature_names is deprecated; get_feature_names is deprecated in 1.0 and will be removed in 1.2. Please use get_feature_names_out instead.\n", |
| 635 | + " warnings.warn(msg, category=FutureWarning)\n", |
| 636 | + "/Users/gustavocid/miniconda3/envs/unbox-examples/lib/python3.8/site-packages/sklearn/utils/deprecation.py:87: FutureWarning: Function get_feature_names is deprecated; get_feature_names is deprecated in 1.0 and will be removed in 1.2. Please use get_feature_names_out instead.\n", |
| 637 | + " warnings.warn(msg, category=FutureWarning)\n", |
| 638 | + "/Users/gustavocid/miniconda3/envs/unbox-examples/lib/python3.8/site-packages/sklearn/utils/deprecation.py:87: FutureWarning: Function get_feature_names is deprecated; get_feature_names is deprecated in 1.0 and will be removed in 1.2. Please use get_feature_names_out instead.\n", |
| 639 | + " warnings.warn(msg, category=FutureWarning)\n" |
| 640 | + ] |
639 | 641 | } |
640 | 642 | ], |
641 | 643 | "source": [ |
|
654 | 656 | }, |
655 | 657 | { |
656 | 658 | "cell_type": "code", |
657 | | - "execution_count": 27, |
| 659 | + "execution_count": 8, |
658 | 660 | "id": "ee882b61", |
659 | 661 | "metadata": {}, |
660 | 662 | "outputs": [ |
661 | 663 | { |
662 | 664 | "data": { |
| 665 | + "text/html": [ |
| 666 | + "<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(random_state=1300)</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(random_state=1300)</pre></div></div></div></div></div>" |
| 667 | + ], |
663 | 668 | "text/plain": [ |
664 | 669 | "LogisticRegression(random_state=1300)" |
665 | 670 | ] |
666 | 671 | }, |
667 | | - "execution_count": 27, |
| 672 | + "execution_count": 8, |
668 | 673 | "metadata": {}, |
669 | 674 | "output_type": "execute_result" |
670 | 675 | } |
|
676 | 681 | }, |
677 | 682 | { |
678 | 683 | "cell_type": "code", |
679 | | - "execution_count": 28, |
| 684 | + "execution_count": 9, |
680 | 685 | "id": "a4f603d9", |
681 | 686 | "metadata": {}, |
682 | 687 | "outputs": [ |
|
702 | 707 | }, |
703 | 708 | { |
704 | 709 | "cell_type": "code", |
705 | | - "execution_count": 29, |
| 710 | + "execution_count": 10, |
706 | 711 | "id": "5d0e0298", |
707 | 712 | "metadata": {}, |
708 | 713 | "outputs": [], |
|
721 | 726 | }, |
722 | 727 | { |
723 | 728 | "cell_type": "code", |
724 | | - "execution_count": null, |
| 729 | + "execution_count": 11, |
725 | 730 | "id": "82a38cd9", |
726 | 731 | "metadata": {}, |
727 | 732 | "outputs": [], |
|
742 | 747 | }, |
743 | 748 | { |
744 | 749 | "cell_type": "code", |
745 | | - "execution_count": 31, |
| 750 | + "execution_count": 12, |
746 | 751 | "id": "d233987d", |
747 | 752 | "metadata": {}, |
748 | 753 | "outputs": [], |
|
757 | 762 | }, |
758 | 763 | { |
759 | 764 | "cell_type": "code", |
760 | | - "execution_count": 33, |
| 765 | + "execution_count": 13, |
761 | 766 | "id": "674147b8", |
762 | 767 | "metadata": {}, |
763 | 768 | "outputs": [ |
|
769 | 774 | "encoding Gender\n" |
770 | 775 | ] |
771 | 776 | }, |
| 777 | + { |
| 778 | + "name": "stderr", |
| 779 | + "output_type": "stream", |
| 780 | + "text": [ |
| 781 | + "/Users/gustavocid/miniconda3/envs/unbox-examples/lib/python3.8/site-packages/sklearn/utils/deprecation.py:87: FutureWarning: Function get_feature_names is deprecated; get_feature_names is deprecated in 1.0 and will be removed in 1.2. Please use get_feature_names_out instead.\n", |
| 782 | + " warnings.warn(msg, category=FutureWarning)\n", |
| 783 | + "/Users/gustavocid/miniconda3/envs/unbox-examples/lib/python3.8/site-packages/sklearn/utils/deprecation.py:87: FutureWarning: Function get_feature_names is deprecated; get_feature_names is deprecated in 1.0 and will be removed in 1.2. Please use get_feature_names_out instead.\n", |
| 784 | + " warnings.warn(msg, category=FutureWarning)\n", |
| 785 | + "/Users/gustavocid/miniconda3/envs/unbox-examples/lib/python3.8/site-packages/sklearn/base.py:450: UserWarning: X does not have valid feature names, but LogisticRegression was fitted with feature names\n", |
| 786 | + " warnings.warn(\n" |
| 787 | + ] |
| 788 | + }, |
772 | 789 | { |
773 | 790 | "data": { |
774 | 791 | "text/plain": [ |
|
777 | 794 | " [0.81455616, 0.18544384]])" |
778 | 795 | ] |
779 | 796 | }, |
780 | | - "execution_count": 33, |
| 797 | + "execution_count": 13, |
781 | 798 | "metadata": {}, |
782 | 799 | "output_type": "execute_result" |
783 | 800 | } |
|
788 | 805 | }, |
789 | 806 | { |
790 | 807 | "cell_type": "code", |
791 | | - "execution_count": null, |
| 808 | + "execution_count": 14, |
792 | 809 | "id": "ebb1171a", |
793 | 810 | "metadata": {}, |
794 | 811 | "outputs": [], |
|
800 | 817 | }, |
801 | 818 | { |
802 | 819 | "cell_type": "code", |
803 | | - "execution_count": null, |
| 820 | + "execution_count": 15, |
804 | 821 | "id": "230f1aa6", |
805 | 822 | "metadata": {}, |
806 | | - "outputs": [], |
| 823 | + "outputs": [ |
| 824 | + { |
| 825 | + "data": { |
| 826 | + "text/plain": [ |
| 827 | + "{'classNameCounts': None,\n", |
| 828 | + " 'classNames': ['Retained', 'Exited'],\n", |
| 829 | + " 'columnNames': None,\n", |
| 830 | + " 'columnSettings': None,\n", |
| 831 | + " 'dateCreated': '2022-07-06T21:07:36.320577Z',\n", |
| 832 | + " 'description': 'this is my churn dataset',\n", |
| 833 | + " 'featureNames': ['CreditScore',\n", |
| 834 | + " 'Geography',\n", |
| 835 | + " 'Gender',\n", |
| 836 | + " 'Age',\n", |
| 837 | + " 'Tenure',\n", |
| 838 | + " 'Balance',\n", |
| 839 | + " 'NumOfProducts',\n", |
| 840 | + " 'HasCrCard',\n", |
| 841 | + " 'IsActiveMember',\n", |
| 842 | + " 'EstimatedSalary'],\n", |
| 843 | + " 'id': '4b4e4370-7766-4b42-a467-508ffbec219b',\n", |
| 844 | + " 'inProgressNotifications': ['dataset_4b4e4370-7766-4b42-a467-508ffbec219b_process_uploaded_dataset'],\n", |
| 845 | + " 'labelColumnIndex': None,\n", |
| 846 | + " 'language': 'en',\n", |
| 847 | + " 'modelCount': 0,\n", |
| 848 | + " 'name': 'Churn Validation',\n", |
| 849 | + " 'projects': [],\n", |
| 850 | + " 'rowCount': 0,\n", |
| 851 | + " 'tagCount': 0,\n", |
| 852 | + " 'taskType': 'tabular-classification'}" |
| 853 | + ] |
| 854 | + }, |
| 855 | + "execution_count": 15, |
| 856 | + "metadata": {}, |
| 857 | + "output_type": "execute_result" |
| 858 | + } |
| 859 | + ], |
807 | 860 | "source": [ |
808 | 861 | "from unboxapi.tasks import TaskType\n", |
809 | 862 | "\n", |
|
815 | 868 | " description='this is my churn dataset',\n", |
816 | 869 | " task_type=TaskType.TabularClassification,\n", |
817 | 870 | " feature_names=feature_names,\n", |
818 | | - " categorical_features_map=categorical_map,\n", |
| 871 | + " categorical_feature_names=[\"Gender\", \"Geography\"],\n", |
819 | 872 | ")\n", |
820 | 873 | "dataset.to_dict()" |
821 | 874 | ] |
822 | 875 | }, |
823 | 876 | { |
824 | 877 | "cell_type": "code", |
825 | | - "execution_count": null, |
| 878 | + "execution_count": 16, |
826 | 879 | "id": "ace580e8", |
827 | 880 | "metadata": {}, |
828 | | - "outputs": [], |
| 881 | + "outputs": [ |
| 882 | + { |
| 883 | + "name": "stdout", |
| 884 | + "output_type": "stream", |
| 885 | + "text": [ |
| 886 | + "Bundling model and artifacts...\n", |
| 887 | + "Uploading model to Unbox...\n" |
| 888 | + ] |
| 889 | + }, |
| 890 | + { |
| 891 | + "data": { |
| 892 | + "text/plain": [ |
| 893 | + "{'classNames': ['Retained', 'Exited'],\n", |
| 894 | + " 'datasetCount': 0,\n", |
| 895 | + " 'dateCreated': '2022-07-06T21:07:38.167799Z',\n", |
| 896 | + " 'description': 'this is my churn classification model',\n", |
| 897 | + " 'featureNames': ['CreditScore',\n", |
| 898 | + " 'Geography',\n", |
| 899 | + " 'Gender',\n", |
| 900 | + " 'Age',\n", |
| 901 | + " 'Tenure',\n", |
| 902 | + " 'Balance',\n", |
| 903 | + " 'NumOfProducts',\n", |
| 904 | + " 'HasCrCard',\n", |
| 905 | + " 'IsActiveMember',\n", |
| 906 | + " 'EstimatedSalary'],\n", |
| 907 | + " 'featureSettings': None,\n", |
| 908 | + " 'id': 'f5785966-6df1-43a5-8721-ac81a2682e06',\n", |
| 909 | + " 'inProgressNotifications': ['model_f5785966-6df1-43a5-8721-ac81a2682e06_process_uploaded_model'],\n", |
| 910 | + " 'inferenceRunCount': 0,\n", |
| 911 | + " 'modelApi': None,\n", |
| 912 | + " 'name': 'Churn Classifier',\n", |
| 913 | + " 'projects': [],\n", |
| 914 | + " 'runReportCount': 0,\n", |
| 915 | + " 'taskType': 'tabular-classification',\n", |
| 916 | + " 'type': 'sklearn'}" |
| 917 | + ] |
| 918 | + }, |
| 919 | + "execution_count": 16, |
| 920 | + "metadata": {}, |
| 921 | + "output_type": "execute_result" |
| 922 | + } |
| 923 | + ], |
829 | 924 | "source": [ |
830 | 925 | "model = client.add_model(\n", |
831 | 926 | " function=predict_proba, \n", |
|
838 | 933 | " feature_names=feature_names,\n", |
839 | 934 | " train_sample_df=x_train[:3000],\n", |
840 | 935 | " train_sample_label_column_name='churn',\n", |
841 | | - " categorical_features_map=categorical_map,\n", |
| 936 | + " categorical_feature_names=[\"Gender\", \"Geography\"],\n", |
842 | 937 | " col_names=feature_names,\n", |
843 | 938 | " one_hot_encoder=data_encode_one_hot,\n", |
844 | 939 | " encoders=encoders,\n", |
845 | 940 | ")\n", |
846 | 941 | "model.to_dict()" |
847 | 942 | ] |
| 943 | + }, |
| 944 | + { |
| 945 | + "cell_type": "code", |
| 946 | + "execution_count": null, |
| 947 | + "id": "74cae32f", |
| 948 | + "metadata": {}, |
| 949 | + "outputs": [], |
| 950 | + "source": [] |
848 | 951 | } |
849 | 952 | ], |
850 | 953 | "metadata": { |
|
863 | 966 | "name": "python", |
864 | 967 | "nbconvert_exporter": "python", |
865 | 968 | "pygments_lexer": "ipython3", |
866 | | - "version": "3.8.10" |
| 969 | + "version": "3.8.13" |
867 | 970 | } |
868 | 971 | }, |
869 | 972 | "nbformat": 4, |
|
0 commit comments