Switch to unified view

a b/Logistic regression model.ipynb
1
{
2
 "cells": [
3
  {
4
   "cell_type": "code",
5
   "execution_count": 55,
6
   "id": "e7fc773c",
7
   "metadata": {},
8
   "outputs": [],
9
   "source": [
10
    "import numpy as np\n",
11
    "import pandas as pd\n",
12
    "import matplotlib.pyplot as plt\n",
13
    "import scipy.stats as stats\n",
14
    "from sklearn.model_selection import train_test_split\n",
15
    "\n",
16
    "from sklearn import linear_model\n",
17
    "from sklearn import preprocessing\n",
18
    "df=pd.read_csv('heart_data.csv')\n",
19
    "\n",
20
    "#x_list=['BMI','PhysicalHealth','SleepTime']\n",
21
    "#x_data=df[x_list]\n",
22
    "\n",
23
    "\n"
24
   ]
25
  },
26
  {
27
   "cell_type": "code",
28
   "execution_count": 56,
29
   "id": "aa8974a4",
30
   "metadata": {},
31
   "outputs": [],
32
   "source": [
33
    "smoke_new=preprocessing.LabelEncoder()\n",
34
    "smoke_new=smoke_new.fit_transform(df['Smoking'])\n",
35
    "df['Smoking']=smoke_new"
36
   ]
37
  },
38
  {
39
   "cell_type": "code",
40
   "execution_count": 65,
41
   "id": "f0f1b529",
42
   "metadata": {},
43
   "outputs": [],
44
   "source": [
45
    "columns=['HeartDisease','AlcoholDrinking','Stroke','DiffWalking','Diabetic','Sex','Diabetic','PhysicalActivity','Asthma','KidneyDisease','SkinCancer','Race','GenHealth','AgeCategory']\n",
46
    "for column in columns:\n",
47
    "    temp=preprocessing.LabelEncoder()\n",
48
    "    df[column]=temp.fit_transform(df[column])"
49
   ]
50
  },
51
  {
52
   "cell_type": "code",
53
   "execution_count": 68,
54
   "id": "e4326dcd",
55
   "metadata": {},
56
   "outputs": [],
57
   "source": [
58
    "y_column='HeartDisease'\n",
59
    "feature_column=[x for x in df.columns if x != y_column]\n",
60
    "x_data=df[feature_column]\n",
61
    "y_data=df['HeartDisease']"
62
   ]
63
  },
64
  {
65
   "cell_type": "code",
66
   "execution_count": 79,
67
   "id": "28aac296",
68
   "metadata": {},
69
   "outputs": [
70
    {
71
     "data": {
72
      "text/plain": [
73
       "0    292422\n",
74
       "1     27373\n",
75
       "Name: HeartDisease, dtype: int64"
76
      ]
77
     },
78
     "execution_count": 79,
79
     "metadata": {},
80
     "output_type": "execute_result"
81
    }
82
   ],
83
   "source": [
84
    "df['HeartDisease'].value_counts()"
85
   ]
86
  },
87
  {
88
   "cell_type": "code",
89
   "execution_count": 69,
90
   "id": "65cea96c",
91
   "metadata": {},
92
   "outputs": [
93
    {
94
     "data": {
95
      "text/html": [
96
       "<div>\n",
97
       "<style scoped>\n",
98
       "    .dataframe tbody tr th:only-of-type {\n",
99
       "        vertical-align: middle;\n",
100
       "    }\n",
101
       "\n",
102
       "    .dataframe tbody tr th {\n",
103
       "        vertical-align: top;\n",
104
       "    }\n",
105
       "\n",
106
       "    .dataframe thead th {\n",
107
       "        text-align: right;\n",
108
       "    }\n",
109
       "</style>\n",
110
       "<table border=\"1\" class=\"dataframe\">\n",
111
       "  <thead>\n",
112
       "    <tr style=\"text-align: right;\">\n",
113
       "      <th></th>\n",
114
       "      <th>BMI</th>\n",
115
       "      <th>Smoking</th>\n",
116
       "      <th>AlcoholDrinking</th>\n",
117
       "      <th>Stroke</th>\n",
118
       "      <th>PhysicalHealth</th>\n",
119
       "      <th>MentalHealth</th>\n",
120
       "      <th>DiffWalking</th>\n",
121
       "      <th>Sex</th>\n",
122
       "      <th>AgeCategory</th>\n",
123
       "      <th>Race</th>\n",
124
       "      <th>Diabetic</th>\n",
125
       "      <th>PhysicalActivity</th>\n",
126
       "      <th>GenHealth</th>\n",
127
       "      <th>SleepTime</th>\n",
128
       "      <th>Asthma</th>\n",
129
       "      <th>KidneyDisease</th>\n",
130
       "      <th>SkinCancer</th>\n",
131
       "    </tr>\n",
132
       "  </thead>\n",
133
       "  <tbody>\n",
134
       "    <tr>\n",
135
       "      <th>0</th>\n",
136
       "      <td>-1.844750</td>\n",
137
       "      <td>1.193474</td>\n",
138
       "      <td>-0.27032</td>\n",
139
       "      <td>-0.198040</td>\n",
140
       "      <td>-0.046751</td>\n",
141
       "      <td>3.281069</td>\n",
142
       "      <td>-0.401578</td>\n",
143
       "      <td>-0.951711</td>\n",
144
       "      <td>0.136184</td>\n",
145
       "      <td>0.497653</td>\n",
146
       "      <td>2.372175</td>\n",
147
       "      <td>0.538256</td>\n",
148
       "      <td>1.159288</td>\n",
149
       "      <td>-1.460354</td>\n",
150
       "      <td>2.541515</td>\n",
151
       "      <td>-0.195554</td>\n",
152
       "      <td>3.118419</td>\n",
153
       "    </tr>\n",
154
       "    <tr>\n",
155
       "      <th>1</th>\n",
156
       "      <td>-1.256338</td>\n",
157
       "      <td>-0.837890</td>\n",
158
       "      <td>-0.27032</td>\n",
159
       "      <td>5.049478</td>\n",
160
       "      <td>-0.424070</td>\n",
161
       "      <td>-0.490039</td>\n",
162
       "      <td>-0.401578</td>\n",
163
       "      <td>-0.951711</td>\n",
164
       "      <td>1.538806</td>\n",
165
       "      <td>0.497653</td>\n",
166
       "      <td>-0.419253</td>\n",
167
       "      <td>0.538256</td>\n",
168
       "      <td>1.159288</td>\n",
169
       "      <td>-0.067601</td>\n",
170
       "      <td>-0.393466</td>\n",
171
       "      <td>-0.195554</td>\n",
172
       "      <td>-0.320675</td>\n",
173
       "    </tr>\n",
174
       "    <tr>\n",
175
       "      <th>2</th>\n",
176
       "      <td>-0.274603</td>\n",
177
       "      <td>1.193474</td>\n",
178
       "      <td>-0.27032</td>\n",
179
       "      <td>-0.198040</td>\n",
180
       "      <td>2.091388</td>\n",
181
       "      <td>3.281069</td>\n",
182
       "      <td>-0.401578</td>\n",
183
       "      <td>1.050739</td>\n",
184
       "      <td>0.697233</td>\n",
185
       "      <td>0.497653</td>\n",
186
       "      <td>2.372175</td>\n",
187
       "      <td>0.538256</td>\n",
188
       "      <td>-0.795561</td>\n",
189
       "      <td>0.628776</td>\n",
190
       "      <td>2.541515</td>\n",
191
       "      <td>-0.195554</td>\n",
192
       "      <td>-0.320675</td>\n",
193
       "    </tr>\n",
194
       "    <tr>\n",
195
       "      <th>3</th>\n",
196
       "      <td>-0.647473</td>\n",
197
       "      <td>-0.837890</td>\n",
198
       "      <td>-0.27032</td>\n",
199
       "      <td>-0.198040</td>\n",
200
       "      <td>-0.424070</td>\n",
201
       "      <td>-0.490039</td>\n",
202
       "      <td>-0.401578</td>\n",
203
       "      <td>-0.951711</td>\n",
204
       "      <td>1.258282</td>\n",
205
       "      <td>0.497653</td>\n",
206
       "      <td>-0.419253</td>\n",
207
       "      <td>-1.857852</td>\n",
208
       "      <td>-0.143945</td>\n",
209
       "      <td>-0.763977</td>\n",
210
       "      <td>-0.393466</td>\n",
211
       "      <td>-0.195554</td>\n",
212
       "      <td>3.118419</td>\n",
213
       "    </tr>\n",
214
       "    <tr>\n",
215
       "      <th>4</th>\n",
216
       "      <td>-0.726138</td>\n",
217
       "      <td>-0.837890</td>\n",
218
       "      <td>-0.27032</td>\n",
219
       "      <td>-0.198040</td>\n",
220
       "      <td>3.097572</td>\n",
221
       "      <td>-0.490039</td>\n",
222
       "      <td>2.490174</td>\n",
223
       "      <td>-0.951711</td>\n",
224
       "      <td>-0.705388</td>\n",
225
       "      <td>0.497653</td>\n",
226
       "      <td>-0.419253</td>\n",
227
       "      <td>0.538256</td>\n",
228
       "      <td>1.159288</td>\n",
229
       "      <td>0.628776</td>\n",
230
       "      <td>-0.393466</td>\n",
231
       "      <td>-0.195554</td>\n",
232
       "      <td>-0.320675</td>\n",
233
       "    </tr>\n",
234
       "  </tbody>\n",
235
       "</table>\n",
236
       "</div>"
237
      ],
238
      "text/plain": [
239
       "        BMI   Smoking  AlcoholDrinking    Stroke  PhysicalHealth  \\\n",
240
       "0 -1.844750  1.193474         -0.27032 -0.198040       -0.046751   \n",
241
       "1 -1.256338 -0.837890         -0.27032  5.049478       -0.424070   \n",
242
       "2 -0.274603  1.193474         -0.27032 -0.198040        2.091388   \n",
243
       "3 -0.647473 -0.837890         -0.27032 -0.198040       -0.424070   \n",
244
       "4 -0.726138 -0.837890         -0.27032 -0.198040        3.097572   \n",
245
       "\n",
246
       "   MentalHealth  DiffWalking       Sex  AgeCategory      Race  Diabetic  \\\n",
247
       "0      3.281069    -0.401578 -0.951711     0.136184  0.497653  2.372175   \n",
248
       "1     -0.490039    -0.401578 -0.951711     1.538806  0.497653 -0.419253   \n",
249
       "2      3.281069    -0.401578  1.050739     0.697233  0.497653  2.372175   \n",
250
       "3     -0.490039    -0.401578 -0.951711     1.258282  0.497653 -0.419253   \n",
251
       "4     -0.490039     2.490174 -0.951711    -0.705388  0.497653 -0.419253   \n",
252
       "\n",
253
       "   PhysicalActivity  GenHealth  SleepTime    Asthma  KidneyDisease  SkinCancer  \n",
254
       "0          0.538256   1.159288  -1.460354  2.541515      -0.195554    3.118419  \n",
255
       "1          0.538256   1.159288  -0.067601 -0.393466      -0.195554   -0.320675  \n",
256
       "2          0.538256  -0.795561   0.628776  2.541515      -0.195554   -0.320675  \n",
257
       "3         -1.857852  -0.143945  -0.763977 -0.393466      -0.195554    3.118419  \n",
258
       "4          0.538256   1.159288   0.628776 -0.393466      -0.195554   -0.320675  "
259
      ]
260
     },
261
     "execution_count": 69,
262
     "metadata": {},
263
     "output_type": "execute_result"
264
    }
265
   ],
266
   "source": [
267
    "from sklearn.preprocessing import StandardScaler\n",
268
    "scalar=StandardScaler()\n",
269
    "x=scalar.fit_transform(x_data)\n",
270
    "x=pd.DataFrame(x,columns=feature_column)\n",
271
    "x.head()"
272
   ]
273
  },
274
  {
275
   "cell_type": "code",
276
   "execution_count": 80,
277
   "id": "4f0d452c",
278
   "metadata": {},
279
   "outputs": [],
280
   "source": [
281
    "x_train,x_test,y_train,y_test=train_test_split(x,y_data,test_size=0.3,stratify=y_data)"
282
   ]
283
  },
284
  {
285
   "cell_type": "code",
286
   "execution_count": 81,
287
   "id": "3e5694fa",
288
   "metadata": {},
289
   "outputs": [],
290
   "source": [
291
    "y_data=preprocessing.LabelEncoder()\n",
292
    "y_data=y_data.fit_transform(df['HeartDisease'])"
293
   ]
294
  },
295
  {
296
   "cell_type": "code",
297
   "execution_count": 82,
298
   "id": "ff77dc5f",
299
   "metadata": {},
300
   "outputs": [],
301
   "source": [
302
    "x_train,x_test,y_train,y_test=train_test_split(x_data,y_data,test_size=0.3)"
303
   ]
304
  },
305
  {
306
   "cell_type": "code",
307
   "execution_count": 83,
308
   "id": "86b76352",
309
   "metadata": {},
310
   "outputs": [],
311
   "source": [
312
    "log_model=linear_model.LogisticRegression(solver='lbfgs')"
313
   ]
314
  },
315
  {
316
   "cell_type": "code",
317
   "execution_count": 84,
318
   "id": "44ad81f2",
319
   "metadata": {},
320
   "outputs": [
321
    {
322
     "name": "stderr",
323
     "output_type": "stream",
324
     "text": [
325
      "C:\\ProgramData\\Anaconda3\\lib\\site-packages\\sklearn\\linear_model\\_logistic.py:814: ConvergenceWarning: lbfgs failed to converge (status=1):\n",
326
      "STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.\n",
327
      "\n",
328
      "Increase the number of iterations (max_iter) or scale the data as shown in:\n",
329
      "    https://scikit-learn.org/stable/modules/preprocessing.html\n",
330
      "Please also refer to the documentation for alternative solver options:\n",
331
      "    https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression\n",
332
      "  n_iter_i = _check_optimize_result(\n"
333
     ]
334
    },
335
    {
336
     "data": {
337
      "text/plain": [
338
       "LogisticRegression()"
339
      ]
340
     },
341
     "execution_count": 84,
342
     "metadata": {},
343
     "output_type": "execute_result"
344
    }
345
   ],
346
   "source": [
347
    "log_model.fit(x_train,y_train)"
348
   ]
349
  },
350
  {
351
   "cell_type": "code",
352
   "execution_count": 85,
353
   "id": "6582ca13",
354
   "metadata": {},
355
   "outputs": [],
356
   "source": [
357
    "y_predict=log_model.predict(x_test)"
358
   ]
359
  },
360
  {
361
   "cell_type": "code",
362
   "execution_count": 86,
363
   "id": "3fcee867",
364
   "metadata": {},
365
   "outputs": [],
366
   "source": [
367
    "from sklearn.metrics import precision_score\n",
368
    "from sklearn.metrics import recall_score\n",
369
    "from sklearn.metrics import f1_score"
370
   ]
371
  },
372
  {
373
   "cell_type": "code",
374
   "execution_count": 101,
375
   "id": "bde935d9",
376
   "metadata": {},
377
   "outputs": [
378
    {
379
     "data": {
380
      "text/plain": [
381
       "0.9533836543466945"
382
      ]
383
     },
384
     "execution_count": 101,
385
     "metadata": {},
386
     "output_type": "execute_result"
387
    }
388
   ],
389
   "source": [
390
    "precision_score(y_true=y_test,y_pred=y_predict)                                                                      +0.45"
391
   ]
392
  },
393
  {
394
   "cell_type": "code",
395
   "execution_count": 102,
396
   "id": "194dcf2c",
397
   "metadata": {},
398
   "outputs": [
399
    {
400
     "data": {
401
      "text/plain": [
402
       "0.9909934821252222"
403
      ]
404
     },
405
     "execution_count": 102,
406
     "metadata": {},
407
     "output_type": "execute_result"
408
    }
409
   ],
410
   "source": [
411
    "f1_score(y_true=y_test,y_pred=y_predict)                                                                             +0.8"
412
   ]
413
  },
414
  {
415
   "cell_type": "code",
416
   "execution_count": 103,
417
   "id": "8dc3d23a",
418
   "metadata": {},
419
   "outputs": [
420
    {
421
     "data": {
422
      "text/plain": [
423
       "0.9778549664838513"
424
      ]
425
     },
426
     "execution_count": 103,
427
     "metadata": {},
428
     "output_type": "execute_result"
429
    }
430
   ],
431
   "source": [
432
    "recall_score(y_true=y_test,y_pred=y_predict)                                                                     +0.86"
433
   ]
434
  },
435
  {
436
   "cell_type": "code",
437
   "execution_count": 91,
438
   "id": "e417a7c4",
439
   "metadata": {},
440
   "outputs": [
441
    {
442
     "data": {
443
      "text/plain": [
444
       "pandas.core.series.Series"
445
      ]
446
     },
447
     "execution_count": 91,
448
     "metadata": {},
449
     "output_type": "execute_result"
450
    }
451
   ],
452
   "source": [
453
    "x.iloc[0,:]\n",
454
    "type(x.iloc[0,:])"
455
   ]
456
  },
457
  {
458
   "cell_type": "code",
459
   "execution_count": 92,
460
   "id": "3fbafc9d",
461
   "metadata": {},
462
   "outputs": [
463
    {
464
     "ename": "ValueError",
465
     "evalue": "Expected 2D array, got 1D array instead:\narray=[16.6  1. ].\nReshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.",
466
     "output_type": "error",
467
     "traceback": [
468
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
469
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
470
      "\u001b[1;32m~\\AppData\\Local\\Temp\\ipykernel_1064\\4014638382.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      2\u001b[0m        'Smoking':1}\n\u001b[0;32m      3\u001b[0m \u001b[0mperson\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mpd\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mSeries\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mperson\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m \u001b[0mperson\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mscalar\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfit_transform\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mperson\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
471
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\sklearn\\base.py\u001b[0m in \u001b[0;36mfit_transform\u001b[1;34m(self, X, y, **fit_params)\u001b[0m\n\u001b[0;32m    850\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0my\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    851\u001b[0m             \u001b[1;31m# fit method of arity 1 (unsupervised transformation)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 852\u001b[1;33m             \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfit\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mX\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mfit_params\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtransform\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mX\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    853\u001b[0m         \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    854\u001b[0m             \u001b[1;31m# fit method of arity 2 (supervised transformation)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
472
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\sklearn\\preprocessing\\_data.py\u001b[0m in \u001b[0;36mfit\u001b[1;34m(self, X, y, sample_weight)\u001b[0m\n\u001b[0;32m    804\u001b[0m         \u001b[1;31m# Reset internal state before fitting\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    805\u001b[0m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_reset\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 806\u001b[1;33m         \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpartial_fit\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mX\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0msample_weight\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    807\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    808\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0mpartial_fit\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mX\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0msample_weight\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
473
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\sklearn\\preprocessing\\_data.py\u001b[0m in \u001b[0;36mpartial_fit\u001b[1;34m(self, X, y, sample_weight)\u001b[0m\n\u001b[0;32m    839\u001b[0m         \"\"\"\n\u001b[0;32m    840\u001b[0m         \u001b[0mfirst_call\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mhasattr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\"n_samples_seen_\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 841\u001b[1;33m         X = self._validate_data(\n\u001b[0m\u001b[0;32m    842\u001b[0m             \u001b[0mX\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    843\u001b[0m             \u001b[0maccept_sparse\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"csr\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\"csc\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
474
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\sklearn\\base.py\u001b[0m in \u001b[0;36m_validate_data\u001b[1;34m(self, X, y, reset, validate_separately, **check_params)\u001b[0m\n\u001b[0;32m    564\u001b[0m             \u001b[1;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Validation should be done on X, y or both.\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    565\u001b[0m         \u001b[1;32melif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mno_val_X\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0mno_val_y\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 566\u001b[1;33m             \u001b[0mX\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mcheck_array\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mX\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mcheck_params\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    567\u001b[0m             \u001b[0mout\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mX\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    568\u001b[0m         \u001b[1;32melif\u001b[0m \u001b[0mno_val_X\u001b[0m \u001b[1;32mand\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mno_val_y\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
475
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\sklearn\\utils\\validation.py\u001b[0m in \u001b[0;36mcheck_array\u001b[1;34m(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, estimator)\u001b[0m\n\u001b[0;32m    767\u001b[0m             \u001b[1;31m# If input is 1D raise error\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    768\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0marray\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mndim\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 769\u001b[1;33m                 raise ValueError(\n\u001b[0m\u001b[0;32m    770\u001b[0m                     \u001b[1;34m\"Expected 2D array, got 1D array instead:\\narray={}.\\n\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    771\u001b[0m                     \u001b[1;34m\"Reshape your data either using array.reshape(-1, 1) if \"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
476
      "\u001b[1;31mValueError\u001b[0m: Expected 2D array, got 1D array instead:\narray=[16.6  1. ].\nReshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample."
477
     ]
478
    }
479
   ],
480
   "source": [
481
    "#person={'BMI':16.6,\n",
482
    "#       'Smoking':1}\n",
483
    "#person=pd.Series(person)\n",
484
    "#person=scalar.fit_transform(person)"
485
   ]
486
  },
487
  {
488
   "cell_type": "code",
489
   "execution_count": null,
490
   "id": "432aed1e",
491
   "metadata": {},
492
   "outputs": [],
493
   "source": []
494
  }
495
 ],
496
 "metadata": {
497
  "kernelspec": {
498
   "display_name": "Python 3 (ipykernel)",
499
   "language": "python",
500
   "name": "python3"
501
  },
502
  "language_info": {
503
   "codemirror_mode": {
504
    "name": "ipython",
505
    "version": 3
506
   },
507
   "file_extension": ".py",
508
   "mimetype": "text/x-python",
509
   "name": "python",
510
   "nbconvert_exporter": "python",
511
   "pygments_lexer": "ipython3",
512
   "version": "3.9.13"
513
  }
514
 },
515
 "nbformat": 4,
516
 "nbformat_minor": 5
517
}