slickdata commited on
Commit
f8130a1
·
1 Parent(s): c707469

First Commit

Browse files
Files changed (5) hide show
  1. CP_App.ipynb +681 -0
  2. Telco-Customer-Churn.csv +0 -0
  3. app.py +64 -0
  4. best_model.joblib +3 -0
  5. requirements.txt +437 -0
CP_App.ipynb ADDED
@@ -0,0 +1,681 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nbformat": 4,
3
+ "nbformat_minor": 0,
4
+ "metadata": {
5
+ "colab": {
6
+ "provenance": []
7
+ },
8
+ "kernelspec": {
9
+ "name": "python3",
10
+ "display_name": "Python 3"
11
+ },
12
+ "language_info": {
13
+ "name": "python"
14
+ }
15
+ },
16
+ "cells": [
17
+ {
18
+ "cell_type": "code",
19
+ "execution_count": 1,
20
+ "metadata": {
21
+ "colab": {
22
+ "base_uri": "https://localhost:8080/"
23
+ },
24
+ "id": "K1JbMys043S_",
25
+ "outputId": "c60da538-342e-4d5d-b678-0acdcf4f1976"
26
+ },
27
+ "outputs": [
28
+ {
29
+ "output_type": "stream",
30
+ "name": "stdout",
31
+ "text": [
32
+ "Mounted at /content/drive\n"
33
+ ]
34
+ }
35
+ ],
36
+ "source": [
37
+ "from google.colab import drive\n",
38
+ "drive.mount('/content/drive')"
39
+ ]
40
+ },
41
+ {
42
+ "cell_type": "code",
43
+ "source": [
44
+ "!pip install gradio"
45
+ ],
46
+ "metadata": {
47
+ "colab": {
48
+ "base_uri": "https://localhost:8080/"
49
+ },
50
+ "id": "IbZYtX6k45IY",
51
+ "outputId": "c9221d56-1854-47ca-e1b9-41e4ee641859"
52
+ },
53
+ "execution_count": 2,
54
+ "outputs": [
55
+ {
56
+ "output_type": "stream",
57
+ "name": "stdout",
58
+ "text": [
59
+ "Collecting gradio\n",
60
+ " Downloading gradio-3.36.1-py3-none-any.whl (19.8 MB)\n",
61
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m19.8/19.8 MB\u001b[0m \u001b[31m55.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
62
+ "\u001b[?25hCollecting aiofiles (from gradio)\n",
63
+ " Downloading aiofiles-23.1.0-py3-none-any.whl (14 kB)\n",
64
+ "Requirement already satisfied: aiohttp in /usr/local/lib/python3.10/dist-packages (from gradio) (3.8.4)\n",
65
+ "Requirement already satisfied: altair>=4.2.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (4.2.2)\n",
66
+ "Collecting fastapi (from gradio)\n",
67
+ " Downloading fastapi-0.100.0-py3-none-any.whl (65 kB)\n",
68
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m65.7/65.7 kB\u001b[0m \u001b[31m7.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
69
+ "\u001b[?25hCollecting ffmpy (from gradio)\n",
70
+ " Downloading ffmpy-0.3.0.tar.gz (4.8 kB)\n",
71
+ " Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
72
+ "Collecting gradio-client>=0.2.7 (from gradio)\n",
73
+ " Downloading gradio_client-0.2.7-py3-none-any.whl (288 kB)\n",
74
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m288.4/288.4 kB\u001b[0m \u001b[31m28.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
75
+ "\u001b[?25hCollecting httpx (from gradio)\n",
76
+ " Downloading httpx-0.24.1-py3-none-any.whl (75 kB)\n",
77
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m75.4/75.4 kB\u001b[0m \u001b[31m7.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
78
+ "\u001b[?25hCollecting huggingface-hub>=0.14.0 (from gradio)\n",
79
+ " Downloading huggingface_hub-0.16.4-py3-none-any.whl (268 kB)\n",
80
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m268.8/268.8 kB\u001b[0m \u001b[31m21.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
81
+ "\u001b[?25hRequirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.1.2)\n",
82
+ "Requirement already satisfied: markdown-it-py[linkify]>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.0.0)\n",
83
+ "Requirement already satisfied: markupsafe in /usr/local/lib/python3.10/dist-packages (from gradio) (2.1.3)\n",
84
+ "Requirement already satisfied: matplotlib in /usr/local/lib/python3.10/dist-packages (from gradio) (3.7.1)\n",
85
+ "Collecting mdit-py-plugins<=0.3.3 (from gradio)\n",
86
+ " Downloading mdit_py_plugins-0.3.3-py3-none-any.whl (50 kB)\n",
87
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m50.5/50.5 kB\u001b[0m \u001b[31m5.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
88
+ "\u001b[?25hRequirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from gradio) (1.22.4)\n",
89
+ "Collecting orjson (from gradio)\n",
90
+ " Downloading orjson-3.9.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (138 kB)\n",
91
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m138.7/138.7 kB\u001b[0m \u001b[31m16.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
92
+ "\u001b[?25hRequirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from gradio) (1.5.3)\n",
93
+ "Requirement already satisfied: pillow in /usr/local/lib/python3.10/dist-packages (from gradio) (8.4.0)\n",
94
+ "Requirement already satisfied: pydantic in /usr/local/lib/python3.10/dist-packages (from gradio) (1.10.9)\n",
95
+ "Collecting pydub (from gradio)\n",
96
+ " Downloading pydub-0.25.1-py2.py3-none-any.whl (32 kB)\n",
97
+ "Requirement already satisfied: pygments>=2.12.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.14.0)\n",
98
+ "Collecting python-multipart (from gradio)\n",
99
+ " Downloading python_multipart-0.0.6-py3-none-any.whl (45 kB)\n",
100
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m45.7/45.7 kB\u001b[0m \u001b[31m5.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
101
+ "\u001b[?25hRequirement already satisfied: pyyaml in /usr/local/lib/python3.10/dist-packages (from gradio) (6.0)\n",
102
+ "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from gradio) (2.27.1)\n",
103
+ "Collecting semantic-version (from gradio)\n",
104
+ " Downloading semantic_version-2.10.0-py2.py3-none-any.whl (15 kB)\n",
105
+ "Collecting uvicorn>=0.14.0 (from gradio)\n",
106
+ " Downloading uvicorn-0.22.0-py3-none-any.whl (58 kB)\n",
107
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m58.3/58.3 kB\u001b[0m \u001b[31m7.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
108
+ "\u001b[?25hCollecting websockets>=10.0 (from gradio)\n",
109
+ " Downloading websockets-11.0.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (129 kB)\n",
110
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m129.9/129.9 kB\u001b[0m \u001b[31m15.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
111
+ "\u001b[?25hRequirement already satisfied: entrypoints in /usr/local/lib/python3.10/dist-packages (from altair>=4.2.0->gradio) (0.4)\n",
112
+ "Requirement already satisfied: jsonschema>=3.0 in /usr/local/lib/python3.10/dist-packages (from altair>=4.2.0->gradio) (4.3.3)\n",
113
+ "Requirement already satisfied: toolz in /usr/local/lib/python3.10/dist-packages (from altair>=4.2.0->gradio) (0.12.0)\n",
114
+ "Requirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages (from gradio-client>=0.2.7->gradio) (2023.6.0)\n",
115
+ "Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from gradio-client>=0.2.7->gradio) (23.1)\n",
116
+ "Requirement already satisfied: typing-extensions in /usr/local/lib/python3.10/dist-packages (from gradio-client>=0.2.7->gradio) (4.6.3)\n",
117
+ "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.14.0->gradio) (3.12.2)\n",
118
+ "Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.14.0->gradio) (4.65.0)\n",
119
+ "Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/dist-packages (from markdown-it-py[linkify]>=2.0.0->gradio) (0.1.2)\n",
120
+ "Collecting linkify-it-py<3,>=1 (from markdown-it-py[linkify]>=2.0.0->gradio)\n",
121
+ " Downloading linkify_it_py-2.0.2-py3-none-any.whl (19 kB)\n",
122
+ "INFO: pip is looking at multiple versions of mdit-py-plugins to determine which version is compatible with other requirements. This could take a while.\n",
123
+ "Collecting mdit-py-plugins<=0.3.3 (from gradio)\n",
124
+ " Downloading mdit_py_plugins-0.3.2-py3-none-any.whl (50 kB)\n",
125
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m50.4/50.4 kB\u001b[0m \u001b[31m6.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
126
+ "\u001b[?25h Downloading mdit_py_plugins-0.3.1-py3-none-any.whl (46 kB)\n",
127
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m46.5/46.5 kB\u001b[0m \u001b[31m5.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
128
+ "\u001b[?25h Downloading mdit_py_plugins-0.3.0-py3-none-any.whl (43 kB)\n",
129
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m43.7/43.7 kB\u001b[0m \u001b[31m4.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
130
+ "\u001b[?25h Downloading mdit_py_plugins-0.2.8-py3-none-any.whl (41 kB)\n",
131
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m41.0/41.0 kB\u001b[0m \u001b[31m4.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
132
+ "\u001b[?25h Downloading mdit_py_plugins-0.2.7-py3-none-any.whl (41 kB)\n",
133
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m41.0/41.0 kB\u001b[0m \u001b[31m4.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
134
+ "\u001b[?25h Downloading mdit_py_plugins-0.2.6-py3-none-any.whl (39 kB)\n",
135
+ " Downloading mdit_py_plugins-0.2.5-py3-none-any.whl (39 kB)\n",
136
+ "INFO: pip is looking at multiple versions of mdit-py-plugins to determine which version is compatible with other requirements. This could take a while.\n",
137
+ " Downloading mdit_py_plugins-0.2.4-py3-none-any.whl (39 kB)\n",
138
+ " Downloading mdit_py_plugins-0.2.3-py3-none-any.whl (39 kB)\n",
139
+ " Downloading mdit_py_plugins-0.2.2-py3-none-any.whl (39 kB)\n",
140
+ " Downloading mdit_py_plugins-0.2.1-py3-none-any.whl (38 kB)\n",
141
+ " Downloading mdit_py_plugins-0.2.0-py3-none-any.whl (38 kB)\n",
142
+ "INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. See https://pip.pypa.io/warnings/backtracking for guidance. If you want to abort this run, press Ctrl + C.\n",
143
+ " Downloading mdit_py_plugins-0.1.0-py3-none-any.whl (37 kB)\n",
144
+ "Collecting markdown-it-py[linkify]>=2.0.0 (from gradio)\n",
145
+ " Downloading markdown_it_py-3.0.0-py3-none-any.whl (87 kB)\n",
146
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m87.5/87.5 kB\u001b[0m \u001b[31m8.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
147
+ "\u001b[?25h Downloading markdown_it_py-2.2.0-py3-none-any.whl (84 kB)\n",
148
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m84.5/84.5 kB\u001b[0m \u001b[31m10.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
149
+ "\u001b[?25hRequirement already satisfied: python-dateutil>=2.8.1 in /usr/local/lib/python3.10/dist-packages (from pandas->gradio) (2.8.2)\n",
150
+ "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas->gradio) (2022.7.1)\n",
151
+ "Requirement already satisfied: click>=7.0 in /usr/local/lib/python3.10/dist-packages (from uvicorn>=0.14.0->gradio) (8.1.3)\n",
152
+ "Collecting h11>=0.8 (from uvicorn>=0.14.0->gradio)\n",
153
+ " Downloading h11-0.14.0-py3-none-any.whl (58 kB)\n",
154
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m58.3/58.3 kB\u001b[0m \u001b[31m7.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
155
+ "\u001b[?25hRequirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->gradio) (23.1.0)\n",
156
+ "Requirement already satisfied: charset-normalizer<4.0,>=2.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->gradio) (2.0.12)\n",
157
+ "Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp->gradio) (6.0.4)\n",
158
+ "Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /usr/local/lib/python3.10/dist-packages (from aiohttp->gradio) (4.0.2)\n",
159
+ "Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp->gradio) (1.9.2)\n",
160
+ "Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp->gradio) (1.3.3)\n",
161
+ "Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp->gradio) (1.3.1)\n",
162
+ "Collecting starlette<0.28.0,>=0.27.0 (from fastapi->gradio)\n",
163
+ " Downloading starlette-0.27.0-py3-none-any.whl (66 kB)\n",
164
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m67.0/67.0 kB\u001b[0m \u001b[31m8.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
165
+ "\u001b[?25hRequirement already satisfied: certifi in /usr/local/lib/python3.10/dist-packages (from httpx->gradio) (2023.5.7)\n",
166
+ "Collecting httpcore<0.18.0,>=0.15.0 (from httpx->gradio)\n",
167
+ " Downloading httpcore-0.17.3-py3-none-any.whl (74 kB)\n",
168
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m74.5/74.5 kB\u001b[0m \u001b[31m6.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
169
+ "\u001b[?25hRequirement already satisfied: idna in /usr/local/lib/python3.10/dist-packages (from httpx->gradio) (3.4)\n",
170
+ "Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from httpx->gradio) (1.3.0)\n",
171
+ "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->gradio) (1.1.0)\n",
172
+ "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib->gradio) (0.11.0)\n",
173
+ "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib->gradio) (4.40.0)\n",
174
+ "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->gradio) (1.4.4)\n",
175
+ "Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->gradio) (3.1.0)\n",
176
+ "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->gradio) (1.26.16)\n",
177
+ "Requirement already satisfied: anyio<5.0,>=3.0 in /usr/local/lib/python3.10/dist-packages (from httpcore<0.18.0,>=0.15.0->httpx->gradio) (3.7.0)\n",
178
+ "Requirement already satisfied: pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=3.0->altair>=4.2.0->gradio) (0.19.3)\n",
179
+ "Collecting uc-micro-py (from linkify-it-py<3,>=1->markdown-it-py[linkify]>=2.0.0->gradio)\n",
180
+ " Downloading uc_micro_py-1.0.2-py3-none-any.whl (6.2 kB)\n",
181
+ "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.8.1->pandas->gradio) (1.16.0)\n",
182
+ "Requirement already satisfied: exceptiongroup in /usr/local/lib/python3.10/dist-packages (from anyio<5.0,>=3.0->httpcore<0.18.0,>=0.15.0->httpx->gradio) (1.1.1)\n",
183
+ "Building wheels for collected packages: ffmpy\n",
184
+ " Building wheel for ffmpy (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
185
+ " Created wheel for ffmpy: filename=ffmpy-0.3.0-py3-none-any.whl size=4694 sha256=833a310a70972f4ea4972633c44808b65fc42559afcf441a716536e3ceddfb1f\n",
186
+ " Stored in directory: /root/.cache/pip/wheels/0c/c2/0e/3b9c6845c6a4e35beb90910cc70d9ac9ab5d47402bd62af0df\n",
187
+ "Successfully built ffmpy\n",
188
+ "Installing collected packages: pydub, ffmpy, websockets, uc-micro-py, semantic-version, python-multipart, orjson, markdown-it-py, h11, aiofiles, uvicorn, starlette, mdit-py-plugins, linkify-it-py, huggingface-hub, httpcore, httpx, fastapi, gradio-client, gradio\n",
189
+ " Attempting uninstall: markdown-it-py\n",
190
+ " Found existing installation: markdown-it-py 3.0.0\n",
191
+ " Uninstalling markdown-it-py-3.0.0:\n",
192
+ " Successfully uninstalled markdown-it-py-3.0.0\n",
193
+ "Successfully installed aiofiles-23.1.0 fastapi-0.100.0 ffmpy-0.3.0 gradio-3.36.1 gradio-client-0.2.7 h11-0.14.0 httpcore-0.17.3 httpx-0.24.1 huggingface-hub-0.16.4 linkify-it-py-2.0.2 markdown-it-py-2.2.0 mdit-py-plugins-0.3.3 orjson-3.9.2 pydub-0.25.1 python-multipart-0.0.6 semantic-version-2.10.0 starlette-0.27.0 uc-micro-py-1.0.2 uvicorn-0.22.0 websockets-11.0.3\n"
194
+ ]
195
+ }
196
+ ]
197
+ },
198
+ {
199
+ "cell_type": "code",
200
+ "source": [
201
+ "import gradio as gr\n",
202
+ "import numpy as np\n",
203
+ "import pandas as pd\n",
204
+ "\n",
205
+ "from sklearn.pipeline import Pipeline\n",
206
+ "from sklearn.preprocessing import LabelEncoder, OneHotEncoder\n",
207
+ "from sklearn.ensemble import GradientBoostingClassifier\n",
208
+ "from sklearn.impute import SimpleImputer\n",
209
+ "from sklearn.compose import ColumnTransformer\n",
210
+ "from imblearn.over_sampling import ADASYN\n",
211
+ "from sklearn.preprocessing import StandardScaler\n",
212
+ "from sklearn.model_selection import train_test_split\n",
213
+ "from sklearn.model_selection import cross_val_score\n",
214
+ "from sklearn.metrics import confusion_matrix\n",
215
+ "from sklearn.metrics import classification_report\n",
216
+ "from sklearn.metrics import accuracy_score\n",
217
+ "from sklearn.metrics import roc_auc_score\n",
218
+ "from sklearn.metrics import roc_curve\n",
219
+ "from sklearn.metrics import precision_score, recall_score, f1_score\n",
220
+ "import sklearn.metrics as metrics\n",
221
+ "\n",
222
+ "from joblib import dump\n",
223
+ "import os\n",
224
+ "import warnings\n",
225
+ "warnings.filterwarnings('ignore')"
226
+ ],
227
+ "metadata": {
228
+ "id": "DuZ7ZW3E5Ge7"
229
+ },
230
+ "execution_count": 3,
231
+ "outputs": []
232
+ },
233
+ {
234
+ "cell_type": "code",
235
+ "source": [
236
+ "c_data = pd.read_csv('/content/drive/MyDrive/Colab Notebooks/Gradio/Telco-Customer-Churn.csv')\n",
237
+ "c_data.drop(['customerID','PhoneService','SeniorCitizen','StreamingMovies','StreamingTV'], axis=1, inplace=True)\n",
238
+ "c_data.info()"
239
+ ],
240
+ "metadata": {
241
+ "colab": {
242
+ "base_uri": "https://localhost:8080/"
243
+ },
244
+ "id": "nDm6h1Pl6tRd",
245
+ "outputId": "14740557-c7d4-40fa-9efb-e9882d6c42ed"
246
+ },
247
+ "execution_count": 4,
248
+ "outputs": [
249
+ {
250
+ "output_type": "stream",
251
+ "name": "stdout",
252
+ "text": [
253
+ "<class 'pandas.core.frame.DataFrame'>\n",
254
+ "RangeIndex: 7043 entries, 0 to 7042\n",
255
+ "Data columns (total 16 columns):\n",
256
+ " # Column Non-Null Count Dtype \n",
257
+ "--- ------ -------------- ----- \n",
258
+ " 0 gender 7043 non-null object \n",
259
+ " 1 Partner 7043 non-null object \n",
260
+ " 2 Dependents 7043 non-null object \n",
261
+ " 3 tenure 7043 non-null int64 \n",
262
+ " 4 MultipleLines 7043 non-null object \n",
263
+ " 5 InternetService 7043 non-null object \n",
264
+ " 6 OnlineSecurity 7043 non-null object \n",
265
+ " 7 OnlineBackup 7043 non-null object \n",
266
+ " 8 DeviceProtection 7043 non-null object \n",
267
+ " 9 TechSupport 7043 non-null object \n",
268
+ " 10 Contract 7043 non-null object \n",
269
+ " 11 PaperlessBilling 7043 non-null object \n",
270
+ " 12 PaymentMethod 7043 non-null object \n",
271
+ " 13 MonthlyCharges 7043 non-null float64\n",
272
+ " 14 TotalCharges 7043 non-null object \n",
273
+ " 15 Churn 7043 non-null object \n",
274
+ "dtypes: float64(1), int64(1), object(14)\n",
275
+ "memory usage: 880.5+ KB\n"
276
+ ]
277
+ }
278
+ ]
279
+ },
280
+ {
281
+ "cell_type": "code",
282
+ "source": [
283
+ "c_data['TotalCharges'] = pd.to_numeric(c_data['TotalCharges'], errors='coerce')\n",
284
+ "c_data.info()"
285
+ ],
286
+ "metadata": {
287
+ "colab": {
288
+ "base_uri": "https://localhost:8080/"
289
+ },
290
+ "id": "w_SwTyvi5GYI",
291
+ "outputId": "4e29588c-f81a-4d1e-d626-8a80b3f02ce9"
292
+ },
293
+ "execution_count": 5,
294
+ "outputs": [
295
+ {
296
+ "output_type": "stream",
297
+ "name": "stdout",
298
+ "text": [
299
+ "<class 'pandas.core.frame.DataFrame'>\n",
300
+ "RangeIndex: 7043 entries, 0 to 7042\n",
301
+ "Data columns (total 16 columns):\n",
302
+ " # Column Non-Null Count Dtype \n",
303
+ "--- ------ -------------- ----- \n",
304
+ " 0 gender 7043 non-null object \n",
305
+ " 1 Partner 7043 non-null object \n",
306
+ " 2 Dependents 7043 non-null object \n",
307
+ " 3 tenure 7043 non-null int64 \n",
308
+ " 4 MultipleLines 7043 non-null object \n",
309
+ " 5 InternetService 7043 non-null object \n",
310
+ " 6 OnlineSecurity 7043 non-null object \n",
311
+ " 7 OnlineBackup 7043 non-null object \n",
312
+ " 8 DeviceProtection 7043 non-null object \n",
313
+ " 9 TechSupport 7043 non-null object \n",
314
+ " 10 Contract 7043 non-null object \n",
315
+ " 11 PaperlessBilling 7043 non-null object \n",
316
+ " 12 PaymentMethod 7043 non-null object \n",
317
+ " 13 MonthlyCharges 7043 non-null float64\n",
318
+ " 14 TotalCharges 7032 non-null float64\n",
319
+ " 15 Churn 7043 non-null object \n",
320
+ "dtypes: float64(2), int64(1), object(13)\n",
321
+ "memory usage: 880.5+ KB\n"
322
+ ]
323
+ }
324
+ ]
325
+ },
326
+ {
327
+ "cell_type": "code",
328
+ "source": [
329
+ "# Removing missing values\n",
330
+ "c_data.dropna(inplace=True)\n",
331
+ "c_data.duplicated().sum()"
332
+ ],
333
+ "metadata": {
334
+ "colab": {
335
+ "base_uri": "https://localhost:8080/"
336
+ },
337
+ "id": "AuIXmyf_5GEm",
338
+ "outputId": "dbe796ae-7870-4cde-c81d-d1abb3da6382"
339
+ },
340
+ "execution_count": 6,
341
+ "outputs": [
342
+ {
343
+ "output_type": "execute_result",
344
+ "data": {
345
+ "text/plain": [
346
+ "26"
347
+ ]
348
+ },
349
+ "metadata": {},
350
+ "execution_count": 6
351
+ }
352
+ ]
353
+ },
354
+ {
355
+ "cell_type": "code",
356
+ "source": [
357
+ "#le = LabelEncoder()\n",
358
+ "#c_data['Churn'] = le.fit_transform(c_data['Churn'])\n",
359
+ "#c_data.head()"
360
+ ],
361
+ "metadata": {
362
+ "id": "EUI4hmnA8rcL"
363
+ },
364
+ "execution_count": 7,
365
+ "outputs": []
366
+ },
367
+ {
368
+ "cell_type": "code",
369
+ "source": [
370
+ "for col in c_data.columns:\n",
371
+ " print(f\"Column '{col}' categories: {c_data[col].unique()}\")"
372
+ ],
373
+ "metadata": {
374
+ "colab": {
375
+ "base_uri": "https://localhost:8080/"
376
+ },
377
+ "id": "2cyG_RbM_yX_",
378
+ "outputId": "558cfe16-f354-4681-b973-a9809d7bc5e8"
379
+ },
380
+ "execution_count": 8,
381
+ "outputs": [
382
+ {
383
+ "output_type": "stream",
384
+ "name": "stdout",
385
+ "text": [
386
+ "Column 'gender' categories: ['Female' 'Male']\n",
387
+ "Column 'Partner' categories: ['Yes' 'No']\n",
388
+ "Column 'Dependents' categories: ['No' 'Yes']\n",
389
+ "Column 'tenure' categories: [ 1 34 2 45 8 22 10 28 62 13 16 58 49 25 69 52 71 21 12 30 47 72 17 27\n",
390
+ " 5 46 11 70 63 43 15 60 18 66 9 3 31 50 64 56 7 42 35 48 29 65 38 68\n",
391
+ " 32 55 37 36 41 6 4 33 67 23 57 61 14 20 53 40 59 24 44 19 54 51 26 39]\n",
392
+ "Column 'MultipleLines' categories: ['No phone service' 'No' 'Yes']\n",
393
+ "Column 'InternetService' categories: ['DSL' 'Fiber optic' 'No']\n",
394
+ "Column 'OnlineSecurity' categories: ['No' 'Yes' 'No internet service']\n",
395
+ "Column 'OnlineBackup' categories: ['Yes' 'No' 'No internet service']\n",
396
+ "Column 'DeviceProtection' categories: ['No' 'Yes' 'No internet service']\n",
397
+ "Column 'TechSupport' categories: ['No' 'Yes' 'No internet service']\n",
398
+ "Column 'Contract' categories: ['Month-to-month' 'One year' 'Two year']\n",
399
+ "Column 'PaperlessBilling' categories: ['Yes' 'No']\n",
400
+ "Column 'PaymentMethod' categories: ['Electronic check' 'Mailed check' 'Bank transfer (automatic)'\n",
401
+ " 'Credit card (automatic)']\n",
402
+ "Column 'MonthlyCharges' categories: [29.85 56.95 53.85 ... 63.1 44.2 78.7 ]\n",
403
+ "Column 'TotalCharges' categories: [ 29.85 1889.5 108.15 ... 346.45 306.6 6844.5 ]\n",
404
+ "Column 'Churn' categories: ['No' 'Yes']\n"
405
+ ]
406
+ }
407
+ ]
408
+ },
409
+ {
410
+ "cell_type": "code",
411
+ "source": [
412
+ "y = c_data['Churn'] # Target Variable\n",
413
+ "X = c_data.drop('Churn', axis =1) # Independent Variable"
414
+ ],
415
+ "metadata": {
416
+ "id": "7pL-2l8T8rU3"
417
+ },
418
+ "execution_count": 9,
419
+ "outputs": []
420
+ },
421
+ {
422
+ "cell_type": "code",
423
+ "source": [
424
+ "numeric_transformer = Pipeline(steps = [('imputer',SimpleImputer(strategy = 'mean')),('scaler',StandardScaler())])\n",
425
+ "categorical_transformer = Pipeline(steps = [('imputer',SimpleImputer(strategy = 'most_frequent')),('one_hot_encoder',OneHotEncoder(handle_unknown='ignore', categories='auto', sparse=False))])"
426
+ ],
427
+ "metadata": {
428
+ "id": "HWA2tbQBJU2e"
429
+ },
430
+ "execution_count": 10,
431
+ "outputs": []
432
+ },
433
+ {
434
+ "cell_type": "code",
435
+ "source": [
436
+ "data_numeric =['tenure','MonthlyCharges','TotalCharges']\n",
437
+ "data_categorical =['gender','Partner','Dependents','MultipleLines','InternetService','OnlineSecurity','OnlineBackup','DeviceProtection','TechSupport','Contract','PaperlessBilling','PaymentMethod']\n",
438
+ "preprocessor =ColumnTransformer(transformers =[('numeric',numeric_transformer,data_numeric),('categoric',categorical_transformer,data_categorical)])"
439
+ ],
440
+ "metadata": {
441
+ "id": "ObJQIJ8RJxXl"
442
+ },
443
+ "execution_count": 11,
444
+ "outputs": []
445
+ },
446
+ {
447
+ "cell_type": "code",
448
+ "source": [
449
+ "# Identify numeric and non-numeric columns\n",
450
+ "#num_cols = X.select_dtypes(include=[np.number]).columns.tolist()\n",
451
+ "#cat_cols = X.select_dtypes(exclude=[np.number]).columns.tolist()\n",
452
+ "\n",
453
+ "#X_cat = X[cat_cols].copy()\n",
454
+ "#X_num = X[num_cols].copy()\n"
455
+ ],
456
+ "metadata": {
457
+ "id": "7T37-Hq78q95"
458
+ },
459
+ "execution_count": 12,
460
+ "outputs": []
461
+ },
462
+ {
463
+ "cell_type": "code",
464
+ "source": [
465
+ "# Creating imputer variables\n",
466
+ "#numerical_imputer = SimpleImputer(strategy = \"mean\")\n",
467
+ "#categorical_imputer = SimpleImputer(strategy = \"most_frequent\")\n",
468
+ "\n",
469
+ "\n",
470
+ "\n",
471
+ "# Define the column transformer\n",
472
+ "#categorical_features = cat_cols\n",
473
+ "#categorical_transformer = Pipeline(steps=[('ohc', OneHotEncoder(handle_unknown='ignore', categories='auto', sparse=False))])\n",
474
+ "#preprocessor = ColumnTransformer(transformers=[('cat', categorical_transformer, cat_cols)])\n"
475
+ ],
476
+ "metadata": {
477
+ "id": "Hx-SIs2K8q2M"
478
+ },
479
+ "execution_count": 13,
480
+ "outputs": []
481
+ },
482
+ {
483
+ "cell_type": "code",
484
+ "source": [
485
+ "# Fitting the Imputer\n",
486
+ "#X_cat_imputed = categorical_imputer.fit_transform(X_cat)\n",
487
+ "#X_num_imputed = numerical_imputer.fit_transform(X_num)"
488
+ ],
489
+ "metadata": {
490
+ "id": "LhfvzFX-KnCe"
491
+ },
492
+ "execution_count": 14,
493
+ "outputs": []
494
+ },
495
+ {
496
+ "cell_type": "code",
497
+ "source": [
498
+ "#ohe = OneHotEncoder(handle_unknown='ignore')\n",
499
+ "#X_cat_encoded = ohe.fit(X_cat_imputed)\n",
500
+ "#X_cat_encoded = pd.DataFrame(ohe.transform(X_cat_imputed).toarray(),\n",
501
+ "# columns=ohe.get_feature_names_out(cat_cols))\n",
502
+ "\n"
503
+ ],
504
+ "metadata": {
505
+ "id": "6N8dMlRuKm7k"
506
+ },
507
+ "execution_count": 15,
508
+ "outputs": []
509
+ },
510
+ {
511
+ "cell_type": "code",
512
+ "source": [
513
+ "#scaler = StandardScaler()\n",
514
+ "#X_num_scaled = scaler.fit_transform(X_num_imputed)\n",
515
+ "#X_num_sc = pd.DataFrame(X_num_scaled, columns = num_cols)\n",
516
+ "\n"
517
+ ],
518
+ "metadata": {
519
+ "id": "EtrHYrNcOvHM"
520
+ },
521
+ "execution_count": 16,
522
+ "outputs": []
523
+ },
524
+ {
525
+ "cell_type": "code",
526
+ "source": [
527
+ "#X_df = pd.concat([X_num_sc,X_cat_encoded], axis =1)"
528
+ ],
529
+ "metadata": {
530
+ "id": "aATpxlXiTA83"
531
+ },
532
+ "execution_count": 17,
533
+ "outputs": []
534
+ },
535
+ {
536
+ "cell_type": "code",
537
+ "source": [
538
+ "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=30)"
539
+ ],
540
+ "metadata": {
541
+ "id": "cxIt0C7TZ91X"
542
+ },
543
+ "execution_count": 18,
544
+ "outputs": []
545
+ },
546
+ {
547
+ "cell_type": "code",
548
+ "source": [
549
+ "gbc = GradientBoostingClassifier(learning_rate = 0.1, max_depth = 5, n_estimators=50, random_state=30)\n",
550
+ "gbc = Pipeline(steps =[('processor',preprocessor),('estimator',gbc)])\n",
551
+ "model = gbc.fit(X_train,y_train)\n",
552
+ "\n",
553
+ "# make predictions on the test data\n",
554
+ "y_pred = model.predict(X_test)\n",
555
+ "\n",
556
+ "# generate the classification report\n",
557
+ "report = classification_report(y_test, y_pred)\n",
558
+ "name = 'Gradient Boosting Classifier'\n",
559
+ "# print the classification report\n",
560
+ "print(f'{name} classification report:\\n{report}\\n')\n"
561
+ ],
562
+ "metadata": {
563
+ "id": "DRT-nIuvOu9y",
564
+ "colab": {
565
+ "base_uri": "https://localhost:8080/"
566
+ },
567
+ "outputId": "ca6a84f9-cf35-4bdb-aaa4-c0155128580c"
568
+ },
569
+ "execution_count": 19,
570
+ "outputs": [
571
+ {
572
+ "output_type": "stream",
573
+ "name": "stdout",
574
+ "text": [
575
+ "Gradient Boosting Classifier classification report:\n",
576
+ " precision recall f1-score support\n",
577
+ "\n",
578
+ " No 0.83 0.89 0.86 1031\n",
579
+ " Yes 0.64 0.51 0.57 376\n",
580
+ "\n",
581
+ " accuracy 0.79 1407\n",
582
+ " macro avg 0.74 0.70 0.72 1407\n",
583
+ "weighted avg 0.78 0.79 0.78 1407\n",
584
+ "\n",
585
+ "\n"
586
+ ]
587
+ }
588
+ ]
589
+ },
590
+ {
591
+ "cell_type": "code",
592
+ "source": [
593
+ " # create a dictionary of a model to fit\n",
594
+ " #models = {'Gradient Boosting Classifier': GradientBoostingClassifier(learning_rate = 0.1, max_depth = 5, n_estimators=50, random_state=30),}\n",
595
+ " # iterate over the models and fit each one to the resampled training data\n",
596
+ " #for name, model in models.items():\n",
597
+ " # model.fit(X_train, y_train)\n",
598
+ "\n",
599
+ " # evaluate each model using cross-validation based on ROC-AUC\n",
600
+ " #roc_auc_scores = {}\n",
601
+ " #for name, model in models.items():\n",
602
+ " # scores = cross_val_score(model, X_train, y_train, cv=5, scoring='roc_auc')\n",
603
+ " # roc_auc_scores[name] = scores.mean()\n",
604
+ "\n",
605
+ " # print the ROC-AUC scores for each model\n",
606
+ " #for name, score in roc_auc_scores.items():\n",
607
+ " # print(f'{name}: {score}')\n",
608
+ "\n",
609
+ " # choose the model with the highest ROC-AUC score\n",
610
+ " #best_model_name = max(roc_auc_scores, key=roc_auc_scores.get)\n",
611
+ " #best_model = models[best_model_name]\n",
612
+ " #print(f'Best model: {best_model_name}')\n",
613
+ "\n",
614
+ "\n",
615
+ " # iterate over the models and make predictions on the test data for each one\n",
616
+ " #for name, model in models.items():\n",
617
+ " # fit the model to the resampled training data\n",
618
+ " # model.fit(X_train, y_train)\n",
619
+ " # make predictions on the test data\n",
620
+ " # y_pred = model.predict(X_test)\n",
621
+ " # generate the classification report\n",
622
+ " # report = classification_report(y_test, y_pred)\n",
623
+ " # print the classification report\n",
624
+ " # print(f'{name} classification report:\\n{report}\\n')\n",
625
+ "\n",
626
+ "\n"
627
+ ],
628
+ "metadata": {
629
+ "id": "XW_eIe9ROu2s"
630
+ },
631
+ "execution_count": 20,
632
+ "outputs": []
633
+ },
634
+ {
635
+ "cell_type": "code",
636
+ "source": [
637
+ "# set the destination path to the \"export\" directory\n",
638
+ "destination = \".\"\n",
639
+ "\n",
640
+ "#best_model = gbc\n",
641
+ "models = {\"best_model\": gbc}\n",
642
+ "\n",
643
+ "# loop through the models and save them using joblib.dump()\n",
644
+ "for name, model in models.items():\n",
645
+ " dump(model, os.path.join(destination, f\"{name}.joblib\"))\n"
646
+ ],
647
+ "metadata": {
648
+ "id": "cVzILcaoOusD"
649
+ },
650
+ "execution_count": 21,
651
+ "outputs": []
652
+ },
653
+ {
654
+ "cell_type": "code",
655
+ "source": [
656
+ "!pip freeze > requirements.txt"
657
+ ],
658
+ "metadata": {
659
+ "id": "HrsFQmUROufW"
660
+ },
661
+ "execution_count": 22,
662
+ "outputs": []
663
+ },
664
+ {
665
+ "cell_type": "code",
666
+ "source": [
667
+ "#for name, model in models.items():\n",
668
+ "# dump(model, os.path.join(destination, f\"{name}.joblib\"))\n",
669
+ "# if os.path.exists(os.path.join(destination, f\"{name}.joblib\")):\n",
670
+ "# print(f\"{name} saved successfully!\")\n",
671
+ "# else:\n",
672
+ "# print(f\"{name} failed to save.\")"
673
+ ],
674
+ "metadata": {
675
+ "id": "xsrbuX4JKmnR"
676
+ },
677
+ "execution_count": 23,
678
+ "outputs": []
679
+ }
680
+ ]
681
+ }
Telco-Customer-Churn.csv ADDED
The diff for this file is too large to render. See raw diff
 
app.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pickle
3
+ import pandas as pd
4
+ import numpy as np
5
+ import joblib
6
+ from gradio.components import *
7
+
8
+
9
+ #define prediction function
10
+ def make_prediction(gender, Partner, Dependents, tenure, MultipleLines,
11
+ InternetService, OnlineSecurity, OnlineBackup, DeviceProtection,
12
+ TechSupport, Contract, PaperlessBilling, PaymentMethod,
13
+ MonthlyCharges, TotalCharges):
14
+ #make a dataframe from input data
15
+ input_data = pd.DataFrame({'gender':[gender], 'Partner':[Partner], 'Dependents':[Dependents], 'tenure':[tenure], 'MultipleLines':[MultipleLines],
16
+ 'InternetService':[InternetService], 'OnlineSecurity':[OnlineSecurity], 'OnlineBackup':[OnlineBackup], 'DeviceProtection':[DeviceProtection],
17
+ 'TechSupport':[TechSupport], 'Contract':[Contract], 'PaperlessBilling':[PaperlessBilling], 'PaymentMethod':[PaymentMethod],
18
+ 'MonthlyCharges':[MonthlyCharges], 'TotalCharges':[TotalCharges]})
19
+
20
+ #load already saved pipeline and make predictions
21
+ with open("best_model.joblib", "rb") as f:
22
+ model = joblib.load(f)
23
+ predt = model.predict(input_data)
24
+ #return prediction
25
+ if predt == 'Yes':
26
+ return 'Customer Will Churn'
27
+ return 'Customer Will Not Churn'
28
+
29
+ #create the input components for gradio
30
+ gender_input = gr.Dropdown(choices =['Female', 'Male'])
31
+ Partner_input = gr.Dropdown(choices =['Yes', 'No'])
32
+ Dependents_input = gr.Dropdown(choices =['Yes', 'No'])
33
+ tenure_input = gr.Number()
34
+ MultipleLines_input = gr.Dropdown(choices =['No phone service', 'No', 'Yes'])
35
+ InternetService_input = gr.Dropdown(choices =['DSL', 'Fiber optic', 'No'])
36
+ OnlineSecurity_input = gr.Dropdown(choices =['No', 'Yes', 'No internet service'])
37
+ OnlineBackup_input = gr.Dropdown(choices =['Yes', 'No', 'No internet service'])
38
+ DeviceProtection_input = gr.Dropdown(choices =['No', 'Yes', 'No internet service'])
39
+ TechSupport_input = gr.Dropdown(choices =['No', 'Yes', 'No internet service'])
40
+ Contract_input = gr.Dropdown(choices =['Month-to-month', 'One year', 'Two year'])
41
+ PaperlessBilling_input = gr.Dropdown(choices =['Yes', 'No'])
42
+ PaymentMethod_input = gr.Dropdown(choices =['Electronic check', 'Mailed check', 'Bank transfer (automatic)','Credit card (automatic)'])
43
+ MonthlyCharges_input = gr.Number()
44
+ TotalCharges_input = gr.Number()
45
+
46
+ output = gr.Textbox(label='Prediction')
47
+
48
+ app = gr.Interface(fn =make_prediction, inputs =[gender_input,
49
+ Partner_input,
50
+ Dependents_input,
51
+ tenure_input,
52
+ MultipleLines_input,
53
+ InternetService_input,
54
+ OnlineSecurity_input,
55
+ OnlineBackup_input,
56
+ DeviceProtection_input,
57
+ TechSupport_input,
58
+ Contract_input,
59
+ PaperlessBilling_input,
60
+ PaymentMethod_input,
61
+ MonthlyCharges_input,
62
+ TotalCharges_input], outputs = output)
63
+
64
+ app.launch(share = True, debug = True)
best_model.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:370a1b9437b5c3cd19fb983d819a9b554a1bfd8b1a5a9dd130cc110cfb05f067
3
+ size 321499
requirements.txt ADDED
@@ -0,0 +1,437 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ absl-py==1.4.0
2
+ aiofiles==23.1.0
3
+ aiohttp==3.8.4
4
+ aiosignal==1.3.1
5
+ alabaster==0.7.13
6
+ albumentations==1.2.1
7
+ altair==4.2.2
8
+ anyio==3.7.0
9
+ appdirs==1.4.4
10
+ argon2-cffi==21.3.0
11
+ argon2-cffi-bindings==21.2.0
12
+ array-record==0.4.0
13
+ arviz==0.15.1
14
+ astropy==5.2.2
15
+ astunparse==1.6.3
16
+ async-timeout==4.0.2
17
+ attrs==23.1.0
18
+ audioread==3.0.0
19
+ autograd==1.6.1
20
+ Babel==2.12.1
21
+ backcall==0.2.0
22
+ beautifulsoup4==4.11.2
23
+ bleach==6.0.0
24
+ blis==0.7.9
25
+ blosc2==2.0.0
26
+ bokeh==2.4.3
27
+ branca==0.6.0
28
+ build==0.10.0
29
+ CacheControl==0.13.1
30
+ cached-property==1.5.2
31
+ cachetools==5.3.1
32
+ catalogue==2.0.8
33
+ certifi==2023.5.7
34
+ cffi==1.15.1
35
+ chardet==4.0.0
36
+ charset-normalizer==2.0.12
37
+ chex==0.1.7
38
+ click==8.1.3
39
+ click-plugins==1.1.1
40
+ cligj==0.7.2
41
+ cloudpickle==2.2.1
42
+ cmake==3.25.2
43
+ cmdstanpy==1.1.0
44
+ colorcet==3.0.1
45
+ colorlover==0.3.0
46
+ community==1.0.0b1
47
+ confection==0.0.4
48
+ cons==0.4.6
49
+ contextlib2==0.6.0.post1
50
+ contourpy==1.1.0
51
+ convertdate==2.4.0
52
+ cufflinks==0.17.3
53
+ cvxopt==1.3.1
54
+ cvxpy==1.3.1
55
+ cycler==0.11.0
56
+ cymem==2.0.7
57
+ Cython==0.29.35
58
+ dask==2022.12.1
59
+ datascience==0.17.6
60
+ db-dtypes==1.1.1
61
+ dbus-python==1.2.16
62
+ debugpy==1.6.6
63
+ decorator==4.4.2
64
+ defusedxml==0.7.1
65
+ distributed==2022.12.1
66
+ dlib==19.24.2
67
+ dm-tree==0.1.8
68
+ docutils==0.16
69
+ dopamine-rl==4.0.6
70
+ duckdb==0.8.1
71
+ earthengine-api==0.1.357
72
+ easydict==1.10
73
+ ecos==2.0.12
74
+ editdistance==0.6.2
75
+ en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.5.0/en_core_web_sm-3.5.0-py3-none-any.whl#sha256=0964370218b7e1672a30ac50d72cdc6b16f7c867496f1d60925691188f4d2510
76
+ entrypoints==0.4
77
+ ephem==4.1.4
78
+ et-xmlfile==1.1.0
79
+ etils==1.3.0
80
+ etuples==0.3.9
81
+ exceptiongroup==1.1.1
82
+ fastai==2.7.12
83
+ fastapi==0.100.0
84
+ fastcore==1.5.29
85
+ fastdownload==0.0.7
86
+ fastjsonschema==2.17.1
87
+ fastprogress==1.0.3
88
+ fastrlock==0.8.1
89
+ ffmpy==0.3.0
90
+ filelock==3.12.2
91
+ Fiona==1.9.4.post1
92
+ firebase-admin==5.3.0
93
+ Flask==2.2.5
94
+ flatbuffers==23.5.26
95
+ flax==0.6.11
96
+ folium==0.14.0
97
+ fonttools==4.40.0
98
+ frozendict==2.3.8
99
+ frozenlist==1.3.3
100
+ fsspec==2023.6.0
101
+ future==0.18.3
102
+ gast==0.4.0
103
+ gcsfs==2023.6.0
104
+ GDAL==3.3.2
105
+ gdown==4.6.6
106
+ gensim==4.3.1
107
+ geographiclib==2.0
108
+ geopandas==0.13.2
109
+ geopy==2.3.0
110
+ gin-config==0.5.0
111
+ glob2==0.7
112
+ google==2.0.3
113
+ google-api-core==2.11.1
114
+ google-api-python-client==2.84.0
115
+ google-auth==2.17.3
116
+ google-auth-httplib2==0.1.0
117
+ google-auth-oauthlib==1.0.0
118
+ google-cloud-bigquery==3.10.0
119
+ google-cloud-bigquery-connection==1.12.0
120
+ google-cloud-bigquery-storage==2.20.0
121
+ google-cloud-core==2.3.2
122
+ google-cloud-datastore==2.15.2
123
+ google-cloud-firestore==2.11.1
124
+ google-cloud-functions==1.13.0
125
+ google-cloud-language==2.9.1
126
+ google-cloud-storage==2.8.0
127
+ google-cloud-translate==3.11.1
128
+ google-colab @ file:///colabtools/dist/google-colab-1.0.0.tar.gz#sha256=65ade0f57298e1ede1ee6fe8aaf53f99c32267220c3fd7615c9c7848d2597b9b
129
+ google-crc32c==1.5.0
130
+ google-pasta==0.2.0
131
+ google-resumable-media==2.5.0
132
+ googleapis-common-protos==1.59.1
133
+ googledrivedownloader==0.4
134
+ gradio==3.36.1
135
+ gradio_client==0.2.7
136
+ graphviz==0.20.1
137
+ greenlet==2.0.2
138
+ grpc-google-iam-v1==0.12.6
139
+ grpcio==1.56.0
140
+ grpcio-status==1.48.2
141
+ gspread==3.4.2
142
+ gspread-dataframe==3.0.8
143
+ gym==0.25.2
144
+ gym-notices==0.0.8
145
+ h11==0.14.0
146
+ h5netcdf==1.2.0
147
+ h5py==3.8.0
148
+ holidays==0.27.1
149
+ holoviews==1.15.4
150
+ html5lib==1.1
151
+ httpcore==0.17.3
152
+ httpimport==1.3.0
153
+ httplib2==0.21.0
154
+ httpx==0.24.1
155
+ huggingface-hub==0.16.4
156
+ humanize==4.6.0
157
+ hyperopt==0.2.7
158
+ idna==3.4
159
+ imageio==2.25.1
160
+ imageio-ffmpeg==0.4.8
161
+ imagesize==1.4.1
162
+ imbalanced-learn==0.10.1
163
+ imgaug==0.4.0
164
+ importlib-resources==5.12.0
165
+ imutils==0.5.4
166
+ inflect==6.0.4
167
+ iniconfig==2.0.0
168
+ intel-openmp==2023.1.0
169
+ ipykernel==5.5.6
170
+ ipython==7.34.0
171
+ ipython-genutils==0.2.0
172
+ ipython-sql==0.4.1
173
+ ipywidgets==7.7.1
174
+ itsdangerous==2.1.2
175
+ jax==0.4.10
176
+ jaxlib @ https://storage.googleapis.com/jax-releases/cuda11/jaxlib-0.4.10+cuda11.cudnn86-cp310-cp310-manylinux2014_x86_64.whl#sha256=fe53205ef12727c80ed5ac2d4506d6732c0c3db69ede4565a7d4df98e609af84
177
+ jieba==0.42.1
178
+ Jinja2==3.1.2
179
+ joblib==1.2.0
180
+ jsonpickle==3.0.1
181
+ jsonschema==4.3.3
182
+ jupyter-client==6.1.12
183
+ jupyter-console==6.1.0
184
+ jupyter-server==1.24.0
185
+ jupyter_core==5.3.1
186
+ jupyterlab-pygments==0.2.2
187
+ jupyterlab-widgets==3.0.7
188
+ kaggle==1.5.13
189
+ keras==2.12.0
190
+ kiwisolver==1.4.4
191
+ langcodes==3.3.0
192
+ lazy_loader==0.2
193
+ libclang==16.0.0
194
+ librosa==0.10.0.post2
195
+ lightgbm==3.3.5
196
+ linkify-it-py==2.0.2
197
+ lit==16.0.6
198
+ llvmlite==0.39.1
199
+ locket==1.0.0
200
+ logical-unification==0.4.6
201
+ LunarCalendar==0.0.9
202
+ lxml==4.9.2
203
+ Markdown==3.4.3
204
+ markdown-it-py==2.2.0
205
+ MarkupSafe==2.1.3
206
+ matplotlib==3.7.1
207
+ matplotlib-inline==0.1.6
208
+ matplotlib-venn==0.11.9
209
+ mdit-py-plugins==0.3.3
210
+ mdurl==0.1.2
211
+ miniKanren==1.0.3
212
+ missingno==0.5.2
213
+ mistune==0.8.4
214
+ mizani==0.8.1
215
+ mkl==2019.0
216
+ ml-dtypes==0.2.0
217
+ mlxtend==0.14.0
218
+ more-itertools==9.1.0
219
+ moviepy==1.0.3
220
+ mpmath==1.3.0
221
+ msgpack==1.0.5
222
+ multidict==6.0.4
223
+ multipledispatch==0.6.0
224
+ multitasking==0.0.11
225
+ murmurhash==1.0.9
226
+ music21==8.1.0
227
+ natsort==8.3.1
228
+ nbclient==0.8.0
229
+ nbconvert==6.5.4
230
+ nbformat==5.9.0
231
+ nest-asyncio==1.5.6
232
+ networkx==3.1
233
+ nibabel==3.0.2
234
+ nltk==3.8.1
235
+ notebook==6.4.8
236
+ numba==0.56.4
237
+ numexpr==2.8.4
238
+ numpy==1.22.4
239
+ oauth2client==4.1.3
240
+ oauthlib==3.2.2
241
+ opencv-contrib-python==4.7.0.72
242
+ opencv-python==4.7.0.72
243
+ opencv-python-headless==4.7.0.72
244
+ openpyxl==3.0.10
245
+ opt-einsum==3.3.0
246
+ optax==0.1.5
247
+ orbax-checkpoint==0.2.6
248
+ orjson==3.9.2
249
+ osqp==0.6.2.post8
250
+ packaging==23.1
251
+ palettable==3.3.3
252
+ pandas==1.5.3
253
+ pandas-datareader==0.10.0
254
+ pandas-gbq==0.17.9
255
+ pandocfilters==1.5.0
256
+ panel==0.14.4
257
+ param==1.13.0
258
+ parso==0.8.3
259
+ partd==1.4.0
260
+ pathlib==1.0.1
261
+ pathy==0.10.2
262
+ patsy==0.5.3
263
+ pexpect==4.8.0
264
+ pickleshare==0.7.5
265
+ Pillow==8.4.0
266
+ pip-tools==6.13.0
267
+ platformdirs==3.7.0
268
+ plotly==5.13.1
269
+ plotnine==0.10.1
270
+ pluggy==1.2.0
271
+ polars==0.17.3
272
+ pooch==1.6.0
273
+ portpicker==1.5.2
274
+ prefetch-generator==1.0.3
275
+ preshed==3.0.8
276
+ prettytable==0.7.2
277
+ proglog==0.1.10
278
+ progressbar2==4.2.0
279
+ prometheus-client==0.17.0
280
+ promise==2.3
281
+ prompt-toolkit==3.0.38
282
+ prophet==1.1.4
283
+ proto-plus==1.22.3
284
+ protobuf==3.20.3
285
+ psutil==5.9.5
286
+ psycopg2==2.9.6
287
+ ptyprocess==0.7.0
288
+ py-cpuinfo==9.0.0
289
+ py4j==0.10.9.7
290
+ pyarrow==9.0.0
291
+ pyasn1==0.5.0
292
+ pyasn1-modules==0.3.0
293
+ pycocotools==2.0.6
294
+ pycparser==2.21
295
+ pyct==0.5.0
296
+ pydantic==1.10.9
297
+ pydata-google-auth==1.8.0
298
+ pydot==1.4.2
299
+ pydot-ng==2.0.0
300
+ pydotplus==2.0.2
301
+ PyDrive==1.3.1
302
+ pydub==0.25.1
303
+ pyerfa==2.0.0.3
304
+ pygame==2.4.0
305
+ Pygments==2.14.0
306
+ PyGObject==3.36.0
307
+ pymc==5.1.2
308
+ PyMeeus==0.5.12
309
+ pymystem3==0.2.0
310
+ PyOpenGL==3.1.7
311
+ pyparsing==3.1.0
312
+ pyproj==3.6.0
313
+ pyproject_hooks==1.0.0
314
+ pyrsistent==0.19.3
315
+ PySocks==1.7.1
316
+ pytensor==2.10.1
317
+ pytest==7.2.2
318
+ python-apt==0.0.0
319
+ python-dateutil==2.8.2
320
+ python-louvain==0.16
321
+ python-multipart==0.0.6
322
+ python-slugify==8.0.1
323
+ python-utils==3.7.0
324
+ pytz==2022.7.1
325
+ pyviz-comms==2.3.2
326
+ PyWavelets==1.4.1
327
+ PyYAML==6.0
328
+ pyzmq==23.2.1
329
+ qdldl==0.1.7
330
+ qudida==0.0.4
331
+ regex==2022.10.31
332
+ requests==2.27.1
333
+ requests-oauthlib==1.3.1
334
+ requests-unixsocket==0.2.0
335
+ requirements-parser==0.5.0
336
+ rich==13.4.2
337
+ rpy2==3.5.5
338
+ rsa==4.9
339
+ scikit-image==0.19.3
340
+ scikit-learn==1.2.2
341
+ scipy==1.10.1
342
+ scs==3.2.3
343
+ seaborn==0.12.2
344
+ semantic-version==2.10.0
345
+ Send2Trash==1.8.2
346
+ shapely==2.0.1
347
+ six==1.16.0
348
+ sklearn-pandas==2.2.0
349
+ smart-open==6.3.0
350
+ sniffio==1.3.0
351
+ snowballstemmer==2.2.0
352
+ sortedcontainers==2.4.0
353
+ soundfile==0.12.1
354
+ soupsieve==2.4.1
355
+ soxr==0.3.5
356
+ spacy==3.5.3
357
+ spacy-legacy==3.0.12
358
+ spacy-loggers==1.0.4
359
+ Sphinx==3.5.4
360
+ sphinxcontrib-applehelp==1.0.4
361
+ sphinxcontrib-devhelp==1.0.2
362
+ sphinxcontrib-htmlhelp==2.0.1
363
+ sphinxcontrib-jsmath==1.0.1
364
+ sphinxcontrib-qthelp==1.0.3
365
+ sphinxcontrib-serializinghtml==1.1.5
366
+ SQLAlchemy==2.0.16
367
+ sqlparse==0.4.4
368
+ srsly==2.4.6
369
+ starlette==0.27.0
370
+ statsmodels==0.13.5
371
+ sympy==1.11.1
372
+ tables==3.8.0
373
+ tabulate==0.8.10
374
+ tblib==2.0.0
375
+ tenacity==8.2.2
376
+ tensorboard==2.12.3
377
+ tensorboard-data-server==0.7.1
378
+ tensorflow==2.12.0
379
+ tensorflow-datasets==4.9.2
380
+ tensorflow-estimator==2.12.0
381
+ tensorflow-gcs-config==2.12.0
382
+ tensorflow-hub==0.13.0
383
+ tensorflow-io-gcs-filesystem==0.32.0
384
+ tensorflow-metadata==1.13.1
385
+ tensorflow-probability==0.20.1
386
+ tensorstore==0.1.38
387
+ termcolor==2.3.0
388
+ terminado==0.17.1
389
+ text-unidecode==1.3
390
+ textblob==0.17.1
391
+ tf-slim==1.1.0
392
+ thinc==8.1.10
393
+ threadpoolctl==3.1.0
394
+ tifffile==2023.4.12
395
+ tinycss2==1.2.1
396
+ toml==0.10.2
397
+ tomli==2.0.1
398
+ toolz==0.12.0
399
+ torch @ https://download.pytorch.org/whl/cu118/torch-2.0.1%2Bcu118-cp310-cp310-linux_x86_64.whl#sha256=a7a49d459bf4862f64f7bc1a68beccf8881c2fa9f3e0569608e16ba6f85ebf7b
400
+ torchaudio @ https://download.pytorch.org/whl/cu118/torchaudio-2.0.2%2Bcu118-cp310-cp310-linux_x86_64.whl#sha256=26692645ea061a005c57ec581a2d0425210ac6ba9f923edf11cc9b0ef3a111e9
401
+ torchdata==0.6.1
402
+ torchsummary==1.5.1
403
+ torchtext==0.15.2
404
+ torchvision @ https://download.pytorch.org/whl/cu118/torchvision-0.15.2%2Bcu118-cp310-cp310-linux_x86_64.whl#sha256=19ca4ab5d6179bbe53cff79df1a855ee6533c2861ddc7389f68349d8b9f8302a
405
+ tornado==6.3.1
406
+ tqdm==4.65.0
407
+ traitlets==5.7.1
408
+ triton==2.0.0
409
+ tweepy==4.13.0
410
+ typer==0.7.0
411
+ types-setuptools==68.0.0.1
412
+ typing_extensions==4.6.3
413
+ tzlocal==5.0.1
414
+ uc-micro-py==1.0.2
415
+ uritemplate==4.1.1
416
+ urllib3==1.26.16
417
+ uvicorn==0.22.0
418
+ vega-datasets==0.9.0
419
+ wasabi==1.1.2
420
+ wcwidth==0.2.6
421
+ webcolors==1.13
422
+ webencodings==0.5.1
423
+ websocket-client==1.6.0
424
+ websockets==11.0.3
425
+ Werkzeug==2.3.6
426
+ widgetsnbextension==3.6.4
427
+ wordcloud==1.8.2.2
428
+ wrapt==1.14.1
429
+ xarray==2022.12.0
430
+ xarray-einstats==0.5.1
431
+ xgboost==1.7.6
432
+ xlrd==2.0.1
433
+ yarl==1.9.2
434
+ yellowbrick==1.5
435
+ yfinance==0.2.21
436
+ zict==3.0.0
437
+ zipp==3.15.0