Coder Social home page Coder Social logo

wittawatj / kernel-gof Goto Github PK

View Code? Open in Web Editor NEW
65.0 6.0 16.0 3.56 MB

NeurIPS 2017 best paper. An interpretable linear-time kernel goodness-of-fit test.

License: MIT License

Jupyter Notebook 46.07% Shell 0.73% Python 53.10% Dockerfile 0.10%
machine-learning kernel-methods goodness-of-fit statistical-tests python

kernel-gof's People

Contributors

djsutherland avatar wittawatj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

kernel-gof's Issues

When I try to work with 1D arrays - i get IndexError: too many indices for array

Am I doing something wrong, or code just designed for 2D arrays only?

Here is the code and the error

X = np.random.poisson(2, 400)
tr, te = train_test_split(X, test_size=0.8)
V_opt, gw_opt, opt_info = gof.GaussFSSD.optimize_auto_init(p, data.Data(tr), J, **opts)
IndexError                                Traceback (most recent call last)
<ipython-input-40-380dbe5289fc> in <module>
     14 # make sure to give tr (NOT te).
     15 # do the optimization with the options in opts.
---> 16 V_opt, gw_opt, opt_info = gof.GaussFSSD.optimize_auto_init(p, data.Data(tr), J, **opts)

~\AppData\Local\Continuum\anaconda3\envs\ml_python36\lib\site-packages\kgof\goftest.py in optimize_auto_init(p, dat, J, **ops)
    499         n_gwidth_cand = 5
    500         gwidth_factors = 2.0**np.linspace(-3, 3, n_gwidth_cand)
--> 501         med2 = util.meddistance(X, 1000)**2
    502 
    503         k = kernel.KGauss(med2*2)

~\AppData\Local\Continuum\anaconda3\envs\ml_python36\lib\site-packages\kgof\util.py in meddistance(X, subsample, mean_on_fail)
    146         np.random.set_state(rand_state)
    147         # recursion just one
--> 148         return meddistance(X[ind, :], None, mean_on_fail)
    149 
    150 

IndexError: too many indices for array

Gamma Distribution when k=1

Hi, I tried to test gamma distribution with your test.
I used a gradient log to specify p as below:

def gamma_grad_log(X):
    return ((k-1)/X - 1/theta)*(X>0)

When k=2 and theta=2, and build a sample data from same gamma distribution as below

k_t = 2
theta_t = 2
n=500
seed = 4
np.random.seed(seed)
X = np.random.gamma(k_t, theta_t,(n,1))

In this case, the test works fine - not reject H_0.
{'alpha': 0.01,
'h0_rejected': False,
'n_simulate': 3000,
'pvalue': 0.31133333333333335,
'test_stat': 0.0003191977834490073,
'time_secs': 0.001219034194946289}

But if k=1, the test will reject H_0.
{'alpha': 0.01,
'h0_rejected': True,
'n_simulate': 3000,
'pvalue': 0.0,
'test_stat': 100.18839042139058,
'time_secs': 0.0012459754943847656}

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.