def save_model_to_disk(name, model, model_dir='models'):

    # First serialized the model
    serialized_model = pickle.dumps(model, protocol=pickle.HIGHEST_PROTOCOL)

    # Model directory + model name
    model_path = os.path.join(model_dir, name+'.model')

    # Now store it to disk
    print 'Storing Serialized Model to Disk (%s:%.2fMeg)' % (name, len(serialized_model)/1024.0/1024.0)
    open(model_path,'wb').write(serialized_model)
Serialize and save a model to disk
dataset/ETHPy150Open ClickSecurity/data_hacking/dga_detection/dga_model_gen.py/save_model_to_disk