Esempio n. 1
0
print "Enter oversampling percent"
P=int(input())
syn_X=SMOTE(X1, P, 5)
X1=np.vstack((X1,syn_X))
X1=np.column_stack((X1,np.ones(X1.shape[0])))
X0=np.column_stack((X0,np.zeros(X0.shape[0])))
Xy=np.vstack((X0,X1))
np.random.shuffle(Xy)
trY=Xy[:,Xy.shape[1]-1]
S1_smote=np.delete(Xy,Xy.shape[1]-1,axis=1)
trY=trY.astype(int)

l_decoder=layer[l_s:]

model_as = StackedAutoEncoder(dims=l_decoder, activations=['tanh' for i in range(len(l_decoder))], noise='gaussian', 
	epoch=[10000 for i in range(len(l_decoder))],loss='rmse', lr=0.007, 
	batch_size=20, print_step=2000)

S=model_as.fit_transform(S1_smote)

model_test=StackedAutoEncoder(dims=layer, activations=['tanh' for i in range(len(l_encoder))]+['tanh' for i in range(len(l_decoder))], noise='gaussian', 
	epoch=[10000 for i in range(len(layer))],loss='rmse', lr=0.007, 
	batch_size=20, print_step=2000)
teX=model_test.fit_transform(teX)



_clf_dtree(S,teX,trY,teY)
_clf_svm(S,teX,trY,teY)
_clf_mlp(S,teX,trY,teY)
Esempio n. 2
0
teX = scaler.fit_transform(teX)

X0, X1 = _class_split(trX, trY)
print "smaller class shape", X1.shape
print "Enter hidden layer for SDAE"
layer_sdae = input()
layer_sdae = layer_sdae + [X1.shape[1]]
print "Enter oversampling percent"
P = int(input())

syn_X = sdae_syn(X_s=X1,
                 P=P,
                 h_layer=layer_sdae,
                 activations=['tanh' for i in range(len(layer_sdae))],
                 noise='gaussian',
                 epoch=[10000 for i in range(len(layer_sdae))],
                 loss='rmse',
                 batch_size=20)

X1 = np.vstack((X1, syn_X))
X1 = np.column_stack((X1, np.ones(X1.shape[0])))
X0 = np.column_stack((X0, np.zeros(X0.shape[0])))
Xy = np.vstack((X0, X1))
np.random.shuffle(Xy)
trY = Xy[:, Xy.shape[1] - 1]
trX = np.delete(Xy, Xy.shape[1] - 1, axis=1)

_clf_dtree(trX, teX, trY, teY)
# _clf_svm(trX,teX,trY,teY)
_clf_mlp(trX, teX, trY, teY)
X0,X1=_class_split(trX,trY)
print "smaller class shape",X1.shape
print "Enter hidden layer for SDAE"
layer_sdae=input()
layer_sdae=layer_sdae+[X1.shape[1]]
print "Enter oversampling percent"
P=int(input())

syn_X=sdae_syn(X_s=X1,P=P,h_layer=layer_sdae,
	activations=['tanh' for i in range(len(layer_sdae))],
	noise='gaussian',epoch=[10000 for i in range(len(layer_sdae))],
	loss='rmse',batch_size=20)



X1=np.vstack((X1,syn_X))
X1=np.column_stack((X1,np.ones(X1.shape[0])))
X0=np.column_stack((X0,np.zeros(X0.shape[0])))
Xy=np.vstack((X0,X1))
np.random.shuffle(Xy)
trY=Xy[:,Xy.shape[1]-1]
trX=np.delete(Xy,Xy.shape[1]-1,axis=1)



_clf_dtree(trX,teX,trY,teY)
_clf_softmax(trX,teX,trY,teY)
_clf_svm(trX,teX,trY,teY)
_clf_mlp(trX,teX,trY,teY)
Esempio n. 4
0
l_decoder = layer[l_s:]

model_as = StackedAutoEncoder(
    dims=l_decoder,
    activations=['tanh' for i in range(len(l_decoder))],
    noise='gaussian',
    epoch=[10000 for i in range(len(l_decoder))],
    loss='rmse',
    lr=0.007,
    batch_size=20,
    print_step=2000)

S = model_as.fit_transform(S1_smote)

model_test = StackedAutoEncoder(
    dims=layer,
    activations=['tanh' for i in range(len(l_encoder))] +
    ['tanh' for i in range(len(l_decoder))],
    noise='gaussian',
    epoch=[10000 for i in range(len(layer))],
    loss='rmse',
    lr=0.007,
    batch_size=20,
    print_step=2000)
teX = model_test.fit_transform(teX)

_clf_dtree(S, teX, trY, teY)
_clf_svm(S, teX, trY, teY)
_clf_mlp(S, teX, trY, teY)