Home > other >  Python machine learning
Python machine learning

Time:10-27

Using the Python generated three categories of random sample data (2 d)
Using linear classifier to classify

Results to achieve similar to this



Should be how to implement

CodePudding user response:

To analyze what characteristic value, see other people do, but don't know how to do

CodePudding user response:

Random data code
 import numpy as np 
The import matplotlib
The import matplotlib. Pyplot as PLT

FIG.=PLT figure ()

Data1=np. Random. Randn (150, 2)
Data2=np. Random. Randn (150, 2) * [0.9, 1.8] + [1, 4]
Data3=np. Random. Randn (150, 2) * [0.5, 0.5] + [3, 3]
Data4=np. Random. Randn (150, 2) * (2, 1] + [7]

Ax=FIG. Add_subplot (111)
Ax. Scatter (x=data1 [0] :,, y=data1 [:, 1), label='class1', color='darkturquoise', marker='o')
Ax. Scatter (x=data2 [0] :,, y=data2 [:, 1), label='class2', color='blue', marker='^')
Ax. Scatter (x=data3 [0] :,, y=data3 [:, 1), label='class3', color='yellowgreen', marker='s')
Ax. Scatter (x=data4 [0] :,, y=data4 [:, 1), label='class4', color='red', marker='D')
Ax. Legend (loc='the lower right)

PLT. The show ()

  • Related