思路 这题问题是对于这一群点和一条直线,我们也不知道直线上方的是A类还是直线下方的是A类.其实对于这个二分类问题,我们也没必要知道.我们只需要判断直线每一测的点是不是一类(A类或B类)就可以了. 至于如何判断这一侧的点是不是一类,用一个set就可以了:把这一侧的点的自身类别(A或B)全都扔进一个set,如果是同一类,那么set的大小肯定是1. 进而,如果直线两侧对应的set大小全都是1,那么就二分类成功了. 代码 m, n = [int(i) for i in input().split()]
%%%% Tutorial on the basic structure of using a planar decision boundary %%%% to divide a collection of data-points into two classes. %%%% by Rajeev Raizada, Jan.2010 %%%% %%%% Please mail any comments or suggestions to: raizada at cornell dot edu
1 #CS231n中线性.非线性分类器举例(Softmax) #注意其中反向传播的计算 # -*- coding: utf-8 -*- import numpy as np import matplotlib.pyplot as plt N = 100 # number of points per class D = 2 # dimensionality K = 3 # number of classes X = np.zeros((N*K,D)) # data matrix (each row