Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Pythagorean tree and Pythagorean forest widgets #1441

Merged
merged 12 commits into from
Jul 19, 2016

Conversation

pavlin-policar
Copy link
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

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
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
Contributor

kernc commented Jul 11, 2016

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

@kernc
Copy link
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
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
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
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
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
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
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
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
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)


MAX_OPACITY = 1.
SELECTION_OPACITY = .5
HOVER_OPACITY = .1
Copy link
Contributor

@kernc kernc Jul 19, 2016

Choose a reason for hiding this comment

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

I think this value might be too small. When one branch is hovered, the other branches are almost invisible here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I made it that way because for larger trees, where there is a lot of overlap (e.g. adult with sqrt sizing) the almost invisible-ness of other branches makes the branch you are hovering over very clear. If I change the hover opacity to anything larger (e.g. 0.2), it becomes less clear which branch is being highlighted.

If you feel this is unnecessary and having a higher opacity would be better I can change this.

0.1 opacity vs 0.2 opacity

Copy link
Contributor

Choose a reason for hiding this comment

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

I see (thanks). In that case, it's ok.

@astaric astaric merged commit e7e4ccf into biolab:master Jul 19, 2016
@pavlin-policar pavlin-policar deleted the pythagorean-tree branch November 24, 2016 13:41
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