Git Product home page Git Product logo

men2017's People

Contributors

ddomingof avatar icxa avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

men2017's Issues

Consider PEP-8: Line length

Lines generally shouldn't go over 79. For the case of triple-quoted docstrings, it's easy to just split these over multiple lines.

"""Given the values in the three by three contingency table and the values of the number of positive/negative/non-significant predictions (q+, q-, q0) this function calculates the D-value (or weight).

Use list unpacking

There are a lot of places where you're getting sequential elements from a list. Use unpacking to make this code more readable:

MEN2017/miscellaneous.py

Lines 74 to 75 in 1f77631

q_p = predictionListStats[0]
q_m = predictionListStats[1]

At best, this can look like:

q_p,  q_m = predictionListStats

If there are more elements in predictionListStats, then you have a couple options:

Explicit assignment

q_p,  q_m = predictionListStats[0], predictionListStats[1] 

Unpacking sliced list

q_p,  q_m = predictionListStats[0:2]

Splat Unpacking

q_p,  q_m, *_ = predictionListStats

Use vectorized functions in numpy

You can use vectorized operations in numpy to operate over entire arrays, then list unpack.

Also, remember that <- isn't a valid assingment in Python and the R people also finally decided to stop doing this too (it's only in legacy code or from legacy coders)

f_n_pp <- floor(twoByTwoContingencyTable[0]) #(floor in R/python --> largest integer value less than or equal to x)
f_n_pm <- floor(twoByTwoContingencyTable[1])
f_n_mp <- floor(twoByTwoContingencyTable[2])
f_n_mm <- floor(twoByTwoContingencyTable[3])

f_n_pp,  f_n_pm, f_n_mp, f_n_mm = np.floor(twoByTwoContingencyTable[0:4])

Use Sphinx-style documentation

R and Python don't have the same documentation styles, so this has to be slightly re-written.

Python-style documentation also allows for embedding of mathtype and latex, so the yucky math looks beautiful

Check numeric instability

There must be a way to compute the log of the factorial directly to avoid dealing with ridiculous big numbers

return sum(logOfFactorialOfPredictionListStats) - sum(math.log(math.factorial(threeByThreeContingencyTable)))

At least, this code should be refactored since the pattern of sum log factorial is repeated many times throughout this repo

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.