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
# Predicting the Test set results | |
y_pred = classifier.predict(X_test) | |
y_pred = (y_pred > 0.5) | |
# Making the Confusion Matrix | |
from sklearn.metrics import confusion_matrix | |
cm = confusion_matrix(y_test, y_pred) |
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
# Fitting the ANN to the Training set | |
classifier.fit(X_train, y_train, batch_size = 10, epochs = 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
# Adding the input layer and the first hidden layer | |
classifier.add(Dense(units = 16, kernel_initializer = 'uniform', activation = 'relu', input_dim = 30)) | |
# Adding the second hidden layer | |
classifier.add(Dense(units = 16, kernel_initializer = 'uniform', activation = 'relu')) | |
# Adding the output layer | |
classifier.add(Dense(units = 1, kernel_initializer = 'uniform', activation = 'sigmoid')) | |
# Compiling the ANN |
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
# Initialising the ANN | |
classifier = Sequential() |
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
# Importing the Keras libraries and packages | |
import keras | |
from keras.models import Sequential | |
from keras.layers import Dense |
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
#Splitting into Training set and Test set | |
from sklearn.model_selection import train_test_split | |
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 42) |
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
#Encoding Categorical Data | |
from sklearn.preprocessing import LabelEncoder | |
labelencoder = LabelEncoder() | |
y = labelencoder.fit_transform(y) |
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
#Seperating dependent and independent variables. | |
X = dataset.iloc[:, 2:32].values #Note: Exclude Last column with all NaN values. | |
y = dataset.iloc[:, 1].values |
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 numpy as np | |
import pandas as pd | |
#Importing dataset | |
dataset = pd.read_csv('breast_cancer.csv') | |
#Check the first 5 rows of the dataset. | |
dataset.head(5) |
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
#Uploading the Dataset | |
from google.colab import files | |
uploaded = files.upload() | |
#Save uploaded file on the Virtual Machine's | |
#Thanks to user3800642 from StackOverflow | |
with open("breast_cancer.csv", 'w') as f: | |
f.write(uploaded[uploaded.keys()[0]]) |