Beispiel #1
0
def test_predict_series(df):
    clusterer = KMeansClusterer()
    clusterer.fit(df)
    new = {'feature1': 2, 'feature2': 2}
    series = pd.Series(data=new)
    clusterer.predict(series)
Beispiel #2
0
def test_predict_not_fitted():
    clusterer = KMeansClusterer()
    new = {'feature1': 2, 'feature2': 2}
    series = pd.Series(data=new)
    with pytest.raises(AttributeError):
        clusterer.predict(series)
Beispiel #3
0
def test_predict_dataframe(df):
    clusterer = KMeansClusterer()
    clusterer.fit(df)
    new = {'feature1': [2], 'feature2': [2]}
    dataframe = pd.DataFrame(data=new)
    clusterer.predict(dataframe)
Beispiel #4
0
def test_predict_featuresets(df):
    clusterer = KMeansClusterer()
    clusterer.fit(df)
    new = [{'feature1': 2, 'feature2': 2}]
    clusterer.predict(new)
Beispiel #5
0
def test_predict_dict(df):
    clusterer = KMeansClusterer()
    clusterer.fit(df)
    new = {'feature1': 2, 'feature2': 2}
    clusterer.predict(new)
Beispiel #6
0
def test_predict_bad_input_value(df):
    clusterer = KMeansClusterer()
    clusterer.fit(df)
    with pytest.raises(ValueError):
        clusterer.predict(pd.Series([0, 1, 2]))
Beispiel #7
0
def test_predict_bad_input_type(df):
    clusterer = KMeansClusterer()
    clusterer.fit(df)
    with pytest.raises(TypeError):
        clusterer.predict([0, 1])