-
-
Notifications
You must be signed in to change notification settings - Fork 993
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c82cf0
commit 4dd1176
Showing
4 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
""" | ||
Widgets for the Classify category. | ||
""" | ||
|
||
|
||
NAME = "Classify" | ||
|
||
DESCRIPTION = "Classification algorithms." | ||
|
||
BACKGROUND = "#FAC1D9" | ||
|
||
ICON = "icons/Category-Classify.svg" | ||
|
||
PRIORITY = 3 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
""" | ||
Naive Bayes Learner | ||
""" | ||
|
||
import Orange.data | ||
import Orange.classification.naive_bayes | ||
from Orange.widgets import widget, gui, settings | ||
|
||
|
||
class OWNaiveBayes(widget.OWWidget): | ||
name = "Naive Bayes" | ||
icon = "icons/NaiveBayes.svg" | ||
inputs = [("Data", Orange.data.Table, "setData")] | ||
outputs = [ | ||
("Learner", Orange.classification.naive_bayes.BayesLearner), | ||
("Classifier", Orange.classification.naive_bayes.BayesClassifier) | ||
] | ||
|
||
want_main_area = False | ||
|
||
learner_name = settings.Setting("Naive Bayes") | ||
|
||
def __init__(self): | ||
super().__init__() | ||
|
||
# GUI | ||
gui.lineEdit(gui.widgetBox(self.controlArea, self.tr("Name")), | ||
self, "learner_name") | ||
|
||
gui.rubber(self.controlArea) | ||
|
||
gui.button(self.controlArea, self, self.tr("&Apply"), | ||
callback=self.apply) | ||
|
||
self.data = None | ||
|
||
self.initialize() | ||
|
||
def initialize(self): | ||
""" | ||
Initialize the widget's state. | ||
""" | ||
learner = Orange.classification.naive_bayes.BayesLearner() | ||
learner.name = self.learner_name | ||
self.send("Learner", learner) | ||
self.send("Classifier", None) | ||
|
||
def setData(self, data): | ||
self.data = data | ||
if data is not None: | ||
self.apply() | ||
else: | ||
self.send("Classifier", None) | ||
|
||
def apply(self): | ||
classifier = None | ||
learner = Orange.classification.naive_bayes.BayesLearner() | ||
learner.name = self.learner_name | ||
|
||
if self.data is not None: | ||
classifier = learner(self.data) | ||
classifier.name = self.learner_name | ||
|
||
self.send("Learner", learner) | ||
self.send("Classifier", classifier) |