text: from sklearn_json import classification as clf
  from sklearn_json import regression as reg
  from sklearn_json import feature_extraction as ext
  from sklearn_json import preprocessing as pre
  from sklearn import svm, discriminant_analysis, dummy
  from sklearn.feature_extraction import DictVectorizer
  from sklearn.linear_model import LogisticRegression, Perceptron
  from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor
  from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier, RandomForestRegressor, GradientBoostingRegressor, _gb_losses
  from sklearn.naive_bayes import BernoulliNB, GaussianNB, MultinomialNB, ComplementNB
  from sklearn.linear_model import LinearRegression, Lasso, Ridge
  from sklearn.neural_network import MLPClassifier, MLPRegressor
  from sklearn.preprocessing import MultiLabelBinarizer
  from sklearn.svm import SVR
  import json
  
  __version__ = '0.1.0'
  
  
  def serialize_model(model):
      if isinstance(model, LogisticRegression):
          return clf.serialize_logistic_regression(model)
      elif isinstance(model, BernoulliNB):
          return clf.serialize_bernoulli_nb(model)
      elif isinstance(model, GaussianNB):
          return clf.serialize_gaussian_nb(model)
      elif isinstance(model, MultinomialNB):
          return clf.serialize_multinomial_nb(model)
      elif isinstance(model, ComplementNB):
          return clf.serialize_complement_nb(model)
      elif isinstance(model, discriminant_analysis.LinearDiscriminantAnalysis):
          return clf.serialize_lda(model)
      elif isinstance(model, discriminant_analysis.QuadraticDiscriminantAnalysis):
          return clf.serialize_qda(model)
      elif isinstance(model, svm.SVC):
          return clf.serialize_svm(model)
      elif isinstance(model, Perceptron):
          return clf.serialize_perceptron(model)
      elif isinstance(model, DecisionTreeClassifier):
          return clf.serialize_decision_tree(model)
      elif isinstance(model, GradientBoostingClassifier):
          return clf.serialize_gradient_boosting(model)
      elif isinstance(model, RandomForestClassifier):
          return clf.serialize_random_forest(model)
      elif isinstance(model, MLPClassifier):
          return clf.serialize_mlp(model)
  
      elif isinstance(model, LinearRegression):
          return reg.serialize_linear_regressor(model)
      elif isinstance(model, Lasso):
          return reg.serialize_lasso_regressor(model)
      elif isinstance(model, Ridge):
          return reg.serialize_ridge_regressor(model)
      elif isinstance(model, SVR):
          return reg.serialize_svr(model)
      elif isinstance(model, DecisionTreeRegressor):
          return reg.serialize_decision_tree_regressor(model)
      elif isinstance(model, GradientBoostingRegressor):
          return reg.serialize_gradient_boosting_regressor(model)
      elif isinstance(model, RandomForestRegressor):
          return reg.serialize_random_forest_regressor(model)
      elif isinstance(model, MLPRegressor):
          return reg.serialize_mlp_regressor(model)
  
      elif isinstance(model, DictVectorizer):
          return ext.serialize_dict_vectorizer(model)
  
      elif isinstance(model, MultiLabelBinarizer):
          return pre.serialize_multilabel_binarizer(model)
      else:
          raise ModellNotSupported('This model type is not currently supported. Email support@mlrequest.com to request a feature or report a bug.')
  
  
  def deserialize_model(model_dict):
      if model_dict['meta'] == 'lr':
          return clf.deserialize_logistic_regression(model_dict)
      elif model_dict['meta'] == 'bernoulli-nb':
          return clf.deserialize_bernoulli_nb(model_dict)
      elif model_dict['meta'] == 'gaussian-nb':
          return clf.deserialize_gaussian_nb(model_dict)
      elif model_dict['meta'] == 'multinomial-nb':
          return clf.deserialize_multinomial_nb(model_dict)
      elif model_dict['meta'] == 'complement-nb':
          return clf.deserialize_complement_nb(model_dict)
      elif model_dict['meta'] == 'lda':
          return clf.deserialize_lda(model_dict)
      elif model_dict['meta'] == 'qda':
          return clf.deserialize_qda(model_dict)
      elif model_dict['meta'] == 'svm':
          return clf.deserialize_svm(model_dict)
      elif model_dict['meta'] == 'perceptron':
          return clf.deserialize_perceptron(model_dict)
      elif model_dict['meta'] == 'decision-tree':
          return clf.deserialize_decision_tree(model_dict)
      elif model_dict['meta'] == 'gb':
          return clf.deserialize_gradient_boosting(model_dict)
      elif model_dict['meta'] == 'rf':
          return clf.deserialize_random_forest(model_dict)
      elif model_dict['meta'] == 'mlp':
          return clf.deserialize_mlp(model_dict)
  
      elif model_dict['meta'] == 'linear-regression':
          return reg.deserialize_linear_regressor(model_dict)
      elif model_dict['meta'] == 'lasso-regression':
          return reg.deserialize_lasso_regressor(model_dict)
      elif model_dict['meta'] == 'ridge-regression':
          return reg.deserialize_ridge_regressor(model_dict)
      elif model_dict['meta'] == 'svr':
          return reg.deserialize_svr(model_dict)
      elif model_dict['meta'] == 'decision-tree-regression':
          return reg.deserialize_decision_tree_regressor(model_dict)
      elif model_dict['meta'] == 'gb-regression':
          return reg.deserialize_gradient_boosting_regressor(model_dict)
      elif model_dict['meta'] == 'rf-regression':
          return reg.deserialize_random_forest_regressor(model_dict)
      elif model_dict['meta'] == 'mlp-regression':
          return reg.deserialize_mlp_regressor(model_dict)
  
      elif model_dict['meta'] == 'dict-vectorizer':
          return ext.deserialize_dict_vectorizer(model_dict)
  
      elif model_dict['meta'] == 'multilabel-binarizer':
          return pre.deserialize_multilabel_binarizer(model_dict)
      else:
          raise ModellNotSupported('Model type not supported or corrupt JSON file. Email support@mlrequest.com to request a feature or report a bug.')
  
  
  def to_dict(model):
      return serialize_model(model)
  
  
  def from_dict(model_dict):
      return deserialize_model(model_dict)
  
  
  def to_json(model, model_name):
      with open(model_name, 'w') as model_json:
          json.dump(serialize_model(model), model_json)
  
  
  def from_json(model_name):
      with open(model_name, 'r') as model_json:
          model_dict = json.load(model_json)
          return deserialize_model(model_dict)
  
  class ModellNotSupported(Exception):
      pass