def test_selects_all():
    from sklearn.neighbors import KNeighborsClassifier
    from mlxtend.data import wine_data

    X, y = wine_data()
    knn = KNeighborsClassifier(n_neighbors=4)
    sbs = SBS(knn, k_features=13, scoring='accuracy', cv=3, print_progress=False)
    sbs.fit(X, y)
    assert(len(sbs.indices_) == 13)
def test_selects_all():
    from sklearn.neighbors import KNeighborsClassifier
    from mlxtend.data import wine_data

    X, y = wine_data()
    knn = KNeighborsClassifier(n_neighbors=4)
    sbs = SBS(knn,
              k_features=13,
              scoring='accuracy',
              cv=3,
              print_progress=False)
    sbs.fit(X, y)
    assert (len(sbs.indices_) == 13)
def test_Iris():
    from sklearn.neighbors import KNeighborsClassifier
    from sklearn.datasets import load_iris

    iris = load_iris()
    X = iris.data
    y = iris.target

    knn = KNeighborsClassifier(n_neighbors=4)

    sbs = SBS(knn, k_features=2, scoring='accuracy', cv=5)
    sbs.fit(X, y)

    assert(sbs.indices_ == (0, 3))
    assert(sbs.k_score_ == 0.96)
Esempio n. 4
0
def test_hello():
    print 'test'
    iris = load_iris()
    x, y = iris.data, iris.target
    print x[0]
    clf = DecisionTreeClassifier()
    sbs = SBS(clf, k_features=2)
    sbs = sbs.fit(x, y)
    print sbs.transform(x)
def test_Iris():
    from sklearn.neighbors import KNeighborsClassifier
    from sklearn.datasets import load_iris

    iris = load_iris()
    X = iris.data
    y = iris.target

    knn = KNeighborsClassifier(n_neighbors=4)

    sbs = SBS(knn,
              k_features=2,
              scoring='accuracy',
              cv=5,
              print_progress=False)
    sbs.fit(X, y)

    assert (sbs.indices_ == (0, 3))
    assert (round(sbs.k_score_, 2) == 0.96)