Example #1
0
def regress_predict(exp, field, model):
    pred = model.predict(exp.data)
    df = pd.DataFrame({
        'Y_PRED': pred,
        'Y_TRUE': exp.sample_metadata[field].values,
        'SAMPLE': exp.sample_metadata[field].index.values,
        'CV': 0
    })
    plot_scatter(df, cv=False)
    return df
Example #2
0
 def test_plot_scatter(self):
     res = pd.read_table(join(self.test_data_dir, 'diabetes_pred.txt'), index_col=0)
     title = 'foo'
     ax = plot_scatter(res, title=title)
     self.assertEqual(title, ax.get_title())
     cor = 'r=-0.62 p-value=0.078'
     self.assertEqual(cor, ax.texts[0].get_text())
     dots = []
     for collection in ax.collections:
         dots.append(collection.get_offsets())
     assert_array_equal(np.concatenate(dots, axis=0),
                        res[['Y_TRUE', 'Y_PRED']].values)