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