本文整理匯總了Python中tgrocery.Grocery.get_load_status方法的典型用法代碼示例。如果您正苦於以下問題:Python Grocery.get_load_status方法的具體用法?Python Grocery.get_load_status怎麽用?Python Grocery.get_load_status使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tgrocery.Grocery
的用法示例。
在下文中一共展示了Grocery.get_load_status方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_main
# 需要導入模塊: from tgrocery import Grocery [as 別名]
# 或者: from tgrocery.Grocery import get_load_status [as 別名]
def test_main(self):
grocery = Grocery(self.grocery_name)
grocery.train(self.train_src)
grocery.save()
new_grocery = Grocery('test')
new_grocery.load()
assert grocery.get_load_status()
assert grocery.predict('考生必讀:新托福寫作考試評分標準') == 'education'
# cleanup
if self.grocery_name and os.path.exists(self.grocery_name):
shutil.rmtree(self.grocery_name)
示例2: sentiment_train
# 需要導入模塊: from tgrocery import Grocery [as 別名]
# 或者: from tgrocery.Grocery import get_load_status [as 別名]
def sentiment_train(gro_name, train_set):
"""
:param gro_name:
:param train_set:
:return:
"""
gro_ins = Grocery(gro_name)
# gro_ins.load()
gro_ins.train(train_set)
print("Is trained? ", gro_ins.get_load_status())
gro_ins.save()
示例3: DataFrame
# 需要導入模塊: from tgrocery import Grocery [as 別名]
# 或者: from tgrocery.Grocery import get_load_status [as 別名]
tdic['id'].append(_id)
tdic['type'].append(_type)
tdic['contents'].append(contents)
i +=1
#train = pd.read_csv( train_file, header = 0, delimiter = "\t", quoting = 3 )
#test = pd.read_csv( test_file, header = 1, delimiter = "\t", quoting = 3 )
train = DataFrame(dic)
test = DataFrame(tdic)
#
#classfynews_instance 是模型保存路徑
grocery = Grocery('classfynews_instance')
train_in = [train['contents'],train['type']]
grocery.train(train_in)
print grocery.get_load_status()
#grocery.save()
copy_grocery = Grocery('classfynews_instance')
copy_grocery.load()
#copy_grocery = grocery
test_in = [test['contents'],test['type']]
#輸入類似 ['我是中國人','台北*****']
#輸出 [11,12]
test_result = copy_grocery.predict(test['contents'])
print test_result.predicted_y
#test_result = copy_grocery.test(test_in)
#print test_result.show_result()
示例4: __init__
# 需要導入模塊: from tgrocery import Grocery [as 別名]
# 或者: from tgrocery.Grocery import get_load_status [as 別名]
class Cat:
def __init__(self):
self.grocery = Grocery('autohome')
def test(self):
print self.grocery.get_load_status()
示例5: Grocery
# 需要導入模塊: from tgrocery import Grocery [as 別名]
# 或者: from tgrocery.Grocery import get_load_status [as 別名]
# coding: utf-8
from tgrocery import Grocery
grocery = Grocery('test')
train_src = [
('education', '名師指導托福語法技巧:名詞的複數形式'),
('education', '中國高考成績海外認可 是“狼來了”嗎?'),
('sports', '圖文:法網孟菲爾斯苦戰進16強 孟菲爾斯怒吼'),
('sports', '四川丹棱舉行全國長距登山挑戰賽 近萬人參與')
]
grocery.train(train_src)
print(grocery.get_load_status())
predict_result = grocery.predict('考生必讀:新托福寫作考試評分標準')
print(predict_result)
print(predict_result.dec_values)
grocery = Grocery('read_text')
train_src = '../text_src/train_ch.txt'
grocery.train(train_src)
print(grocery.get_load_status())
predict_result = grocery.predict('考生必讀:新托福寫作考試評分標準')
print(predict_result)
print(predict_result.dec_values)
示例6: Grocery
# 需要導入模塊: from tgrocery import Grocery [as 別名]
# 或者: from tgrocery.Grocery import get_load_status [as 別名]
# coding: utf-8
from tgrocery import Grocery
# pass a tokenizer, must be a python func
custom_grocery = Grocery('custom', custom_tokenize=list)
train_src = [
('education', '名師指導托福語法技巧:名詞的複數形式'),
('education', '中國高考成績海外認可 是“狼來了”嗎?'),
('sports', '圖文:法網孟菲爾斯苦戰進16強 孟菲爾斯怒吼'),
('sports', '四川丹棱舉行全國長距登山挑戰賽 近萬人參與')
]
custom_grocery.train(train_src)
print custom_grocery.get_load_status()
print custom_grocery.predict('考生必讀:新托福寫作考試評分標準')