Giter VIP home page Giter VIP logo

mle's People

Contributors

dvolkow avatar

Stargazers

 avatar

Watchers

 avatar  avatar

mle's Issues

Non-linear model?

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.

[codestyle] Reading files via context manager semantic in python

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).

numpy usage

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]

[codestyle] Debug output in minimize()

'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).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.