🌍 freeCodeCamp · flashcards
freeCodeCamp Machine Learning with Python Flashcards
50 question-and-answer cards covering Machine Learning with Python as it is examined in freeCodeCamp. 24 of them are printed below, taken from across the deck — no signup, no paywall on the preview.
24 sample cards from the Machine Learning with Python deck
Sampled from the end of the deck, so these are different cards from the ones shown on the syllabus page.
What is word embedding in NLP?
A learned mapping of each word to a dense vector in a lower-dimensional space where similar words have similar vectors (small angle/distance between them), unlike sparse one-hot encodings.
In text preprocessing for neural networks, what do tokenization and padding accomplish?
Tokenization converts text into integer sequences (each word/token gets an index); padding adds zeros (or truncates) so all sequences share a fixed length, allowing them to be batched into one tensor.
What makes a recurrent neural network (RNN) suited to sequence data?
It processes elements one at a time while maintaining a hidden internal state that summarizes what it has seen so far, so earlier inputs influence the processing of later ones.
What is the vanishing gradient problem in simple RNNs?
During backpropagation through time, gradients are multiplied at each step and can shrink exponentially, so weight updates for early time steps become negligible and the network fails to learn long-range dependencies.
How does an LSTM improve on a simple RNN?
It adds a cell state plus input, forget, and output gates that control what information is stored, discarded, and emitted, letting gradients flow across many time steps and capturing long-term dependencies.
How does an RNN language model generate text?
Trained to predict the next character/word given the sequence so far, it generates text by sampling from its output distribution and feeding each prediction back in as the next input, repeating step by step.
What is Q-learning?
A model-free reinforcement learning algorithm that learns the action-value function $Q(s, a)$ — the expected future reward of taking action $a$ in state $s$ — stored in a Q-table and updated from experience.
Write the Q-learning update rule.
$$Q(s, a) \leftarrow Q(s, a) + \alpha \left[ r + \gamma \max_{a'} Q(s', a') - Q(s, a) \right]$$ where $\alpha$ is the learning rate, $r$ the reward, $\gamma$ the discount factor, and $s'$ the next state.
What is the exploration–exploitation tradeoff, and how does the epsilon-greedy strategy handle it?
The agent must balance trying new actions (exploration) against using known good actions (exploitation). Epsilon-greedy picks a random action with probability $\epsilon$ and the best-known action with probability $1 - \epsilon$, usually decaying $\epsilon$ over time.
What does the discount factor $\gamma$ control in reinforcement learning?
How much future rewards are worth relative to immediate ones, with $0 \leq \gamma \leq 1$: $\gamma$ near 0 makes the agent myopic; $\gamma$ near 1 makes it value long-term reward. Return: $G_{t} = \sum_{k=0}^{\infty} \gamma^{k} r_{t+k+1}$.
What are the components of a Markov Decision Process (MDP)?
A tuple $(S, A, P, R, \gamma)$: states $S$, actions $A$, transition probabilities $P(s' \mid s, a)$, reward function $R$, and discount factor $\gamma$.
What is the Markov property?
The future depends only on the current state and action, not the full history: $P(s_{t+1} \mid s_{t}, a_{t}, s_{t-1}, \ldots) = P(s_{t+1} \mid s_{t}, a_{t})$.
In an MDP, what is a policy and what makes a policy optimal?
A policy $\pi(s)$ maps each state to an action (or distribution over actions). The optimal policy $\pi^{*}$ maximizes expected cumulative discounted reward from every state; with Q-learning it is $\pi^{*}(s) = \arg\max_{a} Q(s, a)$.
In the freeCodeCamp Rock Paper Scissors project, what must your player achieve, and why can't it play randomly?
It must win at least 60% of games against each of four bots (over 1000 games). Random play yields only about 50% win rate against exploitable bots, so the player must detect and exploit each opponent's pattern.
What general strategy beats the pattern-based bots in the Rock Paper Scissors project?
Track the opponent's move history (e.g., frequency of recent n-grams of moves), predict their most likely next move, and play the move that beats it — adapting as the opponent's pattern changes.
In the Cat and Dog Image Classifier project, what network type and output layer are used, and what accuracy is required?
A CNN (Conv2D + MaxPooling blocks, then dense layers) with a single sigmoid output unit for binary classification; predictions above/below a 0.5 threshold map to dog/cat. Required test accuracy: at least 63% (70% for extra credit).
What does ImageDataGenerator (with flow_from_directory) provide in the Cat and Dog project?
It loads images in batches from directory structure, rescales pixel values (e.g., multiply by $\frac{1}{255}$ to get $[0,1]$), resizes them to a fixed size, and can apply random augmentation transforms on the fly.
Why are pixel values normalized from $[0, 255]$ to $[0, 1]$ before training?
Small, consistent input scales keep gradients well-behaved, speeding up and stabilizing training; large raw values can cause unstable updates and slow convergence.
How does the Book Recommendation Engine use K-Nearest Neighbors to recommend books?
Each book is a vector of user ratings in a sparse user–book matrix; sklearn's NearestNeighbors (cosine metric) finds the books whose rating vectors are closest to the query book, and those neighbors (with their distances) are returned as recommendations.
Why are users and books with few ratings filtered out in the Book Recommendation project?
Users with fewer than 200 ratings and books with fewer than 100 ratings are removed for statistical significance — vectors with almost no ratings give unreliable, noisy distances and meaningless neighbors.
What is cosine similarity between two vectors?
$$\cos\theta = \frac{\vec{a} \cdot \vec{b}}{\lVert \vec{a} \rVert \, \lVert \vec{b} \rVert}$$ It measures the angle between vectors regardless of magnitude: 1 means same direction, 0 means orthogonal (no similarity).
What is the linear regression model equation for predicting a value from several features?
$$\hat{y} = w_{1} x_{1} + w_{2} x_{2} + \cdots + w_{n} x_{n} + b$$ Training finds the weights $w_{i}$ and bias $b$ that minimize the prediction error (e.g., mean squared error) on the training data.
In the Health Costs Calculator project, how must categorical data be handled, how is the data split, and what error is required?
Categorical features (sex, smoker, region) are converted to numbers (label or one-hot encoding); 80% of the data trains the model and 20% tests it; the model must reach mean absolute error under \$3500. MAE: $\frac{1}{n} \sum_{i=1}^{n} \lvert y_{i} - \hat{y}_{i} \rvert$.
Outline the pipeline of the Neural Network SMS Text Classifier.
Tokenize each SMS into integer sequences and pad to fixed length; feed through an Embedding layer, then a recurrent/pooling layer and dense layers to a sigmoid output giving the probability of 'spam' (vs 'ham', i.e., normal messages); classify by thresholding at 0.5.
What this deck covers
The Machine Learning with Python deck follows the freeCodeCamp Machine Learning with Python syllabus — 5 chapters and 14 topics — so questions land on material that is genuinely examinable rather than trivia around it. That works out to roughly 10.0 cards per chapter.
Answers are written to be recallable, not just readable — averaging about 211 characters, which is long enough to carry the reasoning and short enough to say out loud.
A deck like this earns its keep on the second and third pass. Read the syllabus first so you know the shape of the subject, then use the cards to find the specific facts that have not stuck.
Machine Learning with Python flashcards FAQ
How many Machine Learning with Python flashcards are in this freeCodeCamp deck?
50 cards. This page previews 24 of them, sampled evenly across the deck so you can judge the difficulty before installing anything.
Are these freeCodeCamp flashcards free?
Yes. The preview here is free to read with no signup, and the full 50-card deck is free inside the Examius app.
What do the Machine Learning with Python cards cover?
They follow the freeCodeCamp Machine Learning with Python syllabus — 5 chapters and 14 topics — so the questions track what is actually examinable.
How should I use these flashcards?
Read the syllabus first so you know the shape of the subject, then drill the deck. Examius schedules each card with spaced repetition, so cards you keep missing come back sooner and ones you know drift further apart.