1 approx sklearn.datasets
from sklearn.datasets import Load_iris
Import NumPy as NP
data = Load_iris ()
The properties of data are as follows:
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvzgfuz3lhanvhbg==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center ">
The data is stored in the. Data key
The type of each observation object is stored in the. Target property of the dataset.
>>>print (target)
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
2 2]
The type of characteristics of the data is stored in the. Feature_names property of the DataSet.
>>>print (data[' target_names ')
[' Setosa ' versicolor ' virginica ']
2 About traversal problems
A: Traversing the ordinal of an item I
For item in sequence:
Process (item)
B:
For index, item in enumerate (sequence):
Process (index, item)
3:subplot (M,n,i)
For example, subplot (2,3,2), which divides the entire plane into 2 rows and 3 columns, is now the 2nd position in the left-to-right order of the drawing
4 zip in Python
Zip return list
X=[1, 2, 3, 4, 5]y=[6, 7, 8, 9, 10]zip (x, y) got [(1, 6), (2, 7), (3, 8), (4, 9), (5, 10)]
5 range () function
Range ([Start,] stop [, step])
# start selectable number of parameters, start
#stop the number of terminations. Assuming that range has only one parameter x, it produces a list of integers that include 0 to X-1
#step Optional parameters, step size
6 annoying whitespace problem error: indentationerror:expected an indented block
For I in range (1,5): space carriage return
Space print (i) Enter
Else: space carriage return
space print (" ") Enter carriage return
>>> for I in range (1,5):
... print (i)
.. else:
... print ("dead!")
...
1
2
3
4
dead!
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
Machine learn in Python chapter II 2.1.1