Professional Documents
Culture Documents
Deeplearning - Ai Deeplearning - Ai
Deeplearning - Ai Deeplearning - Ai
DeepLearning.AI makes these slides available for educational purposes. You may not use or distribute
these slides for commercial purposes. You may make copies of these slides and use or distribute them for
educational purposes as long as you cite DeepLearning.AI as the source of the slides.
Cost
Prediction
Features Output Output
Function vs
Label
Labels
Sentiment analysis
Positive: 1
Tweet I am happy because I am learning NLP
:
Negative: 0
Logistic regression
Sentiment analysis
I am happy
because I am Train
Classify Positive: 1
learning NLP LR
Summary
● Features, Labels Train Predict
● Feature extraction
[ 1, 1, 1, 1, 1, 1, ... 0, 0, 0]
1. Large training
time
2. Large prediction time
Summary
● Vocabulary: set of unique words
● Stemming
● Lowercasing
Preprocessing: stop words and punctuation
Great great
tune
great
tun tuned
tuning Preprocessed tweet:
[tun, great, ai, model]
Summary
● Stop words, punctuation, handles and URLs
● Stemming
● Lowercasing
● Sigmoid function
Overview of logistic regression
Parameters
Cost
Features F Output Output
vs
Sigmoid
Label
Labels
Overview of logistic regression
Overview of logistic regression
@YMourri and 4.92
@AndrewYNg are tuning a
GREAT AI model
● , positive
● , negative
Logistic
Regression:
Training
deeplearning.ai
Outline
● Review the steps in the training process
Cost
Iteration
Training LR
Initialize
parameters
Classify/predict
Get gradient
Until good
enough
Update
Get Loss
Summary
● Visualize how gradient descent works
● Use gradient descent to train your logistic regression classifier
,
Testing logistic regression
●
,
Testing logistic regression
●
,
Testing logistic regression
Summary
● Performance on unseen data
● Accuracy
To improve model: step size, number of iterations, regularization, new features, etc.
Logistic
Regression:
Cost Function
deeplearning.ai
Outline
● Overview of the logistic cost function, AKA the binary cross-entropy
function
Cost function for logistic regression
Cost function for logistic regression
Cost function for logistic regression
0 any 0
1 0.99 ~0
1 ~0 -inf
Cost function for logistic regression
1 any 0
0 0.01 ~0
0 ~1 -inf
Cost function for logistic regression
Cost function for logistic regression
Summary
● Strong disagreement = high cost