當前位置: 首頁>>代碼示例>>Python>>正文


Python joblib.load方法代碼示例

本文整理匯總了Python中sklearn.externals.joblib.load方法的典型用法代碼示例。如果您正苦於以下問題:Python joblib.load方法的具體用法?Python joblib.load怎麽用?Python joblib.load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sklearn.externals.joblib的用法示例。


在下文中一共展示了joblib.load方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_mood

# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import load [as 別名]
def get_mood(sentence, key_word, model_name):
    feature = _get_feature(sentence, key_word)
    gnb = joblib.load(model_name)
    pre_y = gnb.predict([feature])
    result = {
        "positive": 0,
        "negative": 0,
        "neutral": 0
    }
    try:
        if pre_y[0] == POSITIVE:
            result["positive"] = 1
        elif pre_y[0] == NEGATIVE:
            result["negative"] = 1
        elif pre_y[0] == NEUTRAL:
            result["neutral"] = 1
    except:
        pass
    return result 
開發者ID:Zephery,項目名稱:weiboanalysis,代碼行數:21,代碼來源:mood.py

示例2: try_resume

# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import load [as 別名]
def try_resume(filename):
    """ Return True/False if dataset has already been classified

    Args:
        filename (str): filename of the result to be checked

    Returns:
        bool: If the `npz` file exists and contains a file 'class', this test
            will return True, else False.

    """
    try:
        z = np.load(filename)
    except:
        return False

    if not z['record'].dtype or 'class' not in z['record'].dtype.names:
        return False

    return True 
開發者ID:ceholden,項目名稱:yatsm,代碼行數:22,代碼來源:classify.py

示例3: load_model

# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import load [as 別名]
def load_model(net_func, device, output_path, start_epoch):
    if start_epoch == 0:
        list_of_models = [net_func().to(device) for _ in range(bundle_size)]
        models = MyNet.NetList(list_of_models)
        fn = '%s/epoch%02d_bundled_models%02d.dat' % (output_path, 0, 0)
        models.load_state_dict(torch.load(fn))
        model = models.models[0]
        optimizer = torch.optim.SGD(model.parameters(), lr=lr, momentum=momentum)
    else:
        fn = '%s/epoch%02d_final_model.dat' % (output_path, start_epoch-1)
        model = net_func().to(device)
        model.load_state_dict(torch.load(fn))
        fn = '%s/epoch%02d_final_optimizer.dat' % (output_path, start_epoch-1)
        optimizer = torch.optim.SGD(model.parameters(), lr=lr, momentum=momentum)
        optimizer.load_state_dict(torch.load(fn))
    return model, optimizer 
開發者ID:sato9hara,項目名稱:sgd-influence,代碼行數:18,代碼來源:eval.py

示例4: get_mood

# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import load [as 別名]
def get_mood(sentence, key_word, model_name):
    feature = _get_feature(sentence, key_word)
    gnb = joblib.load(model_name)
    pre_y = gnb.predict([feature])
    result = {
        "positive":0,
        "negative":0,
        "neutral":0
    }
    try:
        if pre_y[0] == POSITIVE:
            result["positive"] = 1
        elif pre_y[0] == NEGATIVE:
            result["negative"] = 1
        elif pre_y[0] == NEUTRAL:
            result["neutral"] = 1
    except:
        pass
    return result 
開發者ID:MashiMaroLjc,項目名稱:dudulu,代碼行數:21,代碼來源:mood.py

示例5: load

# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import load [as 別名]
def load(self):
        """
        Loads the SVM model from the disk.

        Returns
        -------
        ret: bool
            Indication on if the loading was succeeded or not.
        """

        try:
            clf = joblib.load(self._modelFile)
        except:
            return False

        self._clf = clf
        return True

    #--------------------------------------------- 
開發者ID:luigivieira,項目名稱:emotions,代碼行數:21,代碼來源:emotions.py

示例6: load_from_disk

# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import load [as 別名]
def load_from_disk(filename):
  """Load a dataset from file."""
  name = filename
  if os.path.splitext(name)[1] == ".gz":
    name = os.path.splitext(name)[0]
  if os.path.splitext(name)[1] == ".pkl":
    return load_pickle_from_disk(filename)
  elif os.path.splitext(name)[1] == ".joblib":
    try:
      return joblib.load(filename)
    except KeyError:
      # Try older joblib version for legacy files.
      return old_joblib.load(filename)
    except ValueError:
      return old_joblib.load(filename)
  elif os.path.splitext(name)[1] == ".csv":
    # First line of user-specified CSV *must* be header.
    df = pd.read_csv(filename, header=0)
    df = df.replace(np.nan, str(""), regex=True)
    return df
  else:
    raise ValueError("Unrecognized filetype for %s" % filename) 
開發者ID:simonfqy,項目名稱:PADME,代碼行數:24,代碼來源:save.py

示例7: load_cv_dataset_from_disk

# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import load [as 別名]
def load_cv_dataset_from_disk(save_dir, fold_num):
  assert fold_num > 1
  loaded = False
  train_data = []
  valid_data = []
  for i in range(fold_num):
    fold_dir = os.path.join(save_dir, "fold" + str(i + 1))
    train_dir = os.path.join(fold_dir, "train_dir")
    valid_dir = os.path.join(fold_dir, "valid_dir")
    if not os.path.exists(train_dir) or not os.path.exists(valid_dir):
      return False, None, list()
    train = dcCustom.data.DiskDataset(train_dir)
    valid = dcCustom.data.DiskDataset(valid_dir)
    train_data.append(train)
    valid_data.append(valid)
  
  loaded = True  
  with open(os.path.join(save_dir, "transformers.pkl"), 'rb') as f:
    transformers = pickle.load(f)
    return loaded, list(zip(train_data, valid_data)), transformers 
開發者ID:simonfqy,項目名稱:PADME,代碼行數:22,代碼來源:save.py

示例8: __init__

# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import load [as 別名]
def __init__(self, acc_model, don_model, features_path=None):
        self.don_model = joblib.load(don_model)
        self.acc_model = joblib.load(acc_model)
        if features_path is None:
            features_path = os.path.join(this_dir, "../features.json")
        self.features_metadata = read_json(features_path)
        # acceptor and donor site indexes are unified across SOI
        # NB! This indexes are pos=1 of the region, and index-1 is already pos=-1, not 0!
        self.don_i = 3
        self.acc_i = -21
        self.labranchor = kipoi.get_model("labranchor", with_dataloader=False)
        # add current dir to python path for multiprocessing
        sys.path.append(this_dir) 
開發者ID:kipoi,項目名稱:models,代碼行數:15,代碼來源:model.py

示例9: __init__

# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import load [as 別名]
def __init__(self, acc_model, don_model, features_path=None):
        self.don_model = joblib.load(don_model)
        self.acc_model = joblib.load(acc_model)
        if features_path is None:
            features_path = os.path.join(this_dir, "../features.json")
        self.features_metadata = read_json(features_path)
        # acceptor and donor site indexes are unified across SOI
        # NB! This indexes are pos=1 of the region, and index-1 is already pos=-1, not 0!
        self.don_i = 3
        self.acc_i = -21
        # add current dir to python path for multiprocessing
        sys.path.append(this_dir) 
開發者ID:kipoi,項目名稱:models,代碼行數:14,代碼來源:model.py

示例10: load

# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import load [as 別名]
def load(self, model_fname):
        """
        Load the model from the file.

        Args:
            model_fname (str): Filename of the model.
        """
        self.model = joblib.load(model_fname) 
開發者ID:materialsvirtuallab,項目名稱:mlearn,代碼行數:10,代碼來源:models.py

示例11: load

# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import load [as 別名]
def load(self, filepath):
        self.embedding_matrix = joblib.load(filepath)
        return self 
開發者ID:minerva-ml,項目名稱:steppy-toolkit,代碼行數:5,代碼來源:embeddings.py

示例12: load

# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import load [as 別名]
def load(self, filepath):
        object_pickle = joblib.load(filepath)
        self.char_level = object_pickle['char_level']
        self.maxlen = object_pickle['maxlen']
        self.num_words = object_pickle['num_words']
        self.tokenizer = object_pickle['tokenizer']
        return self 
開發者ID:minerva-ml,項目名稱:steppy-toolkit,代碼行數:9,代碼來源:loaders.py

示例13: load

# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import load [as 別名]
def load(self, filepath):
        return ClassPredictor() 
開發者ID:minerva-ml,項目名稱:steppy-toolkit,代碼行數:4,代碼來源:postprocessing.py

示例14: load

# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import load [as 別名]
def load(self, filepath):
        self.estimator = joblib.load(filepath)
        return self 
開發者ID:minerva-ml,項目名稱:steppy-toolkit,代碼行數:5,代碼來源:models.py

示例15: load

# 需要導入模塊: from sklearn.externals import joblib [as 別名]
# 或者: from sklearn.externals.joblib import load [as 別名]
def load(self, filepath):
        return self 
開發者ID:minerva-ml,項目名稱:steppy-toolkit,代碼行數:4,代碼來源:text.py


注:本文中的sklearn.externals.joblib.load方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。