
Explore natural language processing in python, from text processing and vectorization to language models, transformers, and real-world applications like spam detection, sentiment analysis, and translation.
Use the beginner, intermediate, and advanced designations in titles to guide your path through this course. Pace yourself, practice, and leverage the materials at your level.
Learn where to access course code for machine learning NLP in Python, including notebooks and plain text Python files, via the resources tab, code link, and GitHub repositories.
Ask questions via the Q&A to get answers typically within 24 hours. Meet prerequisites and engage with conceptual and coding lectures by taking handwritten notes and coding.
Handle temporary 403 errors when downloading files by noting the host may block CoLab due to public IPs, then download in a browser and upload via the notebook's file explorer.
Convert language into numerical representations for NLP using vector models. Explore token, character, and vocabulary concepts, tokenization, stemming, stop words, and TF-IDF, plus basic word vectors like word2vec and GloVe.
Learn basic natural language processing definitions for English text, including sentences, tokens, and characters, vocabulary, corpus, and engram, with unigrams, bigrams, and trigrams, and a look at Markov models.
Understand what a vector is as an array of scalars representing text in high dimensions, enabling spam detection, document clustering, and NLP within machine learning.
Explore the bag of words representation, which ignores word order and can blur phrases like dog toy versus toy dog, yet it remains widely used in vector models.
Explore the counting method, a simple bag-of-words approach to convert text into document vectors by counting word occurrences, with discussion of tokenization, vocabulary mapping, and normalization considerations.
Explore tokenization in NLP using split versus advanced options, including punctuation handling, casing, accents, and word, character, or subword approaches, with practical trade-offs.
Explore stop words in text vectorization, and how removing them reduces dimensionality and improves differentiation; use scikit-learn's stop words features and multilingual lists to tailor for your language.
Learn how stemming and lemmatization reduce vocabulary size by converting related word forms to a root or lemma, improving search relevance and natural language processing efficiency with practical examples.
Observe a Colab demo comparing stemming and lemmatization using the Porter stemmer and WordNet, showing how POS tagging guides accurate lemmas and explains real words versus nonwords.
Preview of machine learning with the count vectorizer in Python, showing a pipeline of fit, transform, and evaluate on BBC News data with five labels, highlighting tokenization choices and sparsity.
Explore tf-idf theory, detailing term frequency and inverse document frequency, and demonstrate practical use with a tf-idf vectorizer and its common variations.
Build a movie recommendation system by combining keywords, genres, synopsis, tagline, production companies, and production countries into document strings, then apply tf-idf and rank the top five similar movies.
Explore how to build a tf-idf based movie recommender in python by extracting genres and keywords, vectorizing text, and ranking results with cosine similarity.
Learn to build a word to index mapping from a text corpus by tokenizing documents, using a Python dictionary, and handling unknown words for effective count vectors and NLP workflows.
Build a from-scratch tf-idf model on BBC news data, map words to indices, compute tf and idf, and identify top terms for random documents.
Explore neural word embeddings that map words to vectors for fine-grained text representations beyond bag-of-words. Learn how word2vec and GloVe enable sequence models and word analogies.
Demonstrate neural word embeddings using pre-trained vectors, loading embeddings, implementing analogies and nearest neighbors to compare glove vectors with other embeddings.
Convert text to vectors via tokenization, stop words, stemming, and lemmatization; use bag-of-words, tf-idf, and word-to-index mapping, then explore neural word embeddings like word2vec and glove for word analogies.
Explore simple text summarization using vector-based methods and term frequencies, and see how these approaches fit into your existing machine learning course path.
Apply NLP to any language by tokenizing text, mapping tokens to integers, and creating a matrix of document vectors while choosing or building language-specific tokenizers.
Learn how a suggestion box collects learner feedback for the machine learning: natural language processing in Python course, including background, difficulty, missing explanations, and requests for future topics.
Introduce probabilistic models in natural language processing, focusing on Markov models and the shift from vector representations to language based approaches, with applications like page rank and cipher decryption.
Explore how Markov models underpin natural language processing, reinforcement learning, and speech recognition, train them with a state transaction matrix, and generate poetry from an author's existing poems.
Explore the Markov property as the restrictive assumption in sequence modeling, where each symbol depends only on the preceding one, enabling a chain-rule joint distribution for language and beyond.
The lecture presents Markov model for sequences of categorical states, detailing the state distribution pi, the state transition matrix A, and the initial distribution pi, and explains training from data.
Explore smoothing techniques like add-one and epsilon smoothing to fix zero probability issues in Markov models, and learn to compute sequence probabilities using log probabilities to avoid underflow.
Apply Markov models to build a text classifier, using Bayes rule to compare authors and select the most probable class via log-likelihood and maximum a posteriori.
Build a text classifier to distinguish Edgar Allan Poe from Robert Frost using two separate Markov models, a train-test split, and evaluation metrics like accuracy and F1 score.
Build a text classifier with Markov models to distinguish Edgar Allan Poe and Robert Frost from poem lines, using data, preprocessing, tokenization, and A and Pi matrices with smoothing.
Populate A and pi from training data, implement a compute counts function, and build a log-probability text classifier; evaluate with confusion matrices and F1 scores on train and test sets.
Explore how Markov models generate text and why they are generative rather than discriminative. Learn sampling, second-order Markov extensions, and the computational trade-offs compared with neural networks.
Explore building a second-order Markov language model from a Robert Frost poetry corpus. Store word probabilities with dictionaries and sample text using cumulative probabilities without smoothing.
Build a second-order language model to generate Robert Frost poems by constructing initial, first-order, and second-order dictionaries, tokenizing text, removing punctuation, and converting word lists into probabilities.
Implement a word sampler from a probability dictionary using a uniform draw and cumulative sum, then generate four lines of poems with initial, first-order, and second-order models.
Explore the Markov model’s role in NLP, from the Markov property to first- and second-order forms, and relate simple forecasting to neural networks and transformers.
Explore the article spinning problem, its impact on blog visibility and search rankings, and how Markov models and Transformers relate to automated content generation and ethics.
Apply n-gram and markov models to article spinning by predicting next words from previous context. Use first- and second-order dependencies and maximum likelihood estimates to replace text while preserving grammar.
Spin the article spinner exercise with a BBC business dataset using a three-dimensional V by V by V matrix, and explore tokenization options that preserve punctuation with a treebank tokenizer.
Develop a Python-based article spinner by building a tri-gram model from the BBC news dataset, using tokenization, detokenization, and text wrapping to present spun business articles.
Explore how to build an article spinner in Python, using a random seed, tri-grams, and context window techniques to analyze long-range dependencies and semantic coherence.
Examine why article spinning fails without context and grammar, compare simple synonym replacement to deeper models, and learn ethical risks like plagiarism.
Explore a unique cipher project that combines probabilistic language models and genetic algorithms to encode, decode, and evolve solutions, then implement the theory in code.
Explore the substitution cipher in natural language processing, learning how a one-to-one letter mapping encrypts and decrypts messages, with an explicit example and a spy's perspective on cracking the code.
Learn how language models assign high probabilities to real text using engrams and bigrams within a markov framework, apply add-one smoothing, and decode with log-likelihood maximization.
Explore how genetic algorithms optimize a substitution cipher by evolving dna-like letter mappings through swapping mutations, fitness evaluation via log likelihood, and population-based selection.
Describe the code needed for a message decryption script, including a random substitution cipher, a character-level language model from Moby Dick, log likelihood evaluation, encoding, decoding, and a genetic algorithm.
Build a substitution cipher from a randomized letter mapping and compare the decrypted results to the true answer using a simulated genetic algorithm.
Build a language model for cipher decryption using a 26x26 bigram matrix and a 26-entry initial distribution, with add-one smoothing, and functions to update transition and compute log probabilities.
Download the Moby Dick text, clean it with a regex to remove non-alphabetic characters, and train the language model by tokenizing, lowercasing, and normalizing bigram and trigram counts.
Encode and decode a message with a substitution cipher by normalizing to lowercase, replacing non letters with spaces, and mapping characters via encode and decode functions.
This lecture implements an evolutionary cipher solver in python by creating a dna pool of 20 random strings, evolving offspring via swaps, and scoring decoded messages with log likelihood.
Review decoded and true messages, compare log likelihoods, examine mapping errors and randomness-driven variability, and plot the objective per iteration to illustrate convergence in cipher decryption.
Clarify the misconception that this method can crack modern encryption like RSA, and emphasize its real use for learning NLP, ML, language models, and optimization methods.
Explore a real-world application of cipher decryption through a laser microphone keystroke keylogger, using clustering to map keystroke sounds to encoded characters and decode them.
Learn cipher decryption by combining substitution ciphers, probabilistic language models, and genetic algorithms; build a character-level markov model with add-one smoothing and log likelihood to optimize decryption.
Introduce the next major part of machine learning, covering vector-based and probability-based models, with interchangeable techniques and application-focused sections on spam detection, sentiment analysis, and Latent Semantic Indexing.
Describe what spam detection is and why we want to filter unwanted messages, such as emails or texts, using a simple function that returns 1 for spam and 0 otherwise.
Explore Bayes rule intuition for classification, defining priors, likelihoods, and posteriors, then explain Naive Bayes' independence assumption and common distributions for NLP, like Gaussian, multinomial, and Bernoulli.
Develop a text classifier to detect spam in sms messages, split data into train and test, explore count vectorizer and tf-idf with stop words, and evaluate with accuracy.
Explore how class imbalance distorts accuracy and how a confusion matrix reveals true positives, false positives, true negatives, and false negatives, with sensitivity, specificity, precision, recall, and the F1 score.
Explain class imbalance and roc curve, showing the tradeoff between true positive rate and false positives. Note auc and f1 score as alternatives, and explain how predict_proba enables probability-based thresholding.
This lecture guides building an sms spam classifier in python using count vectorizer features, evaluating with f1, roc auc score, and confusion matrices, plus word clouds and misclassification analysis.
Explore sentiment analysis as a supervised task that predicts sentiment from text (positive, negative, or neutral) using classification or regression, with applications in reputation monitoring and stock market.
Explore the intuition of logistic regression as a linear classifier using vector features for sentiment analysis, its sigmoid probability, and a comparison of discriminative logistic regression with generative Naive Bayes.
Explore multiclass logistic regression using softmax to convert class scores into a probability distribution, with outputs as an n by k matrix and predictions by the maximum probability per sample.
Learn to train logistic regression in Python, fit models with iterative optimization, generate predictions and probabilities, and interpret weights for both binary and multiclass cases.
Implement sentiment analysis on a tweets dataset labeled positive, negative, or neutral, splitting into train-test sets. Build a logistic regression classifier with count or tf-idf vectorization, and evaluate accuracy, F1.
Implement sentiment analysis on airline tweets using Python, TF-IDF features, and logistic regression; explore class imbalance, AUC, and multiclass evaluation with one-vs-one and confusion matrices.
The lecture demonstrates filtering to positive and negative samples, tf-idf vectorization, and logistic regression with accuracy, plus interpreting weights via a word-to-index mapping and identifying top weighted words for sentiment.
Ever wondered how AI technologies like OpenAI ChatGPT, GPT-4, DALL-E, Midjourney, and Stable Diffusion really work? In this course, you will learn the foundations of these groundbreaking applications.
Hello friends!
Welcome to Machine Learning: Natural Language Processing in Python (Version 2).
This is a massive 4-in-1 course covering:
1) Vector models and text preprocessing methods
2) Probability models and Markov models
3) Machine learning methods
4) Deep learning and neural network methods
In part 1, which covers vector models and text preprocessing methods, you will learn about why vectors are so essential in data science and artificial intelligence. You will learn about various techniques for converting text into vectors, such as the CountVectorizer and TF-IDF, and you'll learn the basics of neural embedding methods like word2vec, and GloVe.
You'll then apply what you learned for various tasks, such as:
Text classification
Document retrieval / search engine
Text summarization
Along the way, you'll also learn important text preprocessing steps, such as tokenization, stemming, and lemmatization.
You'll be introduced briefly to classic NLP tasks such as parts-of-speech tagging.
In part 2, which covers probability models and Markov models, you'll learn about one of the most important models in all of data science and machine learning in the past 100 years. It has been applied in many areas in addition to NLP, such as finance, bioinformatics, and reinforcement learning.
In this course, you'll see how such probability models can be used in various ways, such as:
Building a text classifier
Article spinning
Text generation (generating poetry)
Importantly, these methods are an essential prerequisite for understanding how the latest Transformer (attention) models such as BERT and GPT-3 work. Specifically, we'll learn about 2 important tasks which correspond with the pre-training objectives for BERT and GPT.
In part 3, which covers machine learning methods, you'll learn about more of the classic NLP tasks, such as:
Spam detection
Sentiment analysis
Latent semantic analysis (also known as latent semantic indexing)
Topic modeling
This section will be application-focused rather than theory-focused, meaning that instead of spending most of our effort learning about the details of various ML algorithms, you'll be focusing on how they can be applied to the above tasks.
Of course, you'll still need to learn something about those algorithms in order to understand what's going on. The following algorithms will be used:
Naive Bayes
Logistic Regression
Principal Components Analysis (PCA) / Singular Value Decomposition (SVD)
Latent Dirichlet Allocation (LDA)
These are not just "any" machine learning / artificial intelligence algorithms but rather, ones that have been staples in NLP and are thus an essential part of any NLP course.
In part 4, which covers deep learning methods, you'll learn about modern neural network architectures that can be applied to solve NLP tasks. Thanks to their great power and flexibility, neural networks can be used to solve any of the aforementioned tasks in the course.
You'll learn about:
Feedforward Artificial Neural Networks (ANNs)
Embeddings
Convolutional Neural Networks (CNNs)
Recurrent Neural Networks (RNNs)
The study of RNNs will involve modern architectures such as the LSTM and GRU which have been widely used by Google, Amazon, Apple, Facebook, etc. for difficult tasks such as language translation, speech recognition, and text-to-speech.
Obviously, as the latest Transformers (such as BERT and GPT-3) are examples of deep neural networks, this part of the course is an essential prerequisite for understanding Transformers.
You will learn how Transformers accelerated progress in AI research, and how scaling laws, techniques like pre-training, supervised fine-tuning, RLHF (reinforcement learning from human feedback), DPO (direct preference optimization), GRPO (group relative policy optimization), alignment, and more, have led to the latest advancements in the field, including vision-language models, multimodal models, and Agentic AI / AI Agents.
UNIQUE FEATURES
Every line of code explained in detail - email me any time if you disagree
No wasted time "typing" on the keyboard like other courses - let's be honest, nobody can really write code worth learning about in just 20 minutes from scratch
Not afraid of university-level math - get important details about algorithms that other courses leave out
Thank you for reading and I hope to see you soon!