Starting from scratch machine learning 1th One realization of a perceptual machine

Source: Internet
Author: User

0. Training Data set: Iris DataSet (Iris DataSet), get URL Https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data

As shown, the first four columns of each row of data in the IRIS data set are the petal length/width, the calyx length/width, and the iris in three categories: Setosa,versicolor,virginica

You can save the dataset with the following example code and display the last 5 rows

1 Import Pandas as PD 2 df = pd.read_csv ('https://archive.ics.uci.edu/ml/machine-learning-databases/iris/ Iris.data', header=None)3 df.tail ()

By classifying the data set by four eigenvalues of the Iris in the dataset, determine which Iris is in the category, and select the first 100 data analysis, the sample code is as follows:

1 ImportMatplotlib.pyplot as Plt2 ImportNumPy as NP3 ImportPandas as PD4 5DF = Pd.read_csv ('Https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data', header=None)6 7 8 #Select Setosa and Versicolor9y = df.iloc[0:100, 4].valuesTeny = np.where (y = ='Iris-setosa',-1, 1) One  A #extract sepal length and petal length -X = df.iloc[0:100, [0, 2]].values -  the #Plot Data -Plt.scatter (x[:50, 0], x[:50, 1], -Color='Red', marker='o', label='Setosa') -Plt.scatter (x[50:100, 0], x[50:100, 1], +Color='Blue', marker='x', label='versicolor') -  +Plt.xlabel ('sepal length [cm]') APlt.ylabel ('petal length [cm]') atPlt.legend (loc='Upper Left') -  - plt.tight_layout () -  -Plt.show ()

The output results are as follows:

According to the statistics of two (petal length and calyx length) of four characters, we can see that the blue and red have a clear boundary and realized the classification.

Starting from scratch machine learning 1th One realization of a perceptual machine

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.