Я мог бы использовать подсказку, чтобы помочь мне построить границу решения для разделения на классы данных. Я создал некоторые образцы данных (из распределения Гаусса) через Python NumPy. В этом случае каждая точка данных является двумерной координатой, т.е. Одним столбчатым вектором, состоящим из 2 строк. Например.
[ 1
2 ]
Предположим, что у меня есть 2 класса, class1 и class2, и я создал 100 точек данных для точек данных класса 1 и 100 для класса 2 с помощью приведенного ниже кода (назначенного переменным x1_samples и x2_samples).
mu_vec1 = np.array([0,0])
cov_mat1 = np.array([[2,0],[0,2]])
x1_samples = np.random.multivariate_normal(mu_vec1, cov_mat1, 100)
mu_vec1 = mu_vec1.reshape(1,2).T # to 1-col vector
mu_vec2 = np.array([1,2])
cov_mat2 = np.array([[1,0],[0,1]])
x2_samples = np.random.multivariate_normal(mu_vec2, cov_mat2, 100)
mu_vec2 = mu_vec2.reshape(1,2).T
Когда я рисую точки данных для каждого класса, он будет выглядеть так:
Теперь я придумал уравнение для границы решения для разделения обоих классов и хотел бы добавить его к сюжету. Тем не менее, я не совсем уверен, как я могу построить эту функцию:
def decision_boundary(x_vec, mu_vec1, mu_vec2):
g1 = (x_vec-mu_vec1).T.dot((x_vec-mu_vec1))
g2 = 2*( (x_vec-mu_vec2).T.dot((x_vec-mu_vec2)) )
return g1 - g2
Я очень благодарен за любую помощь!
EDIT: Интуитивно (если бы я сделал свое математическое право), я ожидал бы, что граница принятия решения будет выглядеть как эта красная линия, когда я построю функцию...