コード例 #1
0
r = [a, b, c]
r = np.min(r)

# Only the values from the DF are useful in this analysis. When plotting a
# matrix graph, the DF come in handy.
cl1 = cl1.values[:r, :]
cl2 = cl2.values[:r, :]
cl3 = cl3.values[:r, :]

# Our input
x = np.r_[cl1, cl2, cl3]
x = np.array(x, dtype=float)
x = conv.normalize(x)

# Our output using a proprietary function (See pyconv.py).
y = conv.out_b([a, b, c])

# Test parameters. Desired train ration an Nearest Neighbors are altered here.
trainArr = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]
nnArr = [1, 5, 7, 11, 13, 17]
testN = 30

# Overwrite Results?
ovrw = 1

# Initializing our algorithm (See algorithm.py).
knn = alg.KNearestNeighbors(x, y)
caMax, caMin, caMean, caStd = list(), list(), list(), list()

# For loop to calculate KNN based on trainArr and nnArr
for nnNumber in nnArr:
コード例 #2
0
x = np.r_[cl1, cl2, cl3]
x = np.array(x, dtype=float)
#y = conv.out_b([950,950,950])

x = (x - np.min(x, 0)) / (np.max(x, 0) - np.min(x, 0))
caMax, caMin, caMean, caStd = list(), list(), list(), list()
xx = list()

t_size = 5
for n in range(0, int(len(x) / t_size)):
    xx.append(np.mean(x[n * t_size:(n + 1) * t_size, :], 0))

m = int(len(x) / (3 * t_size))
xx = np.array(xx, dtype=float)
y = conv.out_b([m, m, m])
knn = alg.KNearestNeighbors(xx, y)

trainArr = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]
nnArr = [1, 5, 7, 11, 13, 17]

for nnNumber in nnArr:
    for trainSize in trainArr:
        confArrayList = list()
        for n in range(0, 40):
            knn.train(nnNumber, trainSize)
            confArrayList.append(knn.confArray)

        cal = np.array(confArrayList)
        caMax.append(np.diag(np.max(cal, 0)))
        caMin.append(np.diag(np.min(cal, 0)))
コード例 #3
0
import pyconv as conv


def s_anal(cal):
    caMax = np.max(cal, 0)
    caMin = np.min(cal, 0)
    caMean = np.mean(cal, 0)
    caStd = np.std(cal, 0)
    return caMax, caMin, caMean, caStd


irisdf = pd.read_csv('data/iris.csv')
iris = np.array(irisdf.values)

x = np.array(iris[:, 0:4], dtype='float64')
y = conv.out_b([50, 50, 50])
x = conv.normalize(x)

inputLayer = 4
hiddenLayer = 4
outputLayer = 3
learningRate = 0.3
regularizationParameter = 0

net = alg.MultiLayerPerceptron(inputLayer, hiddenLayer, outputLayer,
                               learningRate, regularizationParameter)

net.initialize(x, y)

caMax, caMin, caMean, caStd = list(), list(), list(), list()
コード例 #4
0
a, b, c = cl1.shape[0], cl2.shape[0], cl3.shape[0]
r = [a, b, c]
r = np.min(r)

# Only the values from the DF are useful in this analysis. When plotting a
# matrix graph, the DF come in handy.
cl1 = cl1.values[:960, :]
cl2 = cl2.values[:960, :]
cl3 = cl3.values[:960, :]

# Our input
x = np.r_[cl1, cl2, cl3]
x = np.array(x, dtype=float)
x = conv.normalize(x)
# Our output using a proprietary function (See pyconv.py).
y = conv.out_b([a, b, c])

# Overwrite Results?
ovrw = 1

# Test parameters. Desired train ration an Nearest Neighbors are altered here.

lenghtArr = np.linspace(1, 80, 80, dtype=int)
nnArr = [1]
testN = 30
trainSize = 0.5
numC = 3

# Initializing our algorithm (See algorithm.py).
(m, n) = x.shape
knn = alg.KNearestNeighbors(x, y)
コード例 #5
0
#a,b,c = 50,50,50
#cl1 = iris[0:a,:]
#cl2 = iris[a:a+b,:]
#cl3 = iris[a+b:a+b+c,:]

cl3 = np.array(cl3.values[:, 0:4])
cl2 = np.array(cl2.values[:, 0:4])
cl1 = np.array(cl1.values[:, 0:4])

cl3 = cl3[0:960, :]
cl2 = cl2[0:960, :]
cl1 = cl1[0:960, :]

x = np.r_[cl1, cl2, cl3]
y = conv.out_b([a, b, c])

x = (x - np.min(x, 0)) / (np.max(x, 0) - np.min(x, 0))

t_size = 10

xx = list()
for n in range(0, int(len(x) / t_size)):
    xx.append(np.mean(x[n * t_size:(n + 1) * t_size, 0:5], 0))

m = int(len(x) / (3 * t_size))
xx = np.array(xx, dtype=float)
y = conv.out_b([m, m, m])
dist = 'eDist'

km = alg.kmeans(xx, y)