本文整理汇总了Python中classifier.Classifier.new_training方法的典型用法代码示例。如果您正苦于以下问题:Python Classifier.new_training方法的具体用法?Python Classifier.new_training怎么用?Python Classifier.new_training使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类classifier.Classifier
的用法示例。
在下文中一共展示了Classifier.new_training方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fill
# 需要导入模块: from classifier import Classifier [as 别名]
# 或者: from classifier.Classifier import new_training [as 别名]
def fill(self, class_id):
"""Fills internal structer with new training samples.
Do not call directly.
:param class_id: class identification
"""
# get training samples
for i in range(len(self.sel_files)):
row = self.sel_files[0]
samples = self.all_files[row].samples
feat = mfcc(samples, 16000, winlen=0.030, appendEnergy=False, VAD=simpleVAD)
# add two symptoms from the middle
self.X.append(feat[int(len(feat) / 2 - 1)])
self.y.append(class_id)
self.X.append(feat[int(len(feat) / 2 + 1)])
self.y.append(class_id)
# clear from the list
del_iter = self.file_store.get_iter(Gtk.TreePath.new_from_indices([row]))
self.file_store.remove(del_iter)
del self.all_files[row]
# print results
if Classifier.new_training(self.X, self.y):
self.status_label.set_text("{0} vzorků, {1} tříd".format(len(self.X), len(self.class_names)))
else:
self.status_label.set_text("Klasifikátor potřebuje víc tříd")
示例2: __init__
# 需要导入模块: from classifier import Classifier [as 别名]
# 或者: from classifier.Classifier import new_training [as 别名]
def __init__(self):
self.builder = Gtk.Builder()
self.builder.add_from_file("app.glade")
self.builder.connect_signals(self)
self.window = self.builder.get_object("window")
self.file_store = self.builder.get_object("filestore")
self.file_view = self.builder.get_object("fileview")
self.status_label = self.builder.get_object("status")
self.run_indicator = self.builder.get_object("running")
self.audiofilter = self.builder.get_object("audiofilter")
self.classcombo = self.builder.get_object("classcombo")
self.aboutdialog = self.builder.get_object("aboutdialog")
self.file_dialog = Gtk.FileChooserDialog(title="Otevřít", transient_for=self.window, action=Gtk.FileChooserAction.OPEN)
self.file_dialog.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)
self.file_dialog.set_default_response(Gtk.ResponseType.OK)
self.file_dialog.set_select_multiple(True)
if os.name != 'nt':
self.audiofilter.set_name("Zvuk")
self.file_dialog.add_filter(self.audiofilter)
self.last_dir = None
# all_files tuple of Files
self.all_files = []
# sel_files: indexes to the all_files tuple
self.sel_files = []
self.X = []
self.y = []
self.class_names = {}
try:
with open('dataset.pickle', 'rb') as f:
(self.X, self.y, self.class_names) = pickle.load(f)
for name in self.class_names.items():
self.classcombo.append(str(name[0]), name[1])
ok = Classifier.new_training(self.X, self.y)
if ok:
self.status_label.set_text("{0} vzorků, {1} tříd".format(len(self.X), len(self.class_names)))
except IOError as e:
pass
self.window.show_all()