CTRL
CTRL
CTRL
import pandas as pd
import numpy as np
import tensorflow as tf
drive.mount('/content/drive')
Shift + Enter
data.head()
Viewing the first 5 lines/ rows
data.info()
provides a concise summary of a DataFrame. It displays information about the DataFrame, such as the
number of rows and columns, the data types of each column, the number of non-null values, and the
memory usage
data.target.value_counts()
For counting number of unique values in the target column.
The resulting object will be in descending order so that the first element is the most frequently-
occurring element. Excludes NA values by default.
i.e. 1 1000
0 500
X.info()
The information contains the number of columns, column labels, column data types, memory
usage, range index, and the number of cells in each column (non-null values).
Here,
# Add the output layer with a single neuron and sigmoid activation for
binary classification
model.add(layers.Dense(1, activation='sigmoid'))
Above 32 neurons are connected to only one neuron.
import numpy as np
import tensorflow as tf
model = keras.Sequential()
# Add a Flatten layer to flatten the input data
model.add(layers.Flatten(input_shape=(13, 1)))
model.add(layers.Dense(64, activation='relu'))
model.add(layers.Dense(32, activation='relu'))
# Add the output layer with a single neuron and sigmoid activation for binary classification
model.add(layers.Dense(1, activation='sigmoid'))
metrics = [
'accuracy',
Precision(name='precision'),
Recall(name='recall'),
AUC(name='auc')
In Keras, compiling the model means configuring the learning process. It's where you define the
optimizer, loss function, and metrics that you want to use. The optimizer is the algorithm that adjusts
the weights of the network to minimize the loss function.
random_state = 1 Controls the shuffling applied to the data before applying the split.
The Merge layer
Multiple Sequential instances can be merged into a single output via a Merge layer. The output
is a layer that can be added as first layer in a new Sequential model. For instance, here's a
model with two separate input branches getting merged:
left_branch = Sequential()
left_branch.add(Dense(32, input_dim=784))
right_branch = Sequential()
right_branch.add(Dense(32, input_dim=784))
final_model = Sequential()
final_model.add(merged)
final_model.add(Dense(10, activation='softmax'))
https://faroit.com/keras-docs/1.0.6/getting-started/sequential-model-guide/