def __init__(self, corpus_path, threshold=None, crossvalidate=True):
        self._logger = get_logger(self.__module__ + '.' + self.__class__.__name__)
        self._threshold = float('-inf') if threshold is None else threshold

        builder = self._get_classifier_builder(
            train_corpus_path=corpus_path,
            crossvalidate=crossvalidate,
            logger=self._logger
        )

        self._classifier = get_cached(builder, get_model_path(corpus_path))
try:
    import cPickle as pickle
except ImportError:  # pragma: no cover
    import pickle

import json
import csv
import os

from items_classifier.utils.log import get_logger
from items_classifier.configs.config import MODELS_DIR

_logger = get_logger(__name__)

def save_as_json(data, path):
    with open(path, 'w') as outfile:
        json.dump(data, outfile)


def read_as_json(path):
    with open(path) as data_file:
        data = json.load(data_file)
    return data


def save_json_as_csv(data, path):
    output = csv.writer(open(path, 'wb+'))
    output.writerow(data.keys())  # header row

    max_size = max(len(data[label]) for label in data)
    prepared_data = []