神经网络mlp

2018-02-11  本文已影响0人  绍重先
import pandas as pd
from sklearn.preprocessing import StandardScaler
from sklearn.neural_network import MLPClassifier
namesE=['Country','SA','FE','GG','EC','UD','HF','SL','PS','HR','DP','RD','EX','TR','ND','AD']
data = pd.read_csv('datasets/problemE/Select30CountryEKind.csv',names=namesE)
del data['Country']
X = np.array(data.values.tolist())
Y = np.array([1,2,1,3,1,1,1,1,2,3,3,2,3,1,1,2,1,2,3,2,2,1,1,2,1,1,1,2,2,2])
scaler = StandardScaler()
StandardScaler(copy=True, with_mean=True, with_std=True)
scaler.fit(X)
X = scaler.transform(X)
mlp = MLPClassifier(hidden_layer_sizes=(15,15,1),max_iter=1000)
mlp.fit(X,Y)
indoDataOri = np.array([[6.80,7.05,6.80,5.91,7.12,6.83,6.29,6.35,6.75,7.15,6.34,6.14,0,0,0]])

for i in range (0,11):
    for j in range(0,11):
        for k in range(0,11):
            tarr = [6.80,7.05,6.80,5.91,7.12,6.83,6.29,6.35,6.75,7.15,6.34,6.14]
            tarr.append(i)
            tarr.append(j)
            tarr.append(k)
            narr=np.array(tarr)
            indoDataOri = np.row_stack((indoDataOri, narr))
indoDataOri
indoXTest = scaler.transform(indoDataOri)
predictions = mlp.predict(indoXTest)
predictions = mlp.predict(indoXTest)
plot(predictions)
indoData=np.array([[6.80,7.05,6.80,5.91,7.12,6.83,6.29,6.35,6.75,7.15,6.34,6.14,9.684,8.75,1]])
#TR=9.684
#ND=8.75
TR=0
ND=0
AD=1
while TR <=10:
    ND=0
    while ND <= 10:
        AD=0
        while AD <=10:
            tarr = [6.80,7.05,6.80,5.91,7.12,6.83,6.29,6.35,6.75,7.15,6.34,6.14]
            tarr.append(TR)
            tarr.append(ND)
            tarr.append(AD)
            narr=np.array(tarr)
            indoData = np.row_stack((indoData, narr))
            AD = AD + 0.1
        ND = ND+0.1
    TR = TR+0.1
indoData
indoXT = scaler.transform(indoData)
indopredict = mlp.predict(indoXT)
plot(indopredict)
testData = np.array([[5,5,5,5,5,5,5,5,5,5,5,5,0,0,0]])

for i in range (0,11):
    for j in range(0,11):
        for k in range(0,11):
            tarr = [5,5,5,5,5,5,5,5,5,5,5,5]
            tarr.append(i)
            tarr.append(j)
            tarr.append(k)
            narr=np.array(tarr)
            indoDataOri = np.row_stack((indoDataOri, narr))
indoDataOri
indoXTest = scaler.transform(indoDataOri)
predictions = mlp.predict(indoXTest)
predictions = mlp.predict(indoXTest)
plot(predictions)
上一篇下一篇

猜你喜欢

热点阅读