本文整理汇总了Python中hpelm.HPELM.error方法的典型用法代码示例。如果您正苦于以下问题:Python HPELM.error方法的具体用法?Python HPELM.error怎么用?Python HPELM.error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hpelm.HPELM
的用法示例。
在下文中一共展示了HPELM.error方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_MultilabelError_CorrectWithMultipleClasses
# 需要导入模块: from hpelm import HPELM [as 别名]
# 或者: from hpelm.HPELM import error [as 别名]
def test_MultilabelError_CorrectWithMultipleClasses(self):
T = np.zeros((100, 5))
T[:, 0] = 1
Y = np.zeros((100, 5))
Y[:, 1] = 1
model = HPELM(1, 5, classification='ml')
self.assertEqual(0.4, model.error(T, Y))
示例2: test_MultiLabelClassError_Works
# 需要导入模块: from hpelm import HPELM [as 别名]
# 或者: from hpelm.HPELM import error [as 别名]
def test_MultiLabelClassError_Works(self):
T = self.makeh5(np.array([[0, 1], [1, 1], [1, 0]]))
Y = self.makeh5(np.array([[0.4, 0.6], [0.8, 0.6], [1, 1]]))
hpelm = HPELM(1, 2)
hpelm.add_neurons(1, "lin")
hpelm.classification = "ml"
e = hpelm.error(T, Y)
np.testing.assert_allclose(e, 1.0 / 6)
示例3: test_RegressionError_Works
# 需要导入模块: from hpelm import HPELM [as 别名]
# 或者: from hpelm.HPELM import error [as 别名]
def test_RegressionError_Works(self):
T = np.array([1, 2, 3])
Y = np.array([1.1, 2.2, 3.3])
err1 = np.mean((T - Y) ** 2)
fT = self.makeh5(T)
fY = self.makeh5(Y)
hpelm = HPELM(1, 1)
e = hpelm.error(fT, fY)
np.testing.assert_allclose(e, err1)
示例4: test_WeightedClassError_Works
# 需要导入模块: from hpelm import HPELM [as 别名]
# 或者: from hpelm.HPELM import error [as 别名]
def test_WeightedClassError_Works(self):
X = self.makeh5(np.array([1, 2, 3]))
T = self.makeh5(np.array([[0, 1], [0, 1], [1, 0]]))
Y = self.makeh5(np.array([[0, 1], [0.4, 0.6], [0, 1]]))
# here class 0 is totally incorrect, and class 1 is totally correct
w = (9, 1)
hpelm = HPELM(1, 2)
hpelm.add_neurons(1, "lin")
hpelm.train(X, T, "wc", w=w)
e = hpelm.error(T, Y)
np.testing.assert_allclose(e, 0.9)
示例5: test_ParallelBasicPython_Works
# 需要导入模块: from hpelm import HPELM [as 别名]
# 或者: from hpelm.HPELM import error [as 别名]
def test_ParallelBasicPython_Works(self):
X = np.random.rand(1000, 10)
T = np.random.rand(1000, 3)
hX = modules.make_hdf5(X, self.fnameX)
hT = modules.make_hdf5(T, self.fnameT)
model0 = HPELM(10, 3)
model0.add_neurons(10, 'lin')
model0.add_neurons(5, 'tanh')
model0.add_neurons(15, 'sigm')
model0.save(self.fmodel)
model1 = HPELM(10, 3)
model1.load(self.fmodel)
os.remove(self.fnameHT)
os.remove(self.fnameHH)
model1.add_data(self.fnameX, self.fnameT, istart=0, icount=100, fHH=self.fnameHH, fHT=self.fnameHT)
model2 = HPELM(10, 3)
model2.load(self.fmodel)
model2.add_data(self.fnameX, self.fnameT, istart=100, icount=900, fHH=self.fnameHH, fHT=self.fnameHT)
model3 = HPELM(10, 3)
model3.load(self.fmodel)
model3.solve_corr(self.fnameHH, self.fnameHT)
model3.save(self.fmodel)
model4 = HPELM(10, 3)
model4.load(self.fmodel)
model4.predict(self.fnameX, self.fnameY)
err = model4.error(self.fnameT, self.fnameY, istart=0, icount=198)
self.assertLess(err, 1)
err = model4.error(self.fnameT, self.fnameY, istart=379, icount=872)
self.assertLess(err, 1)