Ejemplo n.º 1
0
 def __init__(self, mean, cov, N, cls, maxcls):
     self.N = int(N)
     self.cls = cls
     # 2次元正規分布に従ってデータ生成(ヘンにクラスを使いすぎた)
     gauss2d = gen.GenerateRandomNoize2D(mean=mean, cov=cov, n=N)
     gauss2d.generate()
     # 生成した座標を格納
     self.x1 = np.reshape(gauss2d.x, (len(gauss2d.x), 1))
     self.x2 = np.reshape(gauss2d.y, (len(gauss2d.y), 1))
     self.x_vec = np.hstack((self.x1, self.x2))
Ejemplo n.º 2
0
 def __init__(self, mean, cov, N, cls, maxcls):
     self.N = N
     # 1-of-K 符号化によってクラスを表すベクトルを生成
     self.clsvec = np.zeros(maxcls)
     self.clsvec[cls - 1] = 1
     # 2次元正規分布に従ってデータ生成(ヘンにクラスを使いすぎた)
     gauss2d = gen.GenerateRandomNoize2D(mean=mean, cov=cov, n=N)
     gauss2d.generate()
     # 生成した座標を格納
     self.x1 = np.reshape(gauss2d.x, (len(gauss2d.x), 1))
     self.x2 = np.reshape(gauss2d.y, (len(gauss2d.y), 1))
     self.x_vec = np.hstack((self.x1, self.x2))
Ejemplo n.º 3
0
Archivo: test.py Proyecto: a-lilas/PRML
# coding:utf-8
import matplotlib.pyplot as plt
import numpy as np
import random as rd
import sys
from scipy.stats import norm

sys.path.append('../sampledata')
import generate_data as gen

mean = np.array([0, 0])
cov = np.array([[2, -1.5], [-1.5, 2]])
gauss2d = gen.GenerateRandomNoize2D(mean=mean, cov=cov, n=50)
gauss2d.generate()

plt.scatter(x=gauss2d.x, y=gauss2d.y, alpha=0.4, color='red')
plt.xlim((-4, 10))
plt.ylim((-4, 10))
plt.show()