F1 Machine Learning EM Algorithm Practice
F1 Machine Learning EM Algorithm Practice
In the maximization step, the new mean values are calculated as weighted averages of the lap times according to the responsibilities. For µ1, it is calculated as the sum of γ(𝑧𝑖1) times X divided by the sum of γ(𝑧𝑖1), resulting in (0.8*87 + 0.5*90 + 0.2*94) / (0.8+0.5+0.2). For µ2, calculate (0.2*87 + 0.5*90 + 0.8*94) / (0.2+0.5+0.8).
Calculate the sufficient statistics for the Beta distribution given the spins observed. Perform the E-step by assigning probabilities to each driver's category based on the Beta distribution. In the M-step, update each distribution parameter: α(new) = ∑γ * (observed counts + prior α - 1), β(new) = ∑γ * (1 - observed counts + prior β - 1), where γ is the responsibility for either careful or aggressive drivers.
The EM algorithm is suitable because it can handle latent variables, allowing for estimation of probabilities even when the classification of data points (machine types) is incomplete. It iteratively refines the parameter estimates (probabilities) by calculating expected values of latent variables in the E-step and updating parameters based on these expectations in the M-step. Challenges include the algorithm potentially converging to local maxima and requiring good initial parameter estimates to ensure reasonable solutions.
The log-likelihood is found by computing the probability of each lap time under both Gaussian components and then taking the logarithm of the sum of these probabilities weighted by their respective component probabilities. For each lap time, calculate the probability under the Quali Mode and Fuel-Saving Mode using p(x|Quali) = (1/(√(2π*σ1^2))) * exp(-(x-µ1)^2/(2*σ1^2)) and p(x|Fuel-saving) = (1/(√(2π*σ2^2))) * exp(-(x-µ2)^2/(2*σ2^2)). Then, the total probability for each lap time is π1*p(x|Quali) + π2*p(x|Fuel-saving). Finally, the log-likelihood is the sum of the logarithms of these probabilities across all lap times.
Calculate the probability of observing each error count under the minor and major error Poisson distributions. For a count xi, compute the probability under each distribution: P(xi|Minor) = (e^(-λ1) * λ1^xi) / xi! and P(xi|Major) = (e^(-λ2) * λ2^xi) / xi!. The expected assignment probability for each pit stop is then π1*P(xi|Minor) / [π1*P(xi|Minor) + π2*P(xi|Major)] for minor errors, and π2*P(xi|Major) / [π1*P(xi|Minor) + π2*P(xi|Major)] for major errors.
The EM algorithm ensures an increase in likelihood due to its design: the E-step computes the expected log-likelihood which the M-step then maximizes. This guarantees a non-decreasing sequence of the expected log-likelihood. EM converges to a local maximum of the likelihood function, not necessarily a global maximum, due to its iterative refinement based on the initial configuration.
Compute the probability of observing 6 million dollars under each component of the Gamma distribution. Use the density f(x|α,β) = β^α/Γ(α) * x^(α-1) * e^(-βx). For the hidden investors, compute P(x=6|α2,β2) = (2^5/Gamma(5)) * 6^(5-1) * e^(-2*6). The expected probability is then π2*P(6|Hidden) / [π1*P(6|Sponsor) + π2*P(6|Hidden)].
The E-step computes the expected value of the latent variables, given current parameter estimates, by assigning weights (responsibilities) to components in the mixture model based on observed data. The M-step maximizes the expected log-likelihood found in the E-step with respect to the parameters, updating the model parameters. The E-step is necessary to infer the most likely component that generated each observation, while the M-step refines the model parameters given these inferred assignments.
First, calculate the likelihood of each lap time under the model for Scuderia Ferrari and Red Bull using their respective Gaussian distributions. For a lap time x: p(x|Ferrari) = (1/(√(2πσ1^2))) * exp(-(x-µ1)^2/(2σ1^2)) and p(x|Red Bull) = (1/(√(2πσ2^2))) * exp(-(x-µ2)^2/(2σ2^2)). Use these to calculate the posterior using Bayes' theorem: P(Ferrari|x) = π1*p(x|Ferrari) / (π1*p(x|Ferrari) + π2*p(x|Red Bull)) for each lap time in X = {89, 92, 87}.
Compute the responsibility of each component for each lap time. For a lap time xi, the responsibility for component 1 is γ(z1|xi) = π1*p(xi|µ1, σ1) / [π1*p(xi|µ1, σ1) + π2*p(xi|µ2, σ2)], where p(x|µ,σ) is the Gaussian probability density function. Use initial parameters to compute these values across all lap times in X.