MCPcopy Create free account
hub / github.com/rushter/MLAlgorithms / test_mlp

Function test_mlp

mla/tests/test_classification_accuracy.py:68–90  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

66
67
68def test_mlp():
69 y_train_onehot = one_hot(y_train)
70 y_test_onehot = one_hot(y_test)
71
72 model = NeuralNet(
73 layers=[
74 Dense(256, Parameters(init="uniform", regularizers={"W": L2(0.05)})),
75 Activation("relu"),
76 Dropout(0.5),
77 Dense(128, Parameters(init="normal", constraints={"W": MaxNorm()})),
78 Activation("relu"),
79 Dense(2),
80 Activation("softmax"),
81 ],
82 loss="categorical_crossentropy",
83 optimizer=Adadelta(),
84 metric="accuracy",
85 batch_size=64,
86 max_epochs=25,
87 )
88 model.fit(X_train, y_train_onehot)
89 predictions = model.predict(X_test)
90 assert roc_auc_score(y_test_onehot[:, 0], predictions[:, 0]) >= 0.95
91
92
93def test_gbm():

Callers

nothing calls this directly

Calls 11

fitMethod · 0.95
one_hotFunction · 0.90
NeuralNetClass · 0.90
DenseClass · 0.90
ParametersClass · 0.90
L2Class · 0.90
ActivationClass · 0.90
DropoutClass · 0.90
MaxNormClass · 0.90
AdadeltaClass · 0.90
predictMethod · 0.45

Tested by

no test coverage detected