image_output_1.png
from keras.layers.normalization import BatchNormalization

from sklearn.model_selection import train_test_split

from sklearn.model_selection import train_test_split

from sklearn.preprocessing import  StandardScaler

from tensorflow.keras.layers import Conv2D, MaxPooling2D

from tensorflow.keras.layers import Dense, Dropout

from tensorflow.keras.layers import Dense, Dropout, Flatten

from tensorflow.keras.models import Sequential

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import tensorflow as tf

import tensorflow as tf

nRowsRead = 1000
df = pd.read_csv('../input/cusersmarildownloadsgermancsv/german.csv', delimiter=';', encoding='ISO-8859-2', nrows=nRowsRead)
df.dataframeName = 'german.csv'
nRow, nCol = df.shape

y = df['Creditability']
X = df.iloc[:, :-1]

label = y
train = X
(print('train shape: ', train.shape), print('label shape: ', label.shape))

x_train, x_test, y_train, y_test = train_test_split(train, label, test_size=0.3, random_state=42)

from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
x_train = scaler.fit_transform(x_train)
x_test = scaler.transform(x_test)

x_train = x_train.reshape(-1, 10, 10, 1)
x_test = x_test.reshape(-1, 10, 10, 1)

batch_size = 128
epochs = 8
learning_rate = 0.01
activation = 'relu'
Fully_connected_layer_nodes = 86
input_shape = (10, 10, 1)

img_rows = 10
img_cols = 10
if K.image_data_format() == 'channels_first':
    x_train = x_train.reshape(x_train.shape[0], 1, img_rows, img_cols)
    x_test = x_test.reshape(x_test.shape[0], 1, img_rows, img_cols)
    input_shape = (1, img_rows, img_cols)
else:
    x_train = x_train.reshape(x_train.shape[0], img_rows, img_cols, 1)
    x_test = x_test.reshape(x_test.shape[0], img_rows, img_cols, 1)
    input_shape = (img_rows, img_cols, 1)

model = Sequential()
model.add(Conv2D(8, kernel_size=(1, 1), activation=activation, padding='SAME', input_shape=input_shape))
model.add(BatchNormalization())
model.add(MaxPooling2D(pool_size=(1, 1)))
model.add(BatchNormalization())
model.add(Conv2D(36, (3, 3), activation=activation, padding='SAME'))
model.add(BatchNormalization())
model.add(MaxPooling2D(pool_size=(3, 3)))
model.add(BatchNormalization())
model.add(Flatten())
model.add(Dense(Fully_connected_layer_nodes, activation=activation))
model.add(BatchNormalization())
model.add(Dropout(0.2))
model.add(Dense(Fully_connected_layer_nodes, activation=activation))
model.add(BatchNormalization())
model.add(Dense(1, activation='linear'))
adam = tensorflow.keras.optimizers.Adam(lr=learning_rate)
callback = tf.keras.callbacks.EarlyStopping(monitor='loss', patience=5)
model.compile(loss='mean_squared_error', optimizer='adam', metrics=['mse'])
model.summary()

history = model.fit(x_train, y_train, batch_size=batch_size, epochs=epochs, callbacks=[callback], verbose=1, validation_data=(x_test, y_test), shuffle=False)
val_loss, val_acc = model.evaluate(x_test, y_test)
print('validation loss: ', val_loss)
print('<3 ')
print('validation accuracy: ', val_acc)
print('learn rate: ', learning_rate, 'epochs: ', epochs, 'activation: ', activation, "Fully Connected Layer's Node Number :", Fully_connected_layer_nodes)