def test_supervisedpcaClassifier():
    iris=datasets.load_iris()
    X = iris.data
    Y = iris.target

    spca = SupervisedPCAClassifier()
    spca.fit(X, Y,threshold=1,n_components=2)

    assert_array_equal(spca._leavouts,[0,1])
    assert_almost_equal(spca._model.coef_[0][0], -2.43973048)
Exemple #2
0
def test_supervisedpcaClassifier():
    iris = datasets.load_iris()
    X = iris.data
    Y = iris.target

    spca = SupervisedPCAClassifier()
    spca.fit(X, Y, threshold=1, n_components=2)

    assert_array_equal(spca._leavouts, [0, 1])
    assert_almost_equal(spca._model.coef_[0][0], -2.43973048)
def test_supervisedpcaClassifier_predict():
    iris=datasets.load_iris()
    X = iris.data
    Y = iris.target

    spca = SupervisedPCAClassifier()
    spca.fit(X, Y)
    
    predictions = spca.predict(X)
    error=np.mean(sum(abs(predictions-Y))/float(len(predictions)))
    assert_almost_equal(error,0.08666666)
Exemple #4
0
def test_supervisedpcaClassifier_predict():
    iris = datasets.load_iris()
    X = iris.data
    Y = iris.target

    spca = SupervisedPCAClassifier()
    spca.fit(X, Y)

    predictions = spca.predict(X)
    error = np.mean(sum(abs(predictions - Y)) / float(len(predictions)))
    assert_almost_equal(error, 0.08666666)
from SupervisedPCA import SupervisedPCARegressor
from SupervisedPCA import SupervisedPCAClassifier
from sklearn.utils.testing import assert_almost_equal
from sklearn.utils.testing import assert_array_equal
from sklearn import datasets
import numpy as np

diabetes = datasets.load_iris()
X = diabetes.data
Y = diabetes.target

spca = SupervisedPCAClassifier()
spca.fit(X, Y, threshold=1.7)
print(spca._model.coef_)