本文整理汇总了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