Skip to content

[ENH] Pythagorean tree and Pythagorean forest widgets#1441

Merged
astaric merged 12 commits intobiolab:masterfrom
pavlin-policar:pythagorean-tree
Jul 19, 2016
Merged

[ENH] Pythagorean tree and Pythagorean forest widgets#1441
astaric merged 12 commits intobiolab:masterfrom
pavlin-policar:pythagorean-tree

Conversation

@pavlin-policar
Copy link
Copy Markdown
Collaborator

@pavlin-policar pavlin-policar commented Jul 11, 2016

Pythagorean tree widget for visualising trees. Pythagorean forest widget for visualising random forests.

Both work with the Tree and RandomForest interfaces introduced recently in 2230b7c.

Commit history available in prototypes.

The util files I have for graphic views and components should probably be moved to a better named folder (widgetutils isn't the best, but utils was taken and my utils and the existing ones don't really fit into the same context).

@codecov-io
Copy link
Copy Markdown

codecov-io commented Jul 11, 2016

Current coverage is 88.17%

Merging #1441 into master will increase coverage by 0.07%

@@             master      #1441   diff @@
==========================================
  Files            77         77          
  Lines          7591       7613    +22   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           6688       6713    +25   
+ Misses          903        900     -3   
  Partials          0          0          

Sunburst

Powered by Codecov. Last updated by 65e0e80...596a452

if self.SIZE_CALCULATION[self.size_calc_idx][0] == 'Logarithmic':
self.log_scale_box.parent().setEnabled(True)
else:
self.log_scale_box.parent().setEnabled(False)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.log_scale_box.parent().setEnabled(
    self.SIZE_CALCULATION[self.size_calc_idx][0] == 'Logarithmic')

@kernc
Copy link
Copy Markdown
Contributor

kernc commented Jul 11, 2016

Please enable tests in Orange/widgets/visualize/widgetutils/tree/tests.

@kernc
Copy link
Copy Markdown
Contributor

kernc commented Jul 11, 2016

Please do what you find reasonable to make pylint more happy.

padding = list(repeat(padding, 4))
elif isinstance(padding, list) or isinstance(padding, tuple):
if len(padding) == 2:
padding = (*padding, *padding)
Copy link
Copy Markdown
Contributor

@kernc kernc Jul 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is (unfortunately) not Python 3.4 syntax. Accommodating people using LTS software (including myself), we should keep this Python 3.4-compatible. Easily enough:

padding = tuple(padding * 2)

@pavlin-policar
Copy link
Copy Markdown
Collaborator Author

How would I go about enabling tests? Does this mean I move them to the Orange/tests directory, or do I have to somehow indicate that the tests should be included?

@kernc
Copy link
Copy Markdown
Contributor

kernc commented Jul 12, 2016

How would I go about enabling tests?

Nevermind. Your tests are running on Travis. 😊

x > 30
>>> rule = ContinuousRule('age', True, 30)
>>> ContinuousRule('age', True, 30)
age > 30.000
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to have mislead you, this is not ok. __repr__() should return a Python expression from which the object can be recreated. So best use separate repr and str implementations.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see if the __repr__ implementation is now all right. I've also changed the docstrings to use print() since I find this conveys the meaning of the statement

Rule ∈ [1.000, 3.000)

much clearer than this

IntervalRule(attr_name='Rule', left_rule=ContinuousRule(attr_name='Rule', greater=True, value=1, inclusive=True), right_rule=ContinuousRule(attr_name='Rule', greater=False, value=3, inclusive=False))

If this is not ok, I can fix it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me. 👍

return ContinuousRule(self.attr_name, self.greater, larger)
# When both are LT
else:
smaller = self.value if self.value < rule.value else rule.value
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

min(self.value, rule.value) ?

@astaric astaric added this to the 3.3.7 milestone Jul 17, 2016
@BlazZupan
Copy link
Copy Markdown
Contributor

This is almost ready to merge. I have tested it on Mac, and everything works fine. Some minor suggestions before merging:

  • when showing regression trees, "Target class" label in GUI should change to "Node color" (make sure this is changed back to Target class when the widget gets classification tree on the input). This goes for both Tree and Forest widgets
  • rename widget name display in the canvas from Pythagorean forest to Pythagorean Forest (widget names use camel case)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants