Exemplo n.º 1
0
 def test_groupby1(self):
     df = load_iris()
     train_out = glm_train(
         df,
         feature_cols=['sepal_length', 'sepal_width', 'petal_length'],
         label_col='petal_width',
         group_by=['species'])
     predict_out = glm_predict(df, train_out['model'])
Exemplo n.º 2
0
 def test_groupby1(self):
     df = get_iris()
     train_out = glm_train(
         df,
         feature_cols=['sepal_length', 'sepal_width', 'petal_length'],
         label_col='petal_width',
         group_by=['species'])
     predict_out = glm_predict(df, train_out['model'])
     print(predict_out['out_table'][['petal_width', 'prediction']])
Exemplo n.º 3
0
 def test(self):
     glm_model = glm_train(
         self.testdata,
         feature_cols=['sepal_length', 'sepal_width', 'petal_length'],
         label_col='petal_width',
         family="Poisson",
         link='log',
         group_by=['species'])['model']
     np.testing.assert_array_almost_equal(
         glm_model['_grouped_data']['data']['setosa']['coefficients'],
         [-3.6342016377, 0.1245708937, 0.1885508496, 0.6428621488], 10)
     predict = glm_predict(self.testdata,
                           glm_model)['out_table']['prediction']
     np.testing.assert_array_almost_equal(predict[:5], [
         0.2371754544, 0.2105262982, 0.1999606014, 0.2203860121,
         0.2386977666
     ], 10)