本文整理汇总了Python中hpelm.ELM.predict方法的典型用法代码示例。如果您正苦于以下问题:Python ELM.predict方法的具体用法?Python ELM.predict怎么用?Python ELM.predict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hpelm.ELM
的用法示例。
在下文中一共展示了ELM.predict方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HPELMNN
# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import predict [as 别名]
class HPELMNN(Classifier):
def __init__(self):
self.__hpelm = None
@staticmethod
def name():
return "hpelmnn"
def train(self, X, Y, class_number=-1):
class_count = max(np.unique(Y).size, class_number)
feature_count = X.shape[1]
self.__hpelm = ELM(feature_count, class_count, 'wc')
self.__hpelm.add_neurons(feature_count, "sigm")
Y_arr = Y.reshape(-1, 1)
enc = OneHotEncoder()
enc.fit(Y_arr)
Y_OHE = enc.transform(Y_arr).toarray()
out_fd = sys.stdout
sys.stdout = open(os.devnull, 'w')
self.__hpelm.train(X, Y_OHE)
sys.stdout = out_fd
def predict(self, X):
Y_predicted = self.__hpelm.predict(X)
return Y_predicted
示例2: test_Classification_WorksCorreclty
# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import predict [as 别名]
def test_Classification_WorksCorreclty(self):
elm = ELM(1, 2)
X = np.array([-1, -0.6, -0.3, 0.3, 0.6, 1])
T = np.array([[1, 0], [1, 0], [1, 0], [0, 1], [0, 1], [0, 1]])
elm.add_neurons(1, "lin")
elm.train(X, T, 'c')
Y = elm.predict(X)
self.assertGreater(Y[0, 0], Y[0, 1])
self.assertLess(Y[5, 0], Y[5, 1])
示例3: test_WeightedClassification_ClassWithLargerWeightWins
# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import predict [as 别名]
def test_WeightedClassification_ClassWithLargerWeightWins(self):
elm = ELM(1, 2)
X = np.array([1, 2, 3, 1, 2, 3])
T = np.array([[1, 0], [1, 0], [1, 0], [0, 1], [0, 1], [0, 1]])
elm.add_neurons(1, "lin")
elm.train(X, T, 'wc', w=(1, 0.1))
Y = elm.predict(X)
self.assertGreater(Y[0, 0], Y[0, 1])
self.assertGreater(Y[1, 0], Y[1, 1])
self.assertGreater(Y[2, 0], Y[2, 1])
示例4: build_ELM_encoder
# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import predict [as 别名]
def build_ELM_encoder(xinput, target, num_neurons):
elm = ELM(xinput.shape[1], target.shape[1])
elm.add_neurons(num_neurons, "sigm")
elm.add_neurons(num_neurons, "lin")
#elm.add_neurons(num_neurons, "rbf_l1")
elm.train(xinput, target, "r")
ypred = elm.predict(xinput)
print "mse error", elm.error(ypred, target)
return elm, ypred
示例5: range
# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import predict [as 别名]
#!/usr/bin/env python
import numpy as np
import time
import random
import sys
from hpelm import ELM
inp = np.loadtxt("input.txt")
outp = np.loadtxt("output.txt")
for neuron in range(10, 1000, 10):
elm = ELM(92, 40)
elm.add_neurons(neuron, "sigm")
t0 = time.clock()
elm.train(inp, outp, "c")
t1 = time.clock()
t = t1-t0
pred = elm.predict(inp)
acc = float(np.sum(outp.argmax(1) == pred.argmax(1))) / outp.shape[0]
print "neuron=%d error=%.1f%% time=%dns" % (neuron, 100-acc*100, t*1000000)
if int(acc) == 1:
break
示例6: ELM
# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import predict [as 别名]
outp = np.loadtxt("output.txt")
# BUILD ELM -----------------------------------------------
neuron = 400
elm = ELM(92, 40)
elm.add_neurons(neuron, "sigm")
# TRAIN ---------------------------------------------------
t0 = time.clock()
elm.train(inp, outp, "c")
t1 = time.clock()
tr = t1-t0
# PREDICT -------------------------------------------------
t0 = time.clock()
pred = elm.predict(testp)
t1 = time.clock()
te = t1-t0
# RESULT --------------------------------------------------
for p in pred:
i = 0
for v in p:
i += 1
if 1.0 - abs(v) < 0.00001:
print "people id:", i
break
print "training took", tr*1000000, "ns"
print "testing took", te*1000000, "ns"
示例7: float
# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import predict [as 别名]
plt.plot(t_real[0:len_learn],sampled_data_FC1[0:len_learn,1],'g-',markersize=8.0,linewidth=10.0,alpha=0.8)
plt.plot(t_real[0:len_learn],sampled_data_FC1[0:len_learn,1],'b-',markersize=3.0,linewidth=3.0)
# plt.plot(t_real[0:regressors_num],sampled_data_FC1[0:regressors_num,1],'r-',markersize=3.0,linewidth=3.0,dashes=[10, 6, 1, 6, 1, 6])
train_out=train_out+3.5
plt.plot(t_real[0:len_learn],train_out[0:len(train_out)],'r',markersize=3.0,linewidth=3.0,dashes=[10, 6, 1, 6, 1, 6])
# plot the predict phase data
plt.plot(t_real[len_learn-1:len_prognostics],sampled_data_FC1[len_learn-1:len_prognostics,1],'b-',markersize=3.0,linewidth=3.0)
plt.plot(t_real[len_learn:len_prognostics],FC1_prognostics,'r',markersize=3.0,linewidth=3.0,dashes=[8, 4, 2, 4, 2, 4])
# plt.ylim(3.1,3.5)
# plt.plot(t_real[0:iterations],x_particle,'k.',markersize=0.5)
plt.grid()
plt.xlabel('real time')
plt.ylabel('voltage')
plt.title('ELM')
plt.legend(['observation','real data','train_predict'])
plt.show()
Yh = elm.predict(X_learn)
plt.plot(Y_learn,color='r',linewidth=3)
plt.plot(Yh,color='g',linewidth=1)
plt.show()
plot_prognostic(Yh)
acc = float(np.sum(Y_learn.argmax(1) == Yh.argmax(1))) / Y_learn.shape[0]
print "Iris dataset training error: %.1f%%" % (100-acc*100)
示例8: ELM
# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import predict [as 别名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 19 16:29:09 2014
@author: akusok
"""
import numpy as np
import os
from hpelm import ELM
curdir = os.path.dirname(__file__)
pX = os.path.join(curdir, "../datasets/Unittest-Iris/iris_data.txt")
pY = os.path.join(curdir, "../datasets/Unittest-Iris/iris_classes.txt")
X = np.loadtxt(pX)
Y = np.loadtxt(pY)
elm = ELM(4,3)
elm.add_neurons(15, "sigm")
elm.train(X, Y, "c")
Yh = elm.predict(X)
acc = float(np.sum(Y.argmax(1) == Yh.argmax(1))) / Y.shape[0]
print("Iris dataset training error: %.1f%%" % (100-acc*100))