samashi47 / em-algorithm Goto Github PK
View Code? Open in Web Editor NEWExpectation–Maximization (EM) algorithm implementation in R and Python, and a comparison with K-means.
Expectation–Maximization (EM) algorithm implementation in R and Python, and a comparison with K-means.
NA values in test with mall customers dataset
Iterate until it converges or arrives at maxit, then print the results.
It iterates a number of iteration (maybe 10) and params values become NaN, then it stops and prints:
Error in if (min(abs(paramsOld - paramsCurrent)) < tol) { :
missing value where TRUE/FALSE needed
With some printing statements to debug:
Iterations of EM:
[1] 0.00 0.10 0.35 0.65 0.90
[1] 1.406076e+03 5.441687e-02 1.844696e-01 3.286551e-01 4.324584e-01
Iteration - 1...
[1] 1.406076e+03 5.441687e-02 1.844696e-01 3.286551e-01 4.324584e-01
[1] 1.406007e+03 5.449429e-02 1.844855e-01 3.285626e-01 4.324577e-01
[1] 1.406007e+03 5.449429e-02 1.844855e-01 3.285626e-01 4.324577e-01
[1] 1.405878e+03 5.464702e-02 1.845239e-01 3.283898e-01 4.324393e-01
[1] 1.405878e+03 5.464702e-02 1.845239e-01 3.283898e-01 4.324393e-01
[1] 1.405614e+03 5.496482e-02 1.846160e-01 3.280472e-01 4.323719e-01
[1] 1.405614e+03 5.496482e-02 1.846160e-01 3.280472e-01 4.323719e-01
[1] 1.405040e+03 5.567459e-02 1.848507e-01 3.273132e-01 4.321615e-01
Iteration - 5...
[1] 1.405040e+03 5.567459e-02 1.848507e-01 3.273132e-01 4.321615e-01
[1] 1.403752e+03 5.732103e-02 1.854629e-01 3.256718e-01 4.315442e-01
[1] 1.403752e+03 5.732103e-02 1.854629e-01 3.256718e-01 4.315442e-01
[1] 1.400936e+03 6.107273e-02 1.870133e-01 3.220353e-01 4.298786e-01
[1] 1.400936e+03 6.107273e-02 1.870133e-01 3.220353e-01 4.298786e-01
[1] 1.395328e+03 6.879273e-02 1.905219e-01 3.145853e-01 4.261001e-01
[1] 1.395328e+03 6.879273e-02 1.905219e-01 3.145853e-01 4.261001e-01
[1] 1.385599e+03 8.201161e-02 1.967473e-01 3.015865e-01 4.196546e-01
[1] 1.385599e+03 8.201161e-02 1.967473e-01 3.015865e-01 4.196546e-01
[1] 1369.5543130 0.1023314 0.2033040 0.2829653 0.4113993
Iteration - 10...
[1] 1369.5543130 0.1023314 0.2033040 0.2829653 0.4113993
[1] 1319.6236650 0.1487267 0.1961885 0.2554316 0.3996531
[1] 1319.6236650 0.1487267 0.1961885 0.2554316 0.3996531
[1] -7056.5065741 0.3041669 0.1403421 0.1932749 0.3622161
[1] -7056.5065741 0.3041669 0.1403421 0.1932749 0.3622161
[1] NaN 0.56000000 0.13097109 0.09977132 0.20925759
Error in if (min(abs(paramsOld - paramsCurrent)) < tol) { :
missing value where TRUE/FALSE needed
if you ignore the NaNvalues, then it finishes until maxit, and all result values will be NaN.
Better NaN values handling, or better initial values if thats what generated the bug.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.