Tensorflow Realize the logical regression - Two classification
import tensorflow as tf
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# Logical regression - Two classification
data = pd.read_csv('credit-a.csv', header=None)
print(data.iloc[:, -1].value_counts())
x = data.iloc[:, :-1]
y = data.iloc[:, -1].replace(-1, 0)
model = tf.keras.Sequential()
model.add(tf.keras.layers.Dense(4, input_shape=(15,), activation='relu'))
model.add(tf.keras.layers.Dense(4, activation='relu'))
model.add(tf.keras.layers.Dense(1, activation='sigmoid'))
print(model.summary())
model.compile(optimizer='adam',
loss='binary_crossentropy',
metrics=['acc'])
history = model.fit(x, y, epochs=100)
plt.plot(history.epoch, history.history.get('loss'))
plt.show()
plt.plot(history.epoch, history.history.get('acc'))
plt.show()