This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df=pd.read_csv('glass.csv') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
from sklearn.preprocessing import MinMaxScaler | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
from sklearn.model_selection import train_test_split | |
from sklearn.metrics import accuracy_score | |
import matplotlib.pyplot as plt | |
import tensorflow as tf | |
from tensorflow import keras |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
y_pred=classifier.predict(X_test) | |
y_pred=y_pred>0.5 | |
y_pred_int = y_pred.astype(int) | |
y_pred_int[:10] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plot_learningCurve(history, 15) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plot_learningCurve(history, epoch): | |
# Plot training & validation accuracy values | |
epoch_range = range(1, epoch+1) | |
plt.plot(epoch_range, history.history['accuracy']) | |
plt.plot(epoch_range, history.history['val_accuracy']) | |
plt.title('Model accuracy') | |
plt.ylabel('Accuracy') | |
plt.xlabel('Epoch') | |
plt.legend(['Train', 'Val'], loc='upper left') | |
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loss, accuracy = classifier.evaluate(X_test, y_test) | |
print('Accuracy: %.2f' % (accuracy*100)) | |
print('Loss: %.2f' % (loss*100)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
history = classifier.fit(X_train, y_train, epochs=15, validation_data=(X_test, y_test), verbose=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
classifier.summary() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
classifier.compile(optimizer='sgd',loss='binary_crossentropy',metrics=['accuracy']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
classifier=Sequential() | |
classifier.add(Dense(64,activation='relu',input_dim=117)) | |
classifier.add(Dropout(0.4)) | |
classifier.add(Dense(32,activation='relu')) | |
classifier.add(Dropout(0.3)) | |
classifier.add(Dense(2,activation='softmax')) |