当前位置: 首页>>代码示例>>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;未经允许,请勿转载。