|
19 | 19 | - [Recursive Feature Elimination](#recursive-feature-elimination)
|
20 | 20 |
|
21 | 21 |
|
22 |
| -# Introduction to arrays using numpy |
23 |
| - |
24 |
| -Arrays are used to store multiple values in one single variable. |
25 |
| -An array is a kind of list. |
26 |
| -All the elements in an array are the exact same type |
27 |
| - |
28 |
| -Let's use the numpy python library to handle arrays |
29 |
| - |
30 |
| -``` |
31 |
| ->>> import numpy as np |
32 |
| -``` |
33 |
| - |
34 |
| -data type int64 |
35 |
| -``` |
36 |
| ->>> ti = np.array([1, 2, 3, 4]) |
37 |
| ->>> ti |
38 |
| -array([1, 2, 3, 4]) |
39 |
| ->>> ti.dtype |
40 |
| -dtype('int64') |
41 |
| ->>> |
42 |
| -``` |
43 |
| - |
44 |
| -data type float64 |
45 |
| -``` |
46 |
| ->>> tf = np.array([1.5, 2.5, 3.5, 4.5]) |
47 |
| ->>> tf.dtype |
48 |
| -dtype('float64') |
49 |
| -``` |
50 |
| -access to some elements |
51 |
| -``` |
52 |
| ->>> t = np.array ([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) |
53 |
| ->>> t |
54 |
| -array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) |
55 |
| ->>> t[:6] |
56 |
| -array([0, 1, 2, 3, 4, 5]) |
57 |
| ->>> t |
58 |
| -array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) |
59 |
| -``` |
60 |
| -multi dimensions array |
61 |
| -``` |
62 |
| ->>> tf2d = np.array([[1.5, 2, 3], [4, 5, 6]]) |
63 |
| ->>> tf2d |
64 |
| -array([[1.5, 2. , 3. ], |
65 |
| - [4. , 5. , 6. ]]) |
66 |
| ->>> tf2d.dtype |
67 |
| -dtype('float64') |
68 |
| ->>> tf2d.shape |
69 |
| -(2, 3) |
70 |
| ->>> tf2d.ndim |
71 |
| -2 |
72 |
| ->>> tf2d.size |
73 |
| -6 |
74 |
| -``` |
75 |
| -random number (float) generation |
76 |
| -``` |
77 |
| ->>> np.random.rand(10) |
78 |
| -array([0.67966246, 0.26205002, 0.02549579, 0.11316062, 0.87369288, |
79 |
| - 0.16210068, 0.51009515, 0.92700258, 0.6370769 , 0.06820358]) |
80 |
| -``` |
81 |
| -``` |
82 |
| ->>> np.random.rand(3,2) |
83 |
| -array([[0.78813667, 0.92470323], |
84 |
| - [0.63210563, 0.97820931], |
85 |
| - [0.44739855, 0.03799558]]) |
86 |
| -``` |
87 | 22 |
|
88 | 23 | # visualize a dataset using seaborn
|
89 | 24 |
|
|
0 commit comments