Machine learn in Python chapter II 2.1.1

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.