Exemple #1
0
def test_kerneldensitypredict():
    x, y = data.categorical_2Dmatrix_bernoulli_data()
    km = kernelmethods.KernelMethods()
    km.fit(x, y)
    predict = km.kerneldensitypredict([1, 2], 0.8)
    assert predict == 0
Exemple #2
0
def test_kerneldensityestimate():
    x, y = data.continuous_data_complicated()
    km = kernelmethods.KernelMethods()
    km.fit(x, y)
    kde = km.kerneldensityestimate([5], 1)
    np.testing.assert_almost_equal(kde, 0)
Exemple #3
0
def test_nadarayaaverage():
    x, y = data.continuous_data_complicated()
    km = kernelmethods.KernelMethods()
    km.fit(x, y)
    predict = km.nadarayaaverage(5.5, km.gaussiankernel, 0.01)
    np.testing.assert_almost_equal(predict, 4.237, 2)
Exemple #4
0
def test_locallinearregression():
    x, y = data.continuous_data_complicated()
    km = kernelmethods.KernelMethods()
    km.fit(x, y)
    predict = km.locallinearregression(5.5, km.gaussiankernel, 0.1)
    np.testing.assert_almost_equal(predict, 5.092, 2)
Exemple #5
0
def test_kernelmethods_fit():
    x, y = data.continuous_data_complicated()
    km = kernelmethods.KernelMethods()
    km.fit(x, y)
    assert km.learned