Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import base64
- import pickle
- from io import BytesIO
- from sklearn.svm import LinearSVC
- from sklearn.calibration import CalibratedClassifierCV
- # create classifier
- clf = CalibratedClassifierCV(LinearSVC())
- # create byte-string with pickled model
- model_pickle_bytes = BytesIO()
- pickle.dump(clf, model_pickle_bytes)
- # create cube params odict
- cube_params = {
- "model_pickled": base64.encodebytes(model_pickle_bytes.getvalue()).decode("ascii")
- }
- # save to JSON
- json_dict = json.dumps(cube_params)
- ####
- # load from JSON
- clf_loaded = pickle.load(BytesIO(base64.decodebytes(cube_params["model_pickled"].encode("ascii"))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement