nursakinahbadriah commited on
Commit
8247efc
1 Parent(s): 28b9906

Upload 8 files

Browse files
P1G5_Set_1_badriah_nursakinah.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
P1G5_Set_1_badriah_nursakinah_inference.ipynb ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "## Import Library"
8
+ ]
9
+ },
10
+ {
11
+ "cell_type": "code",
12
+ "execution_count": 5,
13
+ "metadata": {},
14
+ "outputs": [],
15
+ "source": [
16
+ "#Import library\n",
17
+ "\n",
18
+ "import pandas as pd\n",
19
+ "import numpy as np\n",
20
+ "import pickle\n",
21
+ "import json\n",
22
+ "import warnings\n",
23
+ "from sklearn.preprocessing import StandardScaler, OneHotEncoder # Assuming these scalers/encoders are needed\n",
24
+ "import pandas as pd\n",
25
+ "import numpy as np\n",
26
+ "from sklearn.preprocessing import StandardScaler, OneHotEncoder\n",
27
+ "from sklearn.pipeline import make_pipeline, Pipeline\n",
28
+ "\n"
29
+ ]
30
+ },
31
+ {
32
+ "cell_type": "markdown",
33
+ "metadata": {},
34
+ "source": [
35
+ "## Load Data Files"
36
+ ]
37
+ },
38
+ {
39
+ "cell_type": "code",
40
+ "execution_count": 6,
41
+ "metadata": {},
42
+ "outputs": [],
43
+ "source": [
44
+ "with open('best_svm_model.pkl', 'rb') as file_1:\n",
45
+ " list_cat_cols = pickle.load(file_1)"
46
+ ]
47
+ },
48
+ {
49
+ "cell_type": "markdown",
50
+ "metadata": {},
51
+ "source": [
52
+ "## Load Data Yang Sudah Dibuat Untuk Random State Data Inference"
53
+ ]
54
+ },
55
+ {
56
+ "cell_type": "code",
57
+ "execution_count": 7,
58
+ "metadata": {},
59
+ "outputs": [
60
+ {
61
+ "data": {
62
+ "text/html": [
63
+ "<div>\n",
64
+ "<style scoped>\n",
65
+ " .dataframe tbody tr th:only-of-type {\n",
66
+ " vertical-align: middle;\n",
67
+ " }\n",
68
+ "\n",
69
+ " .dataframe tbody tr th {\n",
70
+ " vertical-align: top;\n",
71
+ " }\n",
72
+ "\n",
73
+ " .dataframe thead th {\n",
74
+ " text-align: right;\n",
75
+ " }\n",
76
+ "</style>\n",
77
+ "<table border=\"1\" class=\"dataframe\">\n",
78
+ " <thead>\n",
79
+ " <tr style=\"text-align: right;\">\n",
80
+ " <th></th>\n",
81
+ " <th>Unnamed: 0</th>\n",
82
+ " <th>limit_balance</th>\n",
83
+ " <th>sex</th>\n",
84
+ " <th>education_level</th>\n",
85
+ " <th>marital_status</th>\n",
86
+ " <th>age</th>\n",
87
+ " <th>pay_1</th>\n",
88
+ " <th>pay_2</th>\n",
89
+ " <th>pay_3</th>\n",
90
+ " <th>pay_4</th>\n",
91
+ " <th>...</th>\n",
92
+ " <th>bill_amt_5</th>\n",
93
+ " <th>bill_amt_6</th>\n",
94
+ " <th>pay_amt_1</th>\n",
95
+ " <th>pay_amt_2</th>\n",
96
+ " <th>pay_amt_3</th>\n",
97
+ " <th>pay_amt_4</th>\n",
98
+ " <th>pay_amt_5</th>\n",
99
+ " <th>pay_amt_6</th>\n",
100
+ " <th>default_payment_next_month</th>\n",
101
+ " <th>Klasifikasi</th>\n",
102
+ " </tr>\n",
103
+ " </thead>\n",
104
+ " <tbody>\n",
105
+ " <tr>\n",
106
+ " <th>0</th>\n",
107
+ " <td>0</td>\n",
108
+ " <td>240000.0</td>\n",
109
+ " <td>2</td>\n",
110
+ " <td>2</td>\n",
111
+ " <td>1</td>\n",
112
+ " <td>41.0</td>\n",
113
+ " <td>1.0</td>\n",
114
+ " <td>-1.0</td>\n",
115
+ " <td>-1.0</td>\n",
116
+ " <td>-1.0</td>\n",
117
+ " <td>...</td>\n",
118
+ " <td>11756.0</td>\n",
119
+ " <td>12522.0</td>\n",
120
+ " <td>40529.0</td>\n",
121
+ " <td>3211.0</td>\n",
122
+ " <td>9795.0</td>\n",
123
+ " <td>11756.0</td>\n",
124
+ " <td>12522.0</td>\n",
125
+ " <td>6199.0</td>\n",
126
+ " <td>0</td>\n",
127
+ " <td>Dewasa</td>\n",
128
+ " </tr>\n",
129
+ " </tbody>\n",
130
+ "</table>\n",
131
+ "<p>1 rows × 26 columns</p>\n",
132
+ "</div>"
133
+ ],
134
+ "text/plain": [
135
+ " Unnamed: 0 limit_balance sex education_level marital_status age \\\n",
136
+ "0 0 240000.0 2 2 1 41.0 \n",
137
+ "\n",
138
+ " pay_1 pay_2 pay_3 pay_4 ... bill_amt_5 bill_amt_6 pay_amt_1 \\\n",
139
+ "0 1.0 -1.0 -1.0 -1.0 ... 11756.0 12522.0 40529.0 \n",
140
+ "\n",
141
+ " pay_amt_2 pay_amt_3 pay_amt_4 pay_amt_5 pay_amt_6 \\\n",
142
+ "0 3211.0 9795.0 11756.0 12522.0 6199.0 \n",
143
+ "\n",
144
+ " default_payment_next_month Klasifikasi \n",
145
+ "0 0 Dewasa \n",
146
+ "\n",
147
+ "[1 rows x 26 columns]"
148
+ ]
149
+ },
150
+ "execution_count": 7,
151
+ "metadata": {},
152
+ "output_type": "execute_result"
153
+ }
154
+ ],
155
+ "source": [
156
+ "#Create new data\n",
157
+ "data_inf = pd.read_csv('data_inf')\n",
158
+ "data_inf"
159
+ ]
160
+ },
161
+ {
162
+ "cell_type": "markdown",
163
+ "metadata": {},
164
+ "source": [
165
+ "\n",
166
+ "## Load Data Yang Sudah Dibuat Untuk Random State Data Inference"
167
+ ]
168
+ },
169
+ {
170
+ "cell_type": "code",
171
+ "execution_count": 8,
172
+ "metadata": {},
173
+ "outputs": [
174
+ {
175
+ "name": "stdout",
176
+ "output_type": "stream",
177
+ "text": [
178
+ "default_prediction: 0\n"
179
+ ]
180
+ }
181
+ ],
182
+ "source": [
183
+ "y_pred_inf = list_cat_cols.predict(data_inf)\n",
184
+ "\n",
185
+ "print('default_prediction:', (y_pred_inf[0]))"
186
+ ]
187
+ },
188
+ {
189
+ "cell_type": "markdown",
190
+ "metadata": {},
191
+ "source": [
192
+ "## Kesimpulan"
193
+ ]
194
+ },
195
+ {
196
+ "cell_type": "markdown",
197
+ "metadata": {},
198
+ "source": [
199
+ "Dari hasil inferenece dengan nilai 0 Jika di tarik kesimpulan dan ditinjau pada studi kasus dalam memprediksi `default_payment_next_month` maka dapat dikatakan bahwa `tidak ada kemungkinan` terjadi telat pembayaran di bulan berikutnya "
200
+ ]
201
+ }
202
+ ],
203
+ "metadata": {
204
+ "kernelspec": {
205
+ "display_name": "base",
206
+ "language": "python",
207
+ "name": "python3"
208
+ },
209
+ "language_info": {
210
+ "codemirror_mode": {
211
+ "name": "ipython",
212
+ "version": 3
213
+ },
214
+ "file_extension": ".py",
215
+ "mimetype": "text/x-python",
216
+ "name": "python",
217
+ "nbconvert_exporter": "python",
218
+ "pygments_lexer": "ipython3",
219
+ "version": "3.10.13"
220
+ }
221
+ },
222
+ "nbformat": 4,
223
+ "nbformat_minor": 2
224
+ }
data_inf ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ ,limit_balance,sex,education_level,marital_status,age,pay_1,pay_2,pay_3,pay_4,pay_5,pay_6,bill_amt_1,bill_amt_2,bill_amt_3,bill_amt_4,bill_amt_5,bill_amt_6,pay_amt_1,pay_amt_2,pay_amt_3,pay_amt_4,pay_amt_5,pay_amt_6,default_payment_next_month,Klasifikasi
2
+ 0,240000.0,2,2,1,41.0,1.0,-1.0,-1.0,-1.0,-1,-1,0.0,40529.0,3211.0,9795.0,11756.0,12522.0,40529.0,3211.0,9795.0,11756.0,12522.0,6199.0,0,Dewasa