Commit dd7fed36 authored by Alessandro dos Santos Ferreira's avatar Alessandro dos Santos Ferreira
Browse files

Pynovisao - Experimenter All

parent 94859823
......@@ -56,6 +56,9 @@ class Classifier(object):
def cross_validate(self, detail = True):
pass
def experimenter(self):
pass
@abstractmethod
def reset(self):
......
......@@ -181,3 +181,7 @@ class WekaAlias(object):
raise IException('Invalid classifier')
@staticmethod
def get_aliases():
return _weka_alias
......@@ -142,6 +142,34 @@ class WekaClassifiers(Classifier):
return info
def experimenter(self):
info = ""
aliases = sorted(WekaAlias.get_aliases())
for alias in aliases:
try:
if alias == "MultilayerPerceptron":
continue
start_time = TimeUtils.get_time()
classifier = WClassifier(classname=WekaAlias.get_classifier(alias))
info += "Scheme:\t%s %s\n" % (str(classifier.classname) , " ".join([str(option) for option in classifier.options]))
evl = WEvaluation(self.data)
evl.crossvalidate_model(classifier, self.data, 10, WRandom(1))
info += "Correctly Classified Instances: %0.4f%%\n" % (evl.percent_correct)
info += "Time taken to build model: %0.5f seconds\n\n" % (TimeUtils.get_time() - start_time)
except Exception as e:
if str(e) != 'Object does not implement or subclass weka.classifiers.Classifier: __builtin__.NoneType':
info += "Exception in %s: %s\n\n" % (WekaAlias.get_aliases()[alias], str(e))
return info
def reset(self):
self.data = None
self.classifier = None
......@@ -199,6 +199,10 @@ class TkInterface(Interface):
def show_warning(self, fmt, *args):
tkMessageBox.showwarning("Warning", fmt % args)
def ask_ok_cancel(self, title, question):
return tkMessageBox.askokcancel(title, question)
def show(self):
......
......@@ -67,6 +67,7 @@ if __name__ == "__main__":
tk.add_command("Configure", act.configure_classifier)
tk.add_separator()
tk.add_command("Cross Validation", act.cross_validation, 'X')
tk.add_command("Experimenter All", act.experimenter_all, 'p')
tk.add_separator()
tk.add_command("Execute", act.run_classifier, 'C')
......
......@@ -431,6 +431,24 @@ class Act(object):
popup_info = self.classifier.cross_validate()
self.tk.append_log("Cross Validation finished")
self.tk.popup(popup_info)
def experimenter_all(self):
if self.classifier is None:
raise IException("You must install python-weka-wrapper")
if self.tk.ask_ok_cancel("Experimenter All", "This may take several minutes to complete. Are you sure?"):
if self.classifier.must_train():
self.tk.write_log("Creating training data...")
fextractor = FeatureExtractor(self.extractors)
output_file, run_time = fextractor.extract_all(self.dataset, "training", overwrite = False)
self.classifier.train(self.dataset, "training")
self.tk.write_log("Running Experimenter All on %s...", self.classifier.get_name())
popup_info = self.classifier.experimenter()
self.tk.append_log("\nExperimenter All finished")
self.tk.popup(popup_info)
def func_not_available(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment