def test_data_roundtrip(): "save/load roundtrip shouldn't change data" d = micro_data() path = None try: path = testing.create_tempfile('numerox.h5') d.save(path) d2 = nx.load_data(path) ade(d, d2, "data corrupted during roundtrip") d.save(path, compress=True) d2 = nx.load_data(path) ade(d, d2, "data corrupted during roundtrip") d = d['live'] d.save(path) d2 = nx.load_data(path) ade(d, d2, "data corrupted during roundtrip") finally: testing.delete_tempfile(path)
def test_data_roundtrip(): "save/load roundtrip shouldn't change data" d = micro_data() with tempfile.NamedTemporaryFile() as temp: d.save(temp.name) d2 = nx.load_data(temp.name) ade(d, d2, "data corrupted during roundtrip") d.save(temp.name, compress=True) d2 = nx.load_data(temp.name) ade(d, d2, "data corrupted during roundtrip") d = d['live'] d.save(temp.name) d2 = nx.load_data(temp.name) ade(d, d2, "data corrupted during roundtrip")
def play_data(): """About 1% of a regular Numerai dataset, so contains around 60 rows per era""" return nx.load_data(TEST_DATA)
metric = metric_df.mean(axis=0).tolist() consis = (metric_df['logloss'] < np.log(2)).mean() metric.extend([consis, model]) df.loc[i] = metric return df def load_report(prediction_dir, extension='pred'): "Load Prediction objects (hdf) in `prediction_dir`; return Report object" original_dir = os.getcwd() os.chdir(prediction_dir) predictions = {} try: for filename in glob.glob("*{}".format(extension)): prediction = load_prediction(filename) model = filename[:-len(extension) - 1] predictions[model] = prediction finally: os.chdir(original_dir) report = Report() report.append_prediction_dict(predictions) return report if __name__ == '__main__': import numerox as nx data = nx.load_data('/data/nx/numerai_dataset_20171024.hdf') report = nx.report.load_report('/data/nx/pred') report.performance(data['train'], sort_by='consis')