-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode_for_model.py
104 lines (93 loc) · 5.82 KB
/
code_for_model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
from __future__ import absolute_import, division, print_function
import os
import numpy as np
import pandas as pd
import tensorflow as tf
from sklearn.model_selection import train_test_split
df = pd.read_csv(r"train.csv")
df = df.sample(frac=1)
#df0 = df[df["target"]==0]
#df0 = df.sample(frac=0.33)
#df1 = df[df["target"] == 1]
#dff = pd.concat([df0, df1])
#dff = dff.sample(frac=1)
X = df.iloc[:, 2:].values
Y = df.iloc[:, 1].values
k = 0.1
xt, xtt, yt, ytt = train_test_split(X, Y, test_size=0.05, random_state=42)
i=1000
j = tf.nn.relu
k=0.4
model = tf.keras.models.Sequential([tf.keras.layers.Dense(i,input_shape=(200,), activation=j),
tf.keras.layers.Dropout(rate=k),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(i, activation=j),
tf.keras.layers.Dropout(rate=k),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(i, activation=j),
tf.keras.layers.Dropout(rate=k),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(i, activation=j),
tf.keras.layers.Dropout(rate=k),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(i, activation=j),
tf.keras.layers.Dropout(rate=k),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(i, activation=j),
tf.keras.layers.Dropout(rate=k),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(i, activation=j),
tf.keras.layers.Dropout(rate=k),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(i, activation=j),
tf.keras.layers.Dropout(rate=k),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(i, activation=j),
tf.keras.layers.Dropout(rate=k),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(i, activation=j),
tf.keras.layers.Dropout(rate=k),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(i, activation=j),
tf.keras.layers.Dropout(rate=k),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(i, activation=j),
tf.keras.layers.Dropout(rate=k),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(i, activation=j),
tf.keras.layers.Dropout(rate=k),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(i, activation=j),
tf.keras.layers.Dropout(rate=k),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(i, activation=j),
tf.keras.layers.Dropout(rate=k),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(i, activation=j),
tf.keras.layers.Dropout(rate=k),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(i, activation=j),
tf.keras.layers.Dropout(rate=k),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(i, activation=j),
tf.keras.layers.Dropout(rate=k),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(i, activation=j),
tf.keras.layers.Dropout(rate=k),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(i, activation=j),
tf.keras.layers.Dropout(rate=k),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(i, activation=j),
tf.keras.layers.Dropout(rate=k),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(i, activation=j),
tf.keras.layers.Dropout(rate=k),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Dense(1, activation=tf.nn.sigmoid)])
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
model.fit(xt, yt, batch_size=380, validation_data=(xtt, ytt), epochs=100, use_multiprocessing=True)
test_loss, test_acc = model.evaluate(xtt, ytt, batch_size=200, use_multiprocessing=True)
model.save("santandar.h5")
print('Test accuracy:', test_acc)
print("parameter:" ,str(i), str(j), str(k))