lib/rumale/decomposition/factor_analysis.rb in rumale-0.18.6 vs lib/rumale/decomposition/factor_analysis.rb in rumale-0.18.7
- old
+ new
@@ -88,12 +88,14 @@
s, u = truncate_svd(scaled_x, @params[:n_components])
scaler = Numo::NMath.sqrt(Numo::DFloat.maximum(s**2 - 1.0, 0.0))
@components = (sqrt_noise_variance.diag.dot(u) * scaler).transpose.dup
@noise_variance = Numo::DFloat.maximum(sample_vars - @components.transpose.dot(@components).diagonal, 1e-12)
next if @params[:tol].nil?
+
new_loglike = log_likelihood(cov_mat, @components, @noise_variance)
@loglike.push(new_loglike)
break if (old_loglike - new_loglike).abs <= @params[:tol]
+
old_loglike = new_loglike
end
@loglike = Numo::DFloat.cast(@loglike) unless @params[:tol].nil?
@components = @components[0, true].dup if @params[:n_components] == 1