def to_json(self, X, y):
        '''
        Reads dataset to csv.

        :param X: dataset as list of dict.
        :param y: labels.
        '''
        with gzip.open('%s.gz' % self.path, 'wt') if self.gz else open(
                self.path, 'w') as file:
            json.dump(list(zip(y, X)), file)