示例#1
0
文件: cross.py 项目: bongtrop/IntroCI
from ci import mlp
from ci import helper
import copy
from itertools import izip
import matplotlib.pyplot as plt

argmax = lambda array: max(izip(array, xrange(len(array))))[1]

pttNet = [mlp.randNet([2, 5, 2], type=mlp.SIGMOID), mlp.randNet([2, 10, 2], type=mlp.SIGMOID), mlp.randNet([2, 15, 2], type=mlp.SIGMOID), mlp.randNet([2, 5, 5, 2], type=mlp.SIGMOID)]
learningRate = [0.01, 0.05, 0.1, 0.2]
epoch = 100

f = open("cross.pat", "r")
fw = open("report/cross/report.txt", "w")
lines = f.readlines()

datas = []
for line in lines:
    words = line.split(" ")
    datas.append([float(word) for word in words])

floods = helper.crossvalidation(datas, 0.1, shuffer=True)
plt.ion()
plt.show()

m_cor = 0.0

for pn in pttNet:
    for lr in learningRate:
        s_cor = 0.0
        b_cor = 0.0
示例#2
0
文件: iris.py 项目: bongtrop/IntroCI
from ci import mlp
from ci import helper
import copy
from itertools import izip
import matplotlib.pyplot as plt
import numpy as np

argmax = lambda array: max(izip(array, xrange(len(array))))[1]

pttNet = [mlp.randNet([4, 5, 3], type=mlp.SIGMOID), mlp.randNet([4, 10, 3], type=mlp.SIGMOID), mlp.randNet([4, 15, 3], type=mlp.SIGMOID), mlp.randNet([4, 5, 5, 3], type=mlp.SIGMOID)]
learningRate = [0.01, 0.05, 0.1, 0.2]
epoch = 100

f = open("iris.pat", "r")
fw = open("report/iris/report.txt", "w")
lines = f.readlines()

datas = []
for line in lines:
    words = line.split(" ")
    datas.append([float(word) for word in words])

datas = np.array(datas)

for i in range(0, 4):
    datas[:,i] = (datas[:,i] - np.min(datas[:,i]))/(np.max(datas[:,i])-np.min(datas[:,i]))

datas = datas.tolist()

floods = helper.crossvalidation(datas, 0.1, shuffer=True)
plt.ion()