本文整理匯總了Python中sklearn.externals.joblib.dump方法的典型用法代碼示例。如果您正苦於以下問題:Python joblib.dump方法的具體用法?Python joblib.dump怎麽用?Python joblib.dump使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sklearn.externals.joblib
的用法示例。
在下文中一共展示了joblib.dump方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: save_classifier_model
# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import dump [as 別名]
def save_classifier_model(df_question_train, df_question_class, model_type="linearSVC"):
"""
FIXME: Although the classifier is being saved in Pickle file. It is not being used to predict.
Since, Support Vector Classifier, fails when it encounters new features it failed to see while training.
"""
classifier_model = None
training_model_path = os.path.join(CORPUS_DIR, QUESTION_CLASSIFICATION_MODEL)
if model_type == "linearSVC":
classifier_model = support_vector_machine(df_question_train, df_question_class)
else:
logger.error("Undefined Classifier")
if classifier_model is not None:
joblib.dump(classifier_model, training_model_path)
logger.info("Model saved at {0}".format(training_model_path))
else:
logger.error("Model empty")
示例2: save_predictions
# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import dump [as 別名]
def save_predictions(train_ids, train_predictions, meta_test, out_of_fold_test_predictions):
averaged_mask_predictions_test = np.mean(np.array(out_of_fold_test_predictions), axis=0)
LOGGER.info('Saving predictions')
out_of_fold_train_predictions_path = os.path.join(EXPERIMENT_DIR, 'out_of_fold_train_predictions.pkl')
joblib.dump({'ids': train_ids,
'images': train_predictions}, out_of_fold_train_predictions_path)
out_of_fold_test_predictions_path = os.path.join(EXPERIMENT_DIR, 'out_of_fold_test_predictions.pkl')
joblib.dump({'ids': meta_test[ID_COLUMN].tolist(),
'images': averaged_mask_predictions_test}, out_of_fold_test_predictions_path)
# .___ ___. ___ __ .__ __.
# | \/ | / \ | | | \ | |
# | \ / | / ^ \ | | | \| |
# | |\/| | / /_\ \ | | | . ` |
# | | | | / _____ \ | | | |\ |
# |__| |__| /__/ \__\ |__| |__| \__|
#
示例3: store_models
# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import dump [as 別名]
def store_models(self) -> None:
"""
Save the learners to disk.
:returns: None
:rtype: None
"""
# Iterate over the learner types (for which there will be
# separate instances for each sub-experiment of the
# cross-validation experiment)
for learner_name in self.cv_learners_:
loginfo('Saving {0} model files to disk...'.format(learner_name))
for i, estimator in enumerate(self.cv_learners_[learner_name]):
loginfo('Saving {0} model file #{1}'.format(learner_name, i + 1))
joblib.dump(estimator,
self.model_path_template_.format(learner_name, i + 1))
示例4: save
# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import dump [as 別名]
def save(self, model_fname):
"""
Save the model into file.
Args:
model_fname (str): Filename of the model.
"""
joblib.dump(self.model, '%s.pkl' % model_fname)
示例5: persist
# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import dump [as 別名]
def persist(self, filepath):
joblib.dump(self.embedding_matrix, filepath)
示例6: persist
# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import dump [as 別名]
def persist(self, filepath):
object_pickle = {'char_level': self.char_level,
'maxlen': self.maxlen,
'num_words': self.num_words,
'tokenizer': self.tokenizer}
joblib.dump(object_pickle, filepath)
示例7: persist
# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import dump [as 別名]
def persist(self, filepath):
joblib.dump({}, filepath)
示例8: persist
# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import dump [as 別名]
def persist(self, filepath):
joblib.dump(self.estimator, filepath)
示例9: persist
# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import dump [as 別名]
def persist(self, filepath):
params = {'x_columns': self.x_columns,
'y_columns': self.y_columns
}
joblib.dump(params, filepath)
示例10: persist
# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import dump [as 別名]
def persist(self, filepath):
params = {'loader_params': self.loader_params}
joblib.dump(params, filepath)
示例11: save
# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import dump [as 別名]
def save(self, filepath):
params = {'loader_params': self.loader_params}
joblib.dump(params, filepath)
示例12: script_run
# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import dump [as 別名]
def script_run():
# 產生keyword
kw_list = build_key_word("train.txt")
# 保存數據
fp = open("new_word.txt", encoding="utf-8", mode="w")
for word in kw_list:
fp.write(word + "\n")
fp.close()
# kw_list = load_key_words("word.txt")
feature, label = get_feature("train.txt", kw_list)
gnb = MultinomialNB() # 多項式貝葉斯
gnb = gnb.fit(feature, label)
joblib.dump(gnb, 'model/gnb.model')
print("訓練完成")
示例13: tofile
# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import dump [as 別名]
def tofile(file_name, model):
joblib.dump(model, file_name)
示例14: save_model
# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import dump [as 別名]
def save_model(self, path):
assert self.n_ensemble == len(self.model)
for i in range(self.n_ensemble):
joblib.dump(self.model[i], path + str(i) + '.pkl')
if self.feature_type == 'descriptors':
np.save(path + 'desc_mean.npy', self.desc_mean)
示例15: make_example_classifier
# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import dump [as 別名]
def make_example_classifier(filename):
# Create a dummy RF model for train/classify testing
rf = RandomForestClassifier()
p, n_class = 42, 2
n = n_class * 5
X = np.random.rand(n, p)
y = np.repeat(range(n_class), n / n_class)
rf.fit(X, y)
jl.dump(rf, filename)
# EXAMPLE DATASETS