当前位置: 首页>>代码示例>>Python>>正文


Python joblib.dump方法代码示例

本文整理汇总了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") 
开发者ID:5hirish,项目名称:adam_qas,代码行数:22,代码来源:question_classifier_trainer.py

示例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)


#  .___  ___.      ___       __  .__   __.
#  |   \/   |     /   \     |  | |  \ |  |
#  |  \  /  |    /  ^  \    |  | |   \|  |
#  |  |\/|  |   /  /_\  \   |  | |  . `  |
#  |  |  |  |  /  _____  \  |  | |  |\   |
#  |__|  |__| /__/     \__\ |__| |__| \__|
# 
开发者ID:neptune-ai,项目名称:open-solution-salt-identification,代码行数:22,代码来源:empty_vs_non_empty.py

示例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)) 
开发者ID:mulhod,项目名称:reviewer_experience_prediction,代码行数:19,代码来源:cv_learn.py

示例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) 
开发者ID:materialsvirtuallab,项目名称:mlearn,代码行数:10,代码来源:models.py

示例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) 
开发者ID:minerva-ml,项目名称:steppy-toolkit,代码行数:4,代码来源:embeddings.py

示例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) 
开发者ID:minerva-ml,项目名称:steppy-toolkit,代码行数:8,代码来源:loaders.py

示例7: persist

# 需要导入模块: from sklearn.externals import joblib [as 别名]
# 或者: from sklearn.externals.joblib import dump [as 别名]
def persist(self, filepath):
        joblib.dump({}, filepath) 
开发者ID:minerva-ml,项目名称:steppy-toolkit,代码行数:4,代码来源:postprocessing.py

示例8: persist

# 需要导入模块: from sklearn.externals import joblib [as 别名]
# 或者: from sklearn.externals.joblib import dump [as 别名]
def persist(self, filepath):
        joblib.dump(self.estimator, filepath) 
开发者ID:minerva-ml,项目名称:steppy-toolkit,代码行数:4,代码来源:models.py

示例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) 
开发者ID:minerva-ml,项目名称:steppy-toolkit,代码行数:7,代码来源:misc.py

示例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) 
开发者ID:minerva-ml,项目名称:steppy-toolkit,代码行数:5,代码来源:classification.py

示例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) 
开发者ID:minerva-ml,项目名称:steppy-toolkit,代码行数:5,代码来源:segmentation.py

示例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("训练完成") 
开发者ID:Zephery,项目名称:weiboanalysis,代码行数:16,代码来源:tool.py

示例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) 
开发者ID:Andres-Hernandez,项目名称:CalibrationNN,代码行数:4,代码来源:data_utils.py

示例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) 
开发者ID:Mariewelt,项目名称:OpenChem,代码行数:8,代码来源:vanilla_model.py

示例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 
开发者ID:ceholden,项目名称:yatsm,代码行数:14,代码来源:conftest.py


注:本文中的sklearn.externals.joblib.dump方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。