Python Data Analytics Overview
Python Data Analytics Overview
Nivi Agrawal
230004
BA(P)
0 katts 19 GC
1 nivi 18 GC
2 milly 19 GC
1
2
3
4
5
6
7
8
9
[[1 2]
1
0 1
1 2
2 3
3 4
0 Ram 10
1 Renu 12
0 Tom 25 4.23
1 James 26 3.24
2 Ricky 25 3.98
3 Vin 23 2.56
4 Steve 30 3.20
5 Smith 29 4.60
6 Jack 23 3.80
7 Lee 34 3.78
8 Chanchal 40 2.98
9 Gasper 30 4.80
10 Naviya 51 4.10
11 Andres 25 3.65
2
[69]: (12, 3)
[70]: 0 False
1 False
2 False
3 False
4 False
5 False
6 False
7 False
8 False
9 False
10 False
11 False
dtype: bool
[72]: (12, 3)
0 1 2 NaN
1 5 10 20.0
[14]: a 0
b 0
c 1
dtype: int64
3
[16]: a b c
0 False False True
<class '[Link]'>
[83]: 4
[[1 2 3]
[4 5 6]
[7 8 9]]
[85]: 3
[86]: 4
1
2
5
9
(5,)
(3, 3)
4
4
4
int32
[10 20 30 40 50]
[11 22 33 44 55]
[ 9 18 27 36 45]
[ 10 40 90 160 250]
[10 10 10 10 10]
5
[102]: array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19])
6
[4.23232323, 4.27272727, 4.31313131, 4.35353535, 4.39393939,
4.43434343, 4.47474747, 4.51515152, 4.55555556, 4.5959596 ],
[4.63636364, 4.67676768, 4.71717172, 4.75757576, 4.7979798 ,
4.83838384, 4.87878788, 4.91919192, 4.95959596, 5. ]])
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
7
12
13
14
15
16
17
18
19
20
[107]: 190
[108]: 19
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
float64
8
<U2
[121]: -4
-4
40
100
[-1 -2 -3 -4]
[10 20 30 40]
[10 20 30 40]
[ 1 10 -4]
[ 4 40 -1]
[ 10 100 -10]
9
[-1.+0.j -2.+0.j -3.+0.j -4.+0.j]]
[7 8 9]
[4 5 6]]
[[7 8 9]
[1 2 3]
[4 5 6]]
[[ 8 10 12]
[ 8 10 12]
[ 8 10 12]]
[[ 7 16 27]
[ 7 16 27]
[16 25 36]]
[[1 2 3]
[7 8 9]
[4 5 6]
[7 8 9]
[1 2 3]
[4 5 6]]
[[1 2 3 7 8 9]
10
[7 8 9 1 2 3]
[80]: 1
11
10 1/11/2016 33 8 37 29.92
11 1/12/2016 35 15 53 29.85
12 1/13/2016 26 4 42 29.94
13 1/14/2016 30 12 47 29.95
14 1/15/2016 43 31 62 29.82
15 1/16/2016 47 37 70 29.52
16 1/17/2016 36 23 66 29.78
17 1/18/2016 25 6 53 29.83
18 1/19/2016 22 3 42 30.03
19 1/20/2016 32 15 49 30.13
20 1/21/2016 31 11 45 30.15
21 1/22/2016 26 6 41 30.21
22 1/23/2016 26 21 78 29.77
23 1/24/2016 28 11 53 29.92
24 1/25/2016 34 18 54 30.25
25 1/26/2016 43 29 56 30.03
26 1/27/2016 41 22 45 30.03
27 1/28/2016 37 20 51 29.90
28 1/29/2016 36 21 50 29.58
29 1/30/2016 34 16 46 30.01
30 1/31/2016 46 28 52 29.90
VisibilityMiles WindSpeedMPH PrecipitationIn
CloudCover Events \
0 10 8.0 0 5 NaN
1 10 7.0 0 3 NaN
2 10 8.0 0 1 NaN
3 10 9.0 0 3 NaN
4 10 5.0 0 0 NaN
5 10 4.0 0 0 NaN
6 10 2.0 0 3 NaN
7 10 4.0 0 8 NaN
8 9 8.0 T 8 Rain
9 4 NaN 1.8 7 Rain
10 10 NaN 0 1 NaN
11 10 6.0 T 4 NaN
12 10 10.0 0 0 NaN
13 10 5.0 T 7 NaN
14 9 5.0 T 2 NaN
15 8 7.0 0.24 7 Rain
16 8 6.0 0.05 6 Fog-
Snow
17 9 12.0 T 2 Snow
18 10 11.0 0 1 NaN
19 10 6.0 0 2 NaN
20 10 6.0 0 1 NaN
21 9 NaN 0.01 3 Snow
12
22 1 16.0 2.31 8 Fog-
Snow
23 8 6.0 T 3 Snow
24 10 3.0 0 2 NaN
25 10 7.0 0 2 NaN
26 10 7.0 T 3 Rain
27 10 5.0 0 1 NaN
28 10 8.0 0 4 NaN
29 10 7.0 0 0 NaN
30 10 5.0 0 0 NaN
WindDirDegrees
0 281
1 275
2 277
3 345
4 333
5 259
6 293
7 79
8 76
9 109
10 289
11 235
12 284
13 266
14 101
15 340
16 345
17 293
18 293
19 302
20 312 21 34
22 42
23 327
24 286
25 244
26 311
27 234
28 298
29 257
30 241
13
2 1/3/2016 40 21 47 29.86
3 1/4/2016 25 9 44 30.05
4 1/5/2016 20 -3 41 30.57
VisibilityMiles WindSpeedMPH PrecipitationIn CloudCover Events \
0 10 8.0 0 5 NaN
1 10 7.0 0 3 NaN
2 10 8.0 0 1 NaN
3 10 9.0 0 3 NaN
4 10 5.0 0 0 NaN
WindDirDegrees
0 281
1 275
2 277
3 345
4 333
[36]: 0 1/1/2016
1 1/2/2016
14
2 1/3/2016
3 1/4/2016
4 1/5/2016
5 1/6/2016
6 1/7/2016
7 1/8/2016
8 1/9/2016
9 1/10/2016
10 1/11/2016
11 1/12/2016
12 1/13/2016
13 1/14/2016
14 1/15/2016
15 1/16/2016
16 1/17/2016
17 1/18/2016
18 1/19/2016
19 1/20/2016
20 1/21/2016
21 1/22/2016
22 1/23/2016
23 1/24/2016
24 1/25/2016
25 1/26/2016
26 1/27/2016
27 1/28/2016
28 1/29/2016
29 1/30/2016
30 1/31/2016
Name: EST, dtype: object
[37]: 0 1/1/2016
1 1/2/2016
2 1/3/2016
3 1/4/2016
4 1/5/2016
5 1/6/2016
6 1/7/2016
7 1/8/2016
8 1/9/2016
9 1/10/2016
10 1/11/2016
11 1/12/2016
12 1/13/2016
13 1/14/2016
14 1/15/2016
15 1/16/2016
15
16 1/17/2016
17 1/18/2016
18 1/19/2016
19 1/20/2016
20 1/21/2016
21 1/22/2016
22 1/23/2016
23 1/24/2016
24 1/25/2016
25 1/26/2016
26 1/27/2016
27 1/28/2016
28 1/29/2016
29 1/30/2016
30 1/31/2016
Name: EST, dtype: object
16
28 1/29/2016 36
29 1/30/2016 34
30 1/31/2016 46
[39]: 50
[40]: 20
[41]: 34.67741935483871
17
28 1/29/2016 36 21 50 29.58
29 1/30/2016 34 16 46 30.01
30 1/31/2016 46 28 52 29.90
VisibilityMiles WindSpeedMPH PrecipitationIn CloudCover Events \
0 10 8.0 0 5 NaN
1 10 7.0 0 3 NaN
2 10 8.0 0 1 NaN
5 10 4.0 0 0 NaN
6 10 2.0 0 3 NaN
7 10 4.0 0 8 NaN
8 9 8.0 T 8 Rain
9 4 NaN 1.8 7 Rain
10 10 NaN 0 1 NaN
11 10 6.0 T 4 NaN
13 10 5.0 T 7 NaN
14 9 5.0 T 2 NaN
15 8 7.0 0.24 7 Rain
16 8 6.0 0.05 6 Fog-Snow
19 10 6.0 0 2 NaN
20 10 6.0 0 1 NaN
24 10 3.0 0 2 NaN
25 10 7.0 0 2 NaN
26 10 7.0 T 3 Rain
27 10 5.0 0 1 NaN
28 10 8.0 0 4 NaN
29 10 7.0 0 0 NaN
30 10 5.0 0 0 NaN
WindDirDegrees
0 281
1 275
2 277
5 259
18
6 293
7 79
8 76
9 109
10 289
11 235
13 266
14 101
15 340
16 345
19 302
20 312
24 286
25 244
26 311
27 234
28 298
29 257
30 241
[44]: 0 38
1 36
2 40
5 1
6 1
7 1
8 1
9 1
10 33
11 35
13 30
14 43
15 47
16 36
19 32
19
20 31
24 34
25 43
26 41
27 37
28 36
29 34
30 46
Name: Temperature, dtype: int64
[46]: weather[[Link]>=30]['Temperature']
[46]: 0 38
1 36
2 40
5 33
6 39
7 39
8 44
9 50
10 33
11 35
13 30
14 43
15 47
16 36
19 32
20 31
24 34
25 43
26 41
27 37
28 36
29 34
30 46
Name: Temperature, dtype: int64
[47]: 341
20
[48]: Temperature DewPoint Humidity Sea Level PressureIn \
count 31.000000 31.000000 31.000000 31.000000
mean 34.677419 17.838710 51.677419 29.992903
std 7.639315 11.378626 11.634395 0.237237
min 20.000000 -3.000000 33.000000 29.520000
25% 29.000000 10.000000 44.500000 29.855000
50% 35.000000 18.000000 50.000000 30.010000
75% 39.500000 23.000000 55.000000 30.140000
max 50.000000 46.000000 78.000000 30.570000
VisibilityMiles WindSpeedMPH CloudCover WindDirDegrees
count 31.000000 28.000000 31.000000 31.000000
mean 9.193548 6.892857 3.129032 247.129032
std 1.939405 2.871821 2.629853 92.308086
min 1.000000 2.000000 0.000000 34.000000
25% 9.000000 5.000000 1.000000 238.000000
50% 10.000000 6.500000 3.000000 281.000000
75% 10.000000 8.000000 4.500000 300.000000
max 10.000000 16.000000 8.000000 345.000000
[200]: 0 8.0
1 7.0
2 8.0
3 9.0
4 5.0
5 4.0
6 2.0
7 4.0
8 8.0
9 NaN
10 NaN
11 6.0
12 10.0
13 5.0
14 5.0
15 7.0
16 6.0
21
17 12.0
18 11.0
19 6.0
20 6.0
21 NaN
22 16.0
23 6.0
24 3.0
25 7.0
26 7.0
27 5.0
28 8.0
29 7.0
30 5.0
Name: WindSpeedMPH, dtype: float64
[201]: 0 8.000000
1 7.000000
2 8.000000
3 9.000000
4 5.000000
5 4.000000
6 2.000000
7 4.000000
8 8.000000
9 7.333333
10 6.666667
11 6.000000
12 10.000000
13 5.000000
14 5.000000
15 7.000000
16 6.000000
17 12.000000
18 11.000000
19 6.000000
20 6.000000
21 11.000000
22 16.000000
23 6.000000
24 3.000000
25 7.000000
26 7.000000
27 5.000000
28 8.000000
22
29 7.000000
30 5.000000
Name: WindSpeedMPH, dtype: float64
[202]: [Link]("quadratic")
[202]: 0 8.000000
1 7.000000
2 8.000000
3 9.000000
4 5.000000
5 4.000000
6 2.000000
7 4.000000
8 8.000000
9 8.211155
10 5.000936
11 6.000000
12 10.000000
13 5.000000
14 5.000000
15 7.000000
16 6.000000
17 12.000000
18 11.000000
19 6.000000
20 6.000000
21 13.199959
22 16.000000
23 6.000000
24 3.000000
25 7.000000
26 7.000000
27 5.000000
28 8.000000
29 7.000000
30 5.000000
Name: WindSpeedMPH, dtype: float64
[203]: 0 8.000000
1 7.000000
2 8.000000
3 9.000000
4 5.000000
5 4.000000
23
6 2.000000
7 4.000000
8 8.000000
9 7.497765
10 5.105927
11 6.000000
12 10.000000
13 5.000000
14 5.000000
15 7.000000
16 6.000000
17 12.000000
18 11.000000
19 6.000000
20 6.000000
21 13.476703
22 16.000000
23 6.000000
24 3.000000
25 7.000000
26 7.000000
27 5.000000
28 8.000000
29 7.000000
30 5.000000
Name: WindSpeedMPH, dtype: float64
0 1 0 3
1 2 1 1
2 3 1 3
3 4 1 1
4 5 0 3
.. … … …
886 887 0 2
887 888 1 1
888 889 0 3
889 890 1 1
890 891 0 3
24
1 Cumings, Mrs. John Bradley (Florence
Briggs Th… female 38.0 1
2 Heikkinen, Miss. Laina female 26.0 0
3 Futrelle, Mrs. Jacques Heath (Lily May
Peel) female 35.0 1
4 Allen, Mr. William Henry male 35.0 0
.. … … … …
886 Montvila, Rev. Juozas male 27.0 0
887 Graham, Miss. Margaret Edith female 19.0
0
888 Johnston, Miss. Catherine Helen "Carrie"
female NaN 1
889 Behr, Mr. Karl Howell male 26.0 0
890 Dooley, Mr. Patrick male 32.0 0
25
max 891.000000 1.000000 3.000000 80.000000 8.000000
Parch Fare
count 891.000000
891.000000 mean 0.381594
32.204208 std 0.806057
49.693429 min 0.000000
0.000000 25% 0.000000
7.910400
50% 0.000000 14.454200
75% 0.000000 31.000000
max 6.000000 512.329200
[55]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket \
0 False False False False False False False False False
1 False False False False False False False False False
2 False False False False False False False False False
3 False False False False False False False False False
4 False False False False False False False False False
.. … … … … … … … … …
886 False False False False False False False False False
887 False False False False False False False False False
888 False False False False False True False False False
889 False False False False False False False False False
890 False False False False False False False False False
[56]: 0 22.0
26
1 38.0
2 26.0
3 35.0
4 35.0
…
886 27.0
887 19.0
888 NaN
889 26.0
890 32.0
Name: Age, Length: 891, dtype: float64
[57]: 29.69911764705882
[58]: print(sum(titanicdata['Age'].isnull()))
average_age=titanicdata['Age'].mean()
print(average_age)
titanicdata['Age'].fillna(average_age,
inplace=True)
print(titanicdata['Age'].isnull().sum())
titanicdata['Age']
177
29.699117647058
82 0
[58]: 0 22.000000
1 38.000000
2 26.000000
3 35.000000
4 35.000000
…
886 27.000000
887 19.000000
888 29.699118
889 26.000000
890 32.000000
Name: Age, Length: 891, dtype: float64
27
[59]: PassengerId Survived Pclass \
1 2 1 1
3 4 1 1
6 7 0 1
10 11 1 3
11 12 1 1
.. … … …
871 872 1 1
872 873 0 1
879 880 1 1
887 888 1 1
889 890 1 1
Name Sex Age SibSp \
1 Cumings, Mrs. John Bradley (Florence Briggs Th… female 38.0 1
3 Futrelle, Mrs. Jacques Heath (Lily May Peel) female 35.0 1
6 McCarthy, Mr. Timothy J male 54.0 0
10 Sandstrom, Miss. Marguerite Rut female 4.0
1
11 Bonnell, Miss. Elizabeth female 58.0 0
.. … … … …
871 Beckwith, Mrs. Richard Leonard (Sallie
Monypeny) female 47.0 1
872 Carlsson, Mr. Frans Olof male 33.0 0
879 Potter, Mrs. Thomas Jr (Lily Alexenia Wilson) female 56.0 0
887 Graham, Miss. Margaret Edith female 19.0 0
889 Behr, Mr. Karl Howell male 26.0 0
28
887 0 112053 30.0000 B42 S
889 0 111369 30.0000 C148 C
29
871 1 11751 52.5542 D35 S
872 0 695 5.0000 B51 B53 B55 S
879 1 11767 83.1583 C50 C
887 0 112053 30.0000 B42 S
889 0 111369 30.0000 C148 C
Mehdi 175
Bella 168
Charles 190
dtype: int64
<class '[Link]'>
Vik 5.91
Mehdi 5.74
Bella 5.51 Charles
6.23
dtype: float64
30
↪work_performance})
tv.
↪plot(x='hours_tv_watched',y='work_performance',kind='line',marker='*',color='bl
1 110
2 120
3 13
4 140
31
B 110
C 120 D 13
E 140
B 110
C 120
D 13
E 140
dtype: int64
[141]: 140
[142]: 140
[143]: 140
[144]: 13
[145]: 110.0
[146]: 483
32
[148]: array([100, 110, 120, 13, 140], dtype=int64)
[149]: 0 150
1 160
2 170
3 180
4 190
dtype: int64
[150]: A NaN
B NaN
C NaN
D NaN
E NaN
0 NaN
1 NaN
2 NaN
3 NaN
4 NaN
dtype: float64
[151]: 0 NaN
1 NaN
2 NaN
3 NaN
4 NaN
A NaN
B NaN
C NaN
D NaN
E NaN
dtype: float64
[152]: 0 250
1 270
2 290
3 193
4 330
dtype: int64
33
[153]: array([[-0.25145098, 1.74957276, 1.59236149, 1.13388756,
0.59145665], [ 0.491809 , 1.67763367, 1.63262222, -0.07133181, -
1.99441643],
[-1.51873202, -0.21791267, -1.41416337, -0.26270568, -0.2871018
],
[ 0.66773747, -0.15423626, -1.04408036, -1.1345158 , -
0.27194434],
[ 0.48938614, -1.44029738, -0.49236417, 1.4755928 , 0.35633081],
[ 0.67757323, 0.61002412, -0.61210965, -0.57407875, -
0.43576099],
[ 0.92434351, 0.3406317 , 0.96053204, -1.6344566 , 1.08284274],
[-0.2960646 , -2.36416739, 0.28912876, -2.94084729, 0.5067725 ],
[ 1.31527328, -0.35306126, -0.73719366, 1.19944216, 0.884311 ],
[ 0.63312738, 0.31557544, 0.91937723, -1.0572506 , -
1.48902662]])
[157]: 0 1 2 3 4
0 -1.216912 -2.055997 -0.280955 -1.548884
0.154844 1 0.216372 0.840746 -1.565535
1.562931 0.115581
2 0.295202 -0.935682 -1.986690 -1.059014
0.460048 3 -0.572186 1.576032 -1.962290 -
1.313634 -0.847534
4 1.861718 1.218910 -1.461494 -0.243895 1.061897
34
[158]: col1 col2 col3 col4 col5
0 -1.216912 -2.055997 -0.280955 -1.548884 0.154844
1 0.216372 0.840746 -1.565535 1.562931 0.115581
2 0.295202 -0.935682 -1.986690 -1.059014 0.4600483 -0.572186 1.576032
-1.962290 -1.313634 -0.847534
4 1.861718 1.218910 -1.461494 -0.243895 1.061897
[159]: 0 -1.216912
1 0.216372 2
0.295202 3
-0.572186
4 1.861718
Name: col1, dtype: float64
[162]: 0 -1.216912
1 0.216372 2
0.295202 3
-0.572186
4 1.861718
Name: col1, dtype: float64
[163]: array([[-
1.21691151],
[
0.21637152],
[ 0.29520161],
[-0.57218619],
[ 1.86171843]])
35
3 -0.572186 -1.962290 -
0.847534
4 1.861718 -1.461494 1.061897
[165]: (5, 5)
[166]: 5
[167]: 5
[170]: 25
[171]: 2
[174]: fixed acidity volatile acidity citric acid residual sugar chlorides \
0 7.4 0.700 0.00 1.9 0.076
1 7.8 0.880 0.00 2.6 0.098
2 7.8 0.760 0.04 2.3 0.092
3 11.2 0.280 0.56 1.9 0.075
4 7.4 0.700 0.00 1.9 0.076
… … … … … …
1594 6.2 0.600 0.08 2.0 0.090
1595 5.9 0.550 0.10 2.2 0.062
36
1596 6.3 0.510 0.13 2.3 0.076
1597 5.9 0.645 0.12 2.0 0.075
1598 6.0 0.310 0.47 3.6 0.067
free sulfur dioxide total sulfur dioxide density pH sulphates \
0 11.0 34.0 0.99780 3.51 0.56
1 25.0 67.0 0.99680 3.20 0.68
2 15.0 54.0 0.99700 3.26 0.65
3 17.0 60.0 0.99800 3.16 0.58
4 11.0 34.0 0.99780 3.51 0.56
… … … … … …
1594 32.0 44.0 0.99490 3.45 0.58
1595 39.0 51.0 0.99512 3.52 0.76
1596 29.0 40.0 0.99574 3.42 0.75
1597 32.0 44.0 0.99547 3.57 0.71 1598 18.0 42.0 0.99549 3.39 0.66
alcohol quality
0 9.4 5
1 9.8 5
2 9.8 5
3 9.8 6
4 9.4 5
… … …
1594 10.5 5
1595 11.2 6
1596 11.0 6
1597 10.2 5
1598 11.0 6
[1599 rows x 12 columns]
37
'pH', 'sulphates', 'alcohol', 'quality'],
dtype='object')
[176]: fixed acidity volatile acidity citric acid residual sugar chlorides \
50 8.8 0.660 0.26 1.70 0.074
51 6.6 0.520 0.04 2.20 0.069
52 6.6 0.500 0.04 2.10 0.068
53 8.6 0.380 0.36 3.00 0.081
54 7.6 0.510 0.15 2.80 0.110
55 7.7 0.620 0.04 3.80 0.084
56 10.2 0.420 0.57 3.40 0.070
57 7.5 0.630 0.12 5.10 0.111
58 7.8 0.590 0.18 2.30 0.076
59 7.3 0.390 0.31 2.40 0.074
60 8.8 0.400 0.40 2.20 0.079
61 7.7 0.690 0.49 1.80 0.115
62 7.5 0.520 0.16 1.90 0.085
63 7.0 0.735 0.05 2.00 0.081
64 7.2 0.725 0.05 4.65 0.086
65 7.2 0.725 0.05 4.65 0.086
66 7.5 0.520 0.11 1.50 0.079
67 6.6 0.705 0.07 1.60 0.076
68 9.3 0.320 0.57 2.00 0.074
69 8.0 0.705 0.05 1.90 0.074
free sulfur dioxide total sulfur dioxide density pH sulphates \
50 4.0 23.0 0.9971 3.15 0.74
51 8.0 15.0 0.9956 3.40 0.63
52 6.0 14.0 0.9955 3.39 0.64
53 30.0 119.0 0.9970 3.20 0.56
54 33.0 73.0 0.9955 3.17 0.63
55 25.0 45.0 0.9978 3.34 0.53
56 4.0 10.0 0.9971 3.04 0.63
57 50.0 110.0 0.9983 3.26 0.77
58 17.0 54.0 0.9975 3.43 0.59
59 9.0 46.0 0.9962 3.41 0.54
60 19.0 52.0 0.9980 3.44 0.64
61 20.0 112.0 0.9968 3.21 0.71
62 12.0 35.0 0.9968 3.38 0.62
63 13.0 54.0 0.9966 3.39 0.57
64 4.0 11.0 0.9962 3.41 0.39
38
65 4.0 11.0 0.9962 3.41 0.39
66 11.0 39.0 0.9968 3.42 0.58
67 6.0 15.0 0.9962 3.44 0.58
68 27.0 65.0 0.9969 3.28 0.79
69 8.0 19.0 0.9962 3.34 0.95
alcohol quality
50 9.2 5
51 9.4 6
52 9.4 6
53 9.4 5
54 10.2 6
55 9.5 5
56 9.6 5
57 9.4 5
58 10.0 5
59 9.4 6
60 9.2 5
61 9.3 5
62 9.5 7
63 9.8 5
64 10.9 5
65 10.9 5
66 9.6 5
67 10.7 5
68 10.7 5
69 10.5 6
39
[179]: <[Link] at 0x1372cb456a0>
40
[180]: fixed acidity volatile acidity citric acid \
fixed acidity 1.000000 -0.256131 0.671703
volatile acidity -0.256131 1.000000 -0.552496
citric acid 0.671703 -0.552496 1.000000
residual sugar 0.114777 0.001918 0.143577
chlorides 0.093705 0.061298 0.203823
free sulfur dioxide -0.153794 -0.010504 -0.060978
41
total sulfur -0.113181 0.076470 0.035533
dioxide
density 0.668047 0.022026 0.364947
pH -0.682978 0.234937 -0.541904
sulphates 0.183006 -0.260987 0.312770
alcohol -0.061668 -0.202288 0.109903
quality 0.124052 -0.390558 0.226373
alcohol quality
fixed acidity -0.061668 0.124052
volatile acidity -0.202288 -0.390558
citric acid 0.109903 0.226373
residual sugar 0.042075 0.013732
chlorides -0.221141 -0.128907
42
free sulfur dioxide -0.069408 -0.050656
total sulfur dioxide -0.205654 -
0.185100
density -0.496180 -
0.174919
pH 0.205633 -
0.057731
sulphates 0.093595
0.251397
alcohol 1.000000
0.476166
quality 0.476166 1.000000
43
[182]: [Link](wine[["fixed acidity","volatile acidity","citric acid","density"]].
↪corr(),annot=True,fmt='0.4f',linewidth=3)
[191]: [Link](x="quality",y="alcohol",data=wine,showfliers=True)
44
[183]: [Link](x="quality",y="alcohol",data=wine,showfliers=False)
#Removed␣ ↪outliers
45
[184]: fixed acidity volatile acidity citric acid residual
sugar \
count 1599.000000 1599.000000 1599.000000 1599.000000
mean 8.319637 0.527821 0.270976 2.538806
std 1.741096 0.179060 0.194801 1.409928
min 4.600000 0.120000 0.000000 0.900000
25% 7.100000 0.390000 0.090000 1.900000
50% 7.900000 0.520000 0.260000 2.200000
75% 9.200000 0.640000 0.420000 2.600000
max 15.900000 1.580000 1.000000 15.500000
chlorides free sulfur dioxide total sulfur dioxide density \
count 1599.000000 1599.000000 1599.000000
1599.000000
mean 0.087467 15.874922 46.467792 0.996747
std 0.047065 10.460157 32.895324 0.001887
min 0.012000 1.000000 6.000000 0.990070
25% 0.070000 7.000000 22.000000 0.995600
50% 0.079000 14.000000 38.000000 0.996750
75% 0.090000 21.000000 62.000000 0.997835
46
max 0.611000 72.000000 289.000000 1.003690
pH sulphates alcohol quality
count 1599.000000 1599.000000 1599.000000 1599.000000
mean 3.311113 0.658149 10.422983 5.636023
std 0.154386 0.169507 1.065668 0.807569
min 2.740000 0.330000 8.400000 3.000000
25% 3.210000 0.550000 9.500000 5.000000
50% 3.310000 0.620000 10.200000 6.000000
75% 3.400000 0.730000 11.100000 6.000000
max 4.010000 2.000000 14.900000 8.000000
[190]: 12
47
1 1 buick skylark 320 2 1 plymouth
satellite
3 1 amc rebel sst 4 1
ford torino
.. … …
392 1 ford mustang gl
393 2 vw pickup
394 1 dodge rampage 395 1 ford ranger 396 1 chevy s-10
[195]: 0 130
1 165
2 150
3 150
4 140
…
392 86
393 52
394 84
395 79
396 82
Name: horsepower, Length: 397, dtype: object
32 1 ford pinto
126 1 ford maverick
330 2 renault lecar deluxe 336
1 ford mustang cobra
354 2 renault 18i
48
[197]: Index([32, 126, 330, 336, 354], dtype='int64')
origin name
0 1 chevrolet chevelle malibu
1 1 buick skylark 320 2 1 plymouth
satellite
3 1 amc rebel sst 4 1
ford torino
.. … …
392 1 ford mustang gl
393 2 vw pickup
394 1 dodge rampage 395 1 ford ranger
396 1 chevy s-10
[206]: fixed acidity volatile acidity citric acid residual sugar chlorides \
0 7.4 0.700 0.00 1.9 0.076
1 7.8 0.880 0.00 2.6 0.098
2 7.8 0.760 0.04 2.3 0.092
49
3 11.2 0.280 0.56 1.9 0.075
4 7.4 0.700 0.00 1.9 0.076
… … … … … …
1594 6.2 0.600 0.08 2.0 0.090
1595 5.9 0.550 0.10 2.2 0.062
1596 6.3 0.510 0.13 2.3 0.076
1597 5.9 0.645 0.12 2.0 0.075
1598 6.0 0.310 0.47 3.6 0.067
free sulfur dioxide total sulfur dioxide density pH sulphates \
0 11.0 34.0 0.99780 3.51 0.56
1 25.0 67.0 0.99680 3.20 0.68
2 15.0 54.0 0.99700 3.26 0.65
3 17.0 60.0 0.99800 3.16 0.58
4 11.0 34.0 0.99780 3.51 0.56
… … … … … …
1594 32.0 44.0 0.99490 3.45 0.58
1595 39.0 51.0 0.99512 3.52 0.76
1596 29.0 40.0 0.99574 3.42 0.75
1597 32.0 44.0 0.99547 3.57 0.71 1598 18.0 42.0 0.99549 3.39 0.66
alcohol quality
0 9.4 5
1 9.8 5
2 9.8 5
3 9.8 6
4 9.4 5
… … …
1594 10.5 5
1595 11.2 6
1596 11.0 6
1597 10.2 5
1598 11.0 6
50
[1599 rows x 12 columns]
[207]: fixed acidity volatile acidity citric acid residual sugar chlorides \
0 7.0 0.27 0.36 20.7 0.045
1 6.3 0.30 0.34 1.6 0.049
2 8.1 0.28 0.40 6.9 0.050
3 7.2 0.23 0.32 8.5 0.058
4 7.2 0.23 0.32 8.5 0.058
… … … … … …
4893 6.2 0.21 0.29 1.6 0.039
4894 6.6 0.32 0.36 8.0 0.047
4895 6.5 0.24 0.19 1.2 0.041
4896 5.5 0.29 0.30 1.1 0.022
4897 6.0 0.21 0.38 0.8 0.020
free sulfur dioxide total sulfur dioxide density pH sulphates \
0 45.0 170.0 1.00100 3.00 0.45
1 14.0 132.0 0.99400 3.30 0.49
2 30.0 97.0 0.99510 3.26 0.44
3 47.0 186.0 0.99560 3.19 0.40
4 47.0 186.0 0.99560 3.19 0.40
… … … … … …
4893 24.0 92.0 0.99114 3.27 0.50
4894 57.0 168.0 0.99490 3.15 0.46
4895 30.0 111.0 0.99254 2.99 0.46
4896 20.0 110.0 0.98869 3.34 0.38
4897 22.0 98.0 0.98941 3.26 0.32
alcohol quality
0 8.8 6
1 9.5 6
2 10.1 6
3 9.9 6
51
4 9.9 6
… … …
4893 11.2 6
4894 9.6 5
4895 9.4 6
4896 12.8 7
4897 11.8 6
[4898 rows x 12 columns]
[208]: fixed acidity volatile acidity citric acid residual sugar chlorides \
50 7.2 0.19 0.31 1.6 0.062
51 6.6 0.25 0.29 1.1 0.068
52 6.2 0.16 0.33 1.1 0.057
53 6.4 0.18 0.35 1.0 0.045
54 6.8 0.20 0.59 0.9 0.147
55 6.9 0.25 0.35 1.3 0.039
56 7.2 0.21 0.34 11.9 0.043
57 6.0 0.19 0.26 12.4 0.048
58 6.6 0.38 0.15 4.6 0.044
59 7.4 0.20 0.36 1.2 0.038
60 6.8 0.22 0.24 4.9 0.092
61 6.0 0.19 0.26 12.4 0.048
62 7.0 0.47 0.07 1.1 0.035
63 6.6 0.38 0.15 4.6 0.044
64 7.2 0.24 0.27 1.4 0.038
65 6.2 0.35 0.03 1.2 0.064
66 6.4 0.26 0.24 6.4 0.040
67 6.7 0.25 0.13 1.2 0.041
68 6.7 0.23 0.31 2.1 0.046
69 7.4 0.24 0.29 10.1 0.050
free sulfur dioxide total sulfur dioxide density pH sulphates \
50 31.0 173.0 0.9917 3.35 0.44
51 39.0 124.0 0.9914 3.34 0.58
52 21.0 82.0 0.9910 3.32 0.46
53 39.0 108.0 0.9911 3.31 0.35
54 38.0 132.0 0.9930 3.05 0.38
55 29.0 191.0 0.9908 3.13 0.52
56 37.0 213.0 0.9962 3.09 0.50
57 50.0 147.0 0.9972 3.30 0.36
58 25.0 78.0 0.9931 3.11 0.38
59 44.0 111.0 0.9926 3.36 0.34
60 30.0 123.0 0.9951 3.03 0.46
52
61 50.0 147.0 0.9972 3.30 0.36
62 17.0 151.0 0.9910 3.02 0.34
63 25.0 78.0 0.9931 3.11 0.38
64 31.0 122.0 0.9927 3.15 0.46
65 29.0 120.0 0.9934 3.22 0.54
66 27.0 124.0 0.9903 3.22 0.49
67 81.0 174.0 0.9920 3.14 0.42
68 30.0 96.0 0.9926 3.33 0.64
69 21.0 105.0 0.9962 3.13 0.35
alcohol quality
50 11.7 6
51 11.0 7
52 10.9 7
53 10.9 6
54 9.1 6
55 11.0 6
56 9.6 6
57 8.9 6
58 10.2 6
59 9.9 6
60 8.6 6
61 8.9 6
62 10.5 5
63 10.2 6
64 10.3 6
65 9.1 5
66 12.6 7
67 9.8 5
68 10.7 8
69 9.5 5
[209]: fixed acidity volatile acidity citric acid residual sugar chlorides \
50 7.2 0.19 0.31 1.6 0.062
55 6.9 0.25 0.35 1.3 0.039
60 6.8 0.22 0.24 4.9 0.092
53
65 6.2 0.35 0.03 1.2 0.064
free sulfur dioxide total sulfur dioxide density pH sulphates \
50 31.0 173.0 0.9917 3.35 0.44
55 29.0 191.0 0.9908 3.13 0.52
60 30.0 123.0 0.9951 3.03 0.46
65 29.0 120.0 0.9934 3.22 0.54
alcohol quality
50 11.7 6
55 11.0 6
60 8.6 6
65 9.1 5
[211]: fixed acidity volatile acidity citric acid residual sugar chlorides \
50 7.2 0.19 0.31 1.6 0.062
53 6.4 0.18 0.35 1.0 0.045
56 7.2 0.21 0.34 11.9 0.043
59 7.4 0.20 0.36 1.2 0.038
62 7.0 0.47 0.07 1.1 0.035
65 6.2 0.35 0.03 1.2 0.064
68 6.7 0.23 0.31 2.1 0.046
71 6.8 0.30 0.23 4.6 0.061
74 6.7 0.23 0.31 2.1 0.046
77 7.0 0.32 0.34 1.3 0.042
80 6.8 0.22 0.31 1.4 0.053
83 7.3 0.22 0.30 8.2 0.047
86 7.2 0.39 0.63 11.0 0.044
89 7.1 0.44 0.62 11.8 0.044
92 6.9 0.24 0.33 1.7 0.035
95 7.1 0.26 0.29 12.4 0.044
98 9.8 0.36 0.46 10.5 0.038
free sulfur dioxide total sulfur dioxide density pH sulphates \
50 31.0 173.0 0.9917 3.35 0.44
53 39.0 108.0 0.9911 3.31 0.35
56 37.0 213.0 0.9962 3.09 0.50
59 44.0 111.0 0.9926 3.36 0.34
62 17.0 151.0 0.9910 3.02 0.34
65 29.0 120.0 0.9934 3.22 0.54
68 30.0 96.0 0.9926 3.33 0.64
71 50.5 238.5 0.9958 3.32 0.60
54
74 30.0 96.0 0.9926 3.33 0.64
77 20.0 69.0 0.9912 3.31 0.65
80 34.0 114.0 0.9929 3.39 0.77
83 42.0 207.0 0.9966 3.33 0.46
86 55.0 156.0 0.9974 3.09 0.44
89 52.0 152.0 0.9975 3.12 0.46
92 47.0 136.0 0.9900 3.26 0.40
95 62.0 240.0 0.9969 3.04 0.42
98 4.0 83.0 0.9956 2.89 0.30
alcohol quality
50 11.7 6
53 10.9 6
56 9.6 6
59 9.9 6
62 10.5 5
65 9.1 5
68 10.7 8
71 9.5 5
74 10.7 8
77 12.0 7
80 10.6 6
83 9.5 6
86 8.7 6
89 8.7 6
92 12.6 7
95 9.2 6
98 10.1 4
[214]: 12
55
[216]: <Axes: xlabel='alcohol', ylabel='Count'>
56
[218]: <[Link] at 0x1373c64fef0>
57
[219]: <[Link] at 0x137512356a0>
58
[220]: fixed acidity volatile acidity citric acid
\
fixed acidity 1.000000 -0.022697 0.289181
volatile acidity -0.022697 1.000000 -0.149472
citric acid 0.289181 -0.149472 1.000000
residual sugar 0.089021 0.064286 0.094212
chlorides 0.023086 0.070512 0.114364
free sulfur dioxide -0.049396 -0.097012 0.094077
total sulfur 0.091070 0.089261 0.121131
dioxide
density 0.265331 0.027114 0.149503
59
pH -0.425858 -0.031915 -0.163748
sulphates -0.017143 -0.035728 0.062331
alcohol -0.120881 0.067718 -0.075729
quality -0.113663 -0.194723 -0.009209
alcohol quality
fixed acidity -0.120881 -0.113663
volatile acidity 0.067718 -0.194723
citric acid -0.075729 -0.009209
residual sugar -0.450631 -0.097577
chlorides -0.360189 -0.209934
60
free sulfur dioxide -0.250104
0.008158 total sulfur dioxide -
0.448892 -0.174737 density -0.780138
-0.307123 pH 0.121432 0.099427
sulphates -0.017433 0.053678 alcohol
1.000000 0.435575 quality
0.435575 1.000000
61
[224]: <Axes: >
62
[226]: [Link](x="alcohol", y="quality", data=whitewine)
63
[229]: from [Link] import pearsonr def
corr_coeff (col1, col2, df): coref,
p_values= pearsonr(df[col1], df[col2])
print("correlation coeff", coref)
print("p-values", p_values)
corr_coeff('chlorides','pH',whitewine)
[301]: fixed acidity volatile acidity citric acid residual sugar chlorides \
0 7.4 0.700 0.00 1.9 0.076
1 7.8 0.880 0.00 2.6 0.098
2 7.8 0.760 0.04 2.3 0.092
3 11.2 0.280 0.56 1.9 0.075
4 7.4 0.700 0.00 1.9 0.076
64
… … … … … …
1594 6.2 0.600 0.08 2.0 0.090
1595 5.9 0.550 0.10 2.2 0.062
1596 6.3 0.510 0.13 2.3 0.076
1597 5.9 0.645 0.12 2.0 0.075
1598 6.0 0.310 0.47 3.6 0.067
free sulfur dioxide total sulfur dioxide density pH sulphates \
0 11.0 34.0 0.99780 3.51 0.56
1 25.0 67.0 0.99680 3.20 0.68
2 15.0 54.0 0.99700 3.26 0.65
3 17.0 60.0 0.99800 3.16 0.58
4 11.0 34.0 0.99780 3.51 0.56
… … … … … …
1594 32.0 44.0 0.99490 3.45 0.58
1595 39.0 51.0 0.99512 3.52 0.76
1596 29.0 40.0 0.99574 3.42 0.75
1597 32.0 44.0 0.99547 3.57 0.71
1598 18.0 42.0 0.99549 3.39 0.66
alcohol
0 9.4 1
9.8 2
9.8 3
9.8
4 9.4
… …
1594 10.5
1595 11.2
1596 11.0
1597 10.2
1598 11.0
[302]: y
[302]: 0 5
1 5
65
2 5
3 6
4 5
..
1594 5
1595 6
1596 6
1597 5
1598 6
Name: quality, Length: 1599, dtype: int64
[303]: 1279
D:\Users\nivia\AnacondaforPython\Lib\sitepackages\sklearn\linear_model
\_logistic.py:469: ConvergenceWarning: lbfgs failed to converge
(status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.
[304]: LogisticRegression()
[305]: array([6, 5, 6, 5, 6, 5, 5, 6, 5, 5, 5, 5, 6, 5, 6, 6, 6, 6,
6, 5, 6, 5, 6, 7, 5, 5, 5, 6, 5, 6, 6, 6, 6, 5, 6, 6, 5, 5, 6, 6, 5,
6, 6, 7,
6, 5, 6, 6, 5, 6, 5, 5, 6, 6, 5, 5, 5, 5, 6, 5, 5, 6, 6, 6, 5,
6,
66
6, 6, 6, 6, 5, 6, 5, 6, 6, 6, 5, 5, 5, 6, 6, 5, 6, 6, 6, 5, 6,
5,
5, 5, 5, 5, 6, 5, 6, 5, 6, 5, 5, 6, 7, 6, 6, 6, 6, 5, 6, 5, 6,
5,
6, 5, 6, 5, 6, 5, 6, 6, 6, 6, 5, 6, 6, 5, 6, 6, 5, 5, 6, 6, 5,
5,
6, 6, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 5, 5, 6, 6, 6, 5, 6, 6, 5,
6,
5, 6, 5, 5, 6, 6, 6, 6, 6, 5, 6, 5, 6, 6, 5, 6, 6, 5, 5, 6, 6,
6,
7, 7, 6, 5, 5, 6, 5, 6, 7, 5, 6, 6, 5, 6, 6, 6, 5, 5, 5, 5, 5,
5,
5, 5, 5, 6, 5, 5, 6, 5, 5, 6, 6, 5, 6, 6, 5, 7, 5, 5, 6, 6, 6,
5,
5, 6, 6, 6, 5, 6, 6, 6, 5, 5, 5, 6, 5, 6, 6, 6, 6, 6, 6, 6, 5,
5,
5, 5, 6, 5, 5, 5, 5, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 5,
5,
5, 5, 5, 5, 6, 6, 6, 5, 6, 6, 6, 6, 6, 5, 6, 6, 5, 6, 5, 6, 6,
5,
6, 5, 6, 6, 6, 6, 6, 5, 5, 6, 5, 5, 5, 5, 6, 5, 5, 6, 6, 6, 6,
5,
5, 5, 6, 6, 5, 5, 5, 7, 6, 6, 5, 6], dtype=int64)
[306]: 0.625
[232]: area 0
1200
1 1400
2 450
67
3 600
4 2200
5 4500
[235]: LinearRegression()
D:\Users\nivia\AnacondaforPython\Lib\site-
packages\sklearn\[Link]: UserWarning: X does not have valid
68
feature names, but LinearRegression was fitted with feature
names [Link](
[236]: array([4031949.25028835])
[237]: 2262220.485917327
[238]: array([707.89150575])
[239]: 4031949.2502923273
69
540 1820000 3000 2 1 1 yes no yes
541 1767150 2400 3 1 1 no no no
542 1750000 3620 2 1 1 yes no no
543 1750000 2910 3 1 1 no no no
544 1750000 3850 3 1 2 yes no no
hotwaterheating airconditioning parking prefarea furnishingstatus
0 no yes 2 yes furnished
1 no yes 3 no furnished
2 no no 2 yes semi-
furnished
3 no yes 3 yes furnished
4 no yes 2 no furnished
.. … … … … …
540 no no 2 no unfurnished
541 no no 0 no semi-
furnished
542 no no 0 no unfurnished
543 no no 0 no furnished
544 no no 0 no unfurnished
[545 rows x 13 columns]
70
[246]: LinearRegression()
D:\Users\nivia\AnacondaforPython\Lib\site-
packages\sklearn\[Link]: UserWarning: X does not have valid
feature names, but LinearRegression was fitted with feature
names [Link](
[247]: array([3311258.270942])
D:\Users\nivia\AnacondaforPython\Lib\site-
packages\sklearn\[Link]:
71
UserWarning: X does not have valid feature names, but LinearRegression
was
fitted with feature names
[Link](
[248]: array([5870599.18521322])
6 8580
273 3500
293 4410
241 3760
239 4000
.. …
307 4080
357 6930
441 4370
486 6000
401 9500
[253]: 6 10150000
273 4340000
293 4200000
241 4550000
239 4585000
…
307 4165000
357 3773000
441 3220000
486 2870000
401 3500000
72
Name: price, Length: 436, dtype: int64
[254]: area
288 5040
260 3162
223 6321
526 3180
487 5400
.. …
296 4600
70 4000
53 5150
127 6500
414 4040
[255]: 109
[257]: 109
73
3 4 94700 1980 3 2 3 No East
4 5 119800 2130 3 3 3 No East
.. … … … … … … … …
123 124 119700 1900 3 3 3 Yes East
124 125 147900 2160 4 3 3 Yes East
125 126 113500 2070 2 2 2 No North
126 127 149900 2020 3 3 1 No West
127 128 124600 2250 3 3 4 No North
[128 rows x 8 columns]
74
[262]: 0 114300
1 114200
2 114800
3 94700
4 119800
…
123 119700
124 147900
125 113500
126 149900
127 124600
Name: Price, Length: 128, dtype: int64
19 1920 3 3
14 2590 4 3
75
91 2150 3 2
35 2080 3 3
20 1790 3 2
.. … … …
64 1860 3 2
15 1780 4 2
100 2010 3 2
125 2070 2 2
9 1730 3 3
[102 rows x 3 columns]
[266]: 19 167200
14 176800
91 116500
35 117100
20 116200
…
64 130300
15 145800
100 103200
125 113500
9 104000
Name: Price, Length: 102, dtype: int64
[267]: 102
[268]: LinearRegression()
D:\Users\nivia\AnacondaforPython\Lib\site-
packages\sklearn\[Link]: UserWarning: X does not have valid
feature names, but LinearRegression was fitted with feature
names [Link](
[269]: array([201902.44178427])
76
[271]: array([31.58275229, 10821.74413904, 14941.54496524])
[272]: -1862.778059492557
77
--------------------------------------------------------------------
-------
ValueError Traceback (most recent call last)
Cell In[274], line 2
1 import [Link] as plt
----> 2 [Link](X, y, label = "Data Points", color = "pink")
3 [Link](X, m*X+c, label = "Regression Line", color =
"purple") 4 [Link]("SqFt")
File D:\Users\nivia\AnacondaforPython\Lib\site-
packages\matplotlib\[Link]:
↪3699, in scatter(x, y, s, c, marker, cmap, norm, vmin, vmax,
alpha,␣
↪linewidths, edgecolors, plotnonfinite, data,
**kwargs) 3680
@_copy_docstring_and_deprecators([Link])
3681 def scatter(
3682 x: float | ArrayLike,
(…)
3697 **kwargs,
3698 ) -> PathCollection:
-> 3699 __ret = gca().scatter(
3700 x,
3701 y,
3702 s=s,
3703 c=c,
3704 marker=marker,
3705 cmap=cmap,
3706 norm=norm,
3707 vmin=vmin,
3708 vmax=vmax,
3709 alpha=alpha,
3710 linewidths=linewidths,
3711 edgecolors=edgecolors,
3712 plotnonfinite=plotnonfinite,
3713 **({"data": data} if data is not None else {}),
3714 **kwargs,
3715 )
3716 sci(__ret)
3717 return __ret
File D:\Users\nivia\AnacondaforPython\Lib\site-
packages\matplotlib\__init__.py: ↪1465, in
_preprocess_data.<locals>.inner(ax, data, *args, **kwargs)
1462 @[Link](func)
78
1463 def inner(ax, *args, data=None, **kwargs):
1464 if data is None:
-> 1465 return func(ax, *map(sanitize_sequence, args), **kwargs)
79
1467 bound = new_sig.bind(ax, *args, **kwargs)
1468 auto_label = ([Link](label_namer)
1469 or [Link](label_namer))
File D:\Users\nivia\AnacondaforPython\Lib\site-
packages\matplotlib\axes\_axes.py: ␣
↪4655, in [Link](self, x, y, s, c, marker, cmap, norm, vmin,
vmax, alpha,
↪linewidths, edgecolors, plotnonfinite,
80
2 47 1
3 52 0
4 46 1
[284]:
[Link]([Link],insurance.bought_insurance,marker="*",color="yello
w")
[286]: 27
81
X_train,X_test,y_train,y_test=train_test_split(insurance[["age"]],insurance["boug
ht_insurance"
↪75,random_state=3)
X_train
[287]: age 21
26
0 22
8 62
3 52
24 50
10 18
[288]: age 18
19
17 58
12 27
25 54
15 55
16 25
13 29
2 47
1 25
23 45
14 49
4 46
22 40
6 55
7 60
5 56
20 21
9 61
11 28
26 23
19 18
[289]: 21 0
0 0
8 1
3 0
24 1
82
10 0
Name: bought_insurance, dtype: int64
[290]: 18 0
17 1
12 0
25 1
15 1
16 1
13 0
2 1
1 0
23 1
14 1
4 1
22 1
6 0
7 1
5 1
20 0
9 1
11 0
26 0
19 0
Name: bought_insurance, dtype: int64
[291]: 6
[292]: 21
83
[293]: 6
[294]: 21
[296]: LogisticRegression()
[297]: LogisticRegression()
[298]: array([0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0,
0],
dtype=int64)
[299]: 0.6666666666666666
D:\Users\nivia\AnacondaforPython\Lib\site-packages\sklearn\[Link]:
UserWarning: X does not have valid feature names, but
LogisticRegression was fitted with feature names [Link](
84