本文整理汇总了Python中model.Model.load_from_file方法的典型用法代码示例。如果您正苦于以下问题:Python Model.load_from_file方法的具体用法?Python Model.load_from_file怎么用?Python Model.load_from_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Model
的用法示例。
在下文中一共展示了Model.load_from_file方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import load_from_file [as 别名]
def __init__(self, config):
"""\
Initialize the object with the given configuration.
Configuration items (in a hash):
model_file: path to a lib.model.Model in a pickle to be used for
classification
"""
# TODO handle features config (now dummy, preset for English)
self.__model_file = config['model_file']
self.__model = Model.load_from_file(self.__model_file)
示例2: install_all_model
# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import load_from_file [as 别名]
def install_all_model(models, dirname, fnames):
'''Load all trained model from filename. Store the result in models. This is a call back for os.path.walk.
@param models: the resulting model list
@param dirname: current visiting directory
@param fnames: all file name int current visiting directory
@see controler.__init__
'''
if dirname == '.':
return
for fname in fnames:
path = os.path.join(dirname, fname)
if '.' in os.path.basename(path):
continue
if os.path.isfile(path):
name = os.path.basename(path)
print "Loading model {} ...".format(name)
model = Model.load_from_file(path)
models[name] = model
示例3: __init__
# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import load_from_file [as 别名]
def __init__(self, config):
"""\
Initialize the object with the given configuration.
Configuration items (in a hash):
model_file: path to a lib.model.Model in a pickle to be used for
classification
"""
# load the model
self.model_file = config['model_file']
self.model = Model.load_from_file(self.model_file)
# setup input features
self.features = config.get('features', 'Lemma|Tag_POS').split('|')
self.numeric_features = set()
if 'feature_types' in config:
feat_types = config['feature_types'].split('|')
self.numeric_features = set([feat for feat, feat_type in zip(self.features, feat_types)
if feat_type.upper() == 'NUMERIC'])
self.ctr = 0