Binary classification

Introduction to Deep Learning with Keras

Miguel Esteban

Data Scientist & Founder

When to use binary classification?

Introduction to Deep Learning with Keras

Our dataset

Introduction to Deep Learning with Keras

Pairplots

import seaborn as sns

# Plot a pairplot
sns.pairplot(circles, hue="target")

Introduction to Deep Learning with Keras

Introduction to Deep Learning with Keras

Introduction to Deep Learning with Keras

Introduction to Deep Learning with Keras

Introduction to Deep Learning with Keras

Introduction to Deep Learning with Keras

The sigmoid function

Introduction to Deep Learning with Keras

Let's build it

from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense

# Instantiate a sequential model model = Sequential()

Introduction to Deep Learning with Keras

Let's build it

from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense

# Instantiate a sequential model model = Sequential()
# Add input and hidden layer model.add(Dense(4, input_shape=(2,), activation='tanh'))

Introduction to Deep Learning with Keras

Let's build it

from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense

# Instantiate a sequential model model = Sequential()
# Add input and hidden layer model.add(Dense(4, input_shape=(2,), activation='tanh'))
# Add output layer, use sigmoid model.add(Dense(1, activation='sigmoid'))

Introduction to Deep Learning with Keras

Compiling, training, predicting

# Compile model
model.compile(optimizer='sgd',
              loss='binary_crossentropy')

# Train model model.train(coordinates, labels, epochs=20)
# Predict with trained model preds = model.predict(coordinates)
Introduction to Deep Learning with Keras

Introduction to Deep Learning with Keras

Let's practice!

Introduction to Deep Learning with Keras

Preparing Video For Download...