當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。