BaşlayınÜcretsiz başlayın

Maximization function

We saw that the EM algorithm is an iterative method between two steps: the expectation and the maximization. In the last exercise, you created the expectation function. Now, create the maximization function which takes the data frame with the probabilities and outputs the estimations of the means and proportions.

Bu egzersiz, kursun bir parçasıdır

Mixture Models in R

Kursa Göz Atın

Egzersiz talimatları

Create the function maximization by completing the sample code.

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

maximization <- function(___){
  means_estimates <- data_with_probs %>%
    summarise(mean_1 = sum(x * ___) / ___(prob_cluster1),
              mean_2 = sum(x * ___) / ___(prob_cluster2)) %>% 
    as.numeric()
  props_estimates <- data_with_probs %>% 
    summarise(proportion_1 = ___(prob_cluster1),
              proportion_2 = 1 - ___) %>% 
    as.numeric()
  list(means_estimates, props_estimates)   
}
Kodu Düzenle ve Çalıştır