dvolkow / mle Goto Github PK
View Code? Open in Web Editor NEWThis spring special seminar for stellar astronomers about maximum likelyhood estimation method.
This spring special seminar for stellar astronomers about maximum likelyhood estimation method.
Right, you've said the method works not very well with poly degree > 1, and it would be understandable to see some function like vr(params, degree)
that works with any degree, but degree=1
is hardcoded for now; but I dont see even a support for higher degrees. That's bad, please, generalize this.
In mle_io.py:
f = open(DATASET_FILE, 'r')
reader = csv.reader(f)
#reading
In modern python you'd rather use context manager semantics:
with open(DATASET_FILE, 'r') as f:
reader = csv.reader(f)
#reading
This is better due to automatic cleanup in any case after leaving the with
scope.
I will mark non-critical issues as [codestyle], as there are no issue labels defined in the repo (or I can't assign one).
Generally, numpy is much faster then python native arrays (altho in this case I didn't achieve significant speed-up by merely using numpy everywhere).
Numpy lets you to carry operations on whole arrays (much like in R):
vr = vr_calc_all(R_0, A) + v_sun_all(u, v, w) # this is array already
sigma = stdev(vr)
L = - len(data.l) * math.log(math.sqrt(2 * math.pi) * sigma)
vr_diff = vr - data.vr
vr_diff_sqr = np.power(vr_diff, 2)
L -= np.sum(vr_diff_sqr) / (2 * sigma ** 2)
I also changed lists to numpy arrays everywhere to achieve array-wise operations, like:
def r_all(self, r0):
if r0 != self.cached_value[0]:
r0s = np.repeat(r0, self.distcos.shape[0])
self.cached_value = (r0, np.sqrt(np.power(r0s, 2) + self.distcos - self.dblcos * r0))
return self.cached_value[1]
'minimize' function you use supports the 'callback' argument it calls after each iteration, you can insert debug output there.
The difference with what you did is that it is called only after each full iteration; the likelyhood_log function, on the other hand, is called many times per iteration (every time minimizer needs any value for calculations, say, it's called multiple times only to numerically calculate a singe derivative value).
In python, you can assign values from tuple-style object like this:
R_0, A, u, v, w = parameters
This is more pythonic then assigning them line-by-line.
For compare and control results.
Now model provide only linear form estimation polinom.
Need for some optimizers into scipy methods, as jac
parameter.
Please, provide full reference results you achieved via LSE earlier.
Now only point-type result.
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.