Beispiel #1
0
 def test_kmeans_groupby1(self):
     df = load_iris()
     train_out = kmeans_train_predict(df,
                                      input_cols=[
                                          'sepal_length', 'sepal_width',
                                          'petal_length', 'petal_width'
                                      ],
                                      group_by=['species'])
     predict_out = kmeans_predict(df, train_out['model'])
Beispiel #2
0
    def test_kmeans_1(self):
        train_out = kmeans_train_predict(self.iris, input_cols=['sepal_length', 'sepal_width', 'petal_length', 'petal_width'], seed=12345)
        predict_out = kmeans_predict(self.iris, train_out['model'])
        table = predict_out['out_table'].values.tolist()

        self.assertListEqual(table[0], [5.1, 3.5, 1.4, 0.2, 'setosa', 0])
        self.assertListEqual(table[1], [4.9, 3.0, 1.4, 0.2, 'setosa', 0])
        self.assertListEqual(table[2], [4.7, 3.2, 1.3, 0.2, 'setosa', 0])
        self.assertListEqual(table[3], [4.6, 3.1, 1.5, 0.2, 'setosa', 0])
        self.assertListEqual(table[4], [5.0, 3.6, 1.4, 0.2, 'setosa', 0])
Beispiel #3
0
    def test_kmeans_groupby1(self):
        train_out = kmeans_train_predict(self.iris, input_cols=['sepal_length', 'sepal_width', 'petal_length', 'petal_width'], seed=12345, n_clusters=2, n_init=4, max_iter=10, n_jobs=3, n_samples=2, group_by=['species'])
        predict_out = kmeans_predict(self.iris, train_out['model'])
        table = predict_out['out_table'].values.tolist()

        self.assertListEqual(table[0], [5.1, 3.5, 1.4, 0.2, 'setosa', 1])
        self.assertListEqual(table[1], [4.9, 3.0, 1.4, 0.2, 'setosa', 0])
        self.assertListEqual(table[2], [4.7, 3.2, 1.3, 0.2, 'setosa', 0])
        self.assertListEqual(table[3], [4.6, 3.1, 1.5, 0.2, 'setosa', 0])
        self.assertListEqual(table[4], [5.0, 3.6, 1.4, 0.2, 'setosa', 1])
Beispiel #4
0
 def kmeans_groupby1(self):
     df = get_iris()
     train_out = kmeans_train_predict(df, input_cols=['sepal_length', 'sepal_width', 'petal_length', 'petal_width'], group_by=['species'])
     predict_out = kmeans_predict(df, train_out['model'])
     print(predict_out['out_table'])