{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%pip install fastapi\n", "%pip install uvicorn\n", "%pip install librosa\n", "%pip install xgboost\n", "%pip install pandas" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import datetime\n", "import string\n", "import random\n", "from pycaret.classification import *" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
 DescriptionValue
0session_id233
1Targetlabel
2Target TypeBinary
3Label Encoded0.0: 0, 1.0: 1
4Original Data(64800, 11)
5Missing Values0
6Numeric Features8
7Categorical Features2
8Ordinal Features0
9High Cardinality Features0
10High Cardinality MethodNone
11Transformed Train Set(45359, 19)
12Transformed Test Set(19441, 19)
13Shuffle Train-TestTrue
14Stratify Train-TestFalse
15Fold GeneratorStratifiedKFold
16Fold Number10
17CPU Jobs-1
18Use GPU0
19Log Experiment0
20Experiment Nameclf-default-name
21USI0b4d
22Imputation Typesimple
23Iterative Imputation IterationNone
24Numeric Imputermean
25Iterative Imputation Numeric ModelNone
26Categorical Imputerconstant
27Iterative Imputation Categorical ModelNone
28Unknown Categoricals Handlingleast_frequent
29Normalize0
30Normalize MethodNone
31Transformation0
32Transformation MethodNone
33PCA0
34PCA MethodNone
35PCA ComponentsNone
36Ignore Low Variance0
37Combine Rare Levels0
38Rare Level ThresholdNone
39Numeric Binning0
40Remove Outliers0
41Outliers ThresholdNone
42Remove Multicollinearity0
43Multicollinearity ThresholdNone
44Remove Perfect Collinearity1
45Clustering0
46Clustering IterationNone
47Polynomial Features0
48Polynomial DegreeNone
49Trignometry Features0
50Polynomial ThresholdNone
51Group Features0
52Feature Selection0
53Feature Selection Methodclassic
54Features Selection ThresholdNone
55Feature Interaction0
56Feature Ratio0
57Interaction ThresholdNone
58Fix Imbalance0
59Fix Imbalance MethodSMOTE
\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# data = pd.read_csv('data/data_feature_eng.csv')\n", "data = pd.read_csv('data/feature_ori.csv')\n", "# print(data)\n", "m_setup = setup(data=data, target='label', normalize=False, \n", " feature_interaction=False,\n", " feature_ratio=False,\n", " trigonometry_features=False,\n", " use_gpu=False)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Transformation Pipeline and Model Successfully Loaded\n" ] } ], "source": [ "# plot_model(tuned_dt, plot='auc')\n", "mdl = load_model('tuned_xgboost_orifeature_0323')" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1.0" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# plot_model(mdl, plot='auc')\n", "# evaluate_model(mdl)\n", "new_prediction = predict_model(mdl, data=data)\n", "from pycaret.utils import check_metric\n", "check_metric(new_prediction['label'], new_prediction['label'], metric = 'Accuracy')" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "API sucessfully created. This function only creates a POST API, it doesn't run it automatically.\n", "\n", "To run your API, please run this command --> !python my_api.py\n", " \n" ] } ], "source": [ "create_api(mdl, 'my_api')\n", "# !python my_api.py" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Writing requirements.txt\n", "Writing Dockerfile\n", "Dockerfile and requirements.txt successfully created.\n", "To build image you have to run --> !docker image build -f \"Dockerfile\" -t IMAGE_NAME:IMAGE_TAG .\n", " \n" ] } ], "source": [ "create_docker('my_api')\n", "# !docker image build -f \"Dockerfile\" -t my_api:latest ." ] } ], "metadata": { "interpreter": { "hash": "916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1" }, "kernelspec": { "display_name": "Python 3.8.10 64-bit", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.8" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }