Spaces:
Runtime error
Runtime error
none
commited on
Commit
·
77012d7
1
Parent(s):
a9ec254
Add back 3rd plot. Accept that it's broken on Firefox
Browse files
app.py
CHANGED
|
@@ -298,6 +298,10 @@ The numbers and letters in brackets like `[3.L]` refer to the parent node's posi
|
|
| 298 |
The trees are a lot deeper than what it shows in the small plot.
|
| 299 |
Hugging Face makes the plot ENORMOUS if you expand it, so that isn't much help.
|
| 300 |
Pick your poison.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 301 |
""")
|
| 302 |
|
| 303 |
|
|
@@ -406,15 +410,12 @@ Later on,
|
|
| 406 |
got me out of a jam.
|
| 407 |
This `empet` character is pretty much the only one who answers Python posts on Plotly's forums.
|
| 408 |
As far as I can tell, that's because they're the only person in the world who understands Plotly's Python library.
|
| 409 |
-
|
| 410 |
-
I'm glad it was challenging, though.
|
| 411 |
-
I did go into this hoping for something more interesting than a donut plot.
|
| 412 |
-
Maybe I'll think on the `value` and `gain` fields a bit and come up with a version 2.
|
| 413 |
""")
|
| 414 |
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
|
|
|
| 418 |
|
| 419 |
# This works the way I want
|
| 420 |
# but the plot is tiny
|
|
@@ -430,20 +431,23 @@ Maybe I'll think on the `value` and `gain` fields a bit and come up with a versi
|
|
| 430 |
# so it won't let me cache that function
|
| 431 |
# I could pack the dataframe bytes to smuggle them past that check
|
| 432 |
# but whatever
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
|
|
|
|
|
|
|
|
|
| 447 |
|
| 448 |
# This is still super slow even if it's only showing the dataframes
|
| 449 |
# I'm just going to leave it out entirely
|
|
@@ -459,16 +463,19 @@ Maybe I'll think on the `value` and `gain` fields a bit and come up with a versi
|
|
| 459 |
|
| 460 |
# Cutting this out fixed the broken animation on Hugging Face
|
| 461 |
# So that issue was perf-based
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
|
|
|
|
|
|
|
|
|
| 472 |
|
| 473 |
|
| 474 |
if __name__=='__main__':
|
|
|
|
| 298 |
The trees are a lot deeper than what it shows in the small plot.
|
| 299 |
Hugging Face makes the plot ENORMOUS if you expand it, so that isn't much help.
|
| 300 |
Pick your poison.
|
| 301 |
+
|
| 302 |
+
Also, it seems to break on Firefox.
|
| 303 |
+
It works locally on Firefox, but it breaks when I look at it on Hugging Face on Firefox.
|
| 304 |
+
🤷
|
| 305 |
""")
|
| 306 |
|
| 307 |
|
|
|
|
| 410 |
got me out of a jam.
|
| 411 |
This `empet` character is pretty much the only one who answers Python posts on Plotly's forums.
|
| 412 |
As far as I can tell, that's because they're the only person in the world who understands Plotly's Python library.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 413 |
""")
|
| 414 |
|
| 415 |
+
st.markdown('## Check out the data!')
|
| 416 |
+
st.markdown("""
|
| 417 |
+
This plot is similar to the plot above, but the slider here coordinates with a table of the data I extracted to plot each tree.
|
| 418 |
+
""")
|
| 419 |
|
| 420 |
# This works the way I want
|
| 421 |
# but the plot is tiny
|
|
|
|
| 431 |
# so it won't let me cache that function
|
| 432 |
# I could pack the dataframe bytes to smuggle them past that check
|
| 433 |
# but whatever
|
| 434 |
+
idx = st.slider(
|
| 435 |
+
label='Which tree do you want to see?',
|
| 436 |
+
min_value=0,
|
| 437 |
+
max_value=len(figures)-1,
|
| 438 |
+
value=0,
|
| 439 |
+
step=1
|
| 440 |
+
)
|
| 441 |
+
st.markdown(f'### Tree {idx}')
|
| 442 |
+
st.plotly_chart(figures[idx])
|
| 443 |
+
st.dataframe(trees[idx])
|
| 444 |
+
st.markdown("""
|
| 445 |
+
This section is mostly just to warn you against making the same foolhardy decision to marry the innermost guts of SciKit-Learn to the sparsely documented world of Plotly animations in Python.
|
| 446 |
+
|
| 447 |
+
I'm glad it was challenging, though.
|
| 448 |
+
I did go into this hoping for something more interesting than a donut plot.
|
| 449 |
+
Maybe I'll think on the `value` and `gain` fields a bit and come up with a version 2.
|
| 450 |
+
""")
|
| 451 |
|
| 452 |
# This is still super slow even if it's only showing the dataframes
|
| 453 |
# I'm just going to leave it out entirely
|
|
|
|
| 463 |
|
| 464 |
# Cutting this out fixed the broken animation on Hugging Face
|
| 465 |
# So that issue was perf-based
|
| 466 |
+
#
|
| 467 |
+
# The issue is back. My theory now is that it's just a Firefox problem.
|
| 468 |
+
# works fine on Chromium
|
| 469 |
+
#st.markdown('#### (secret third plot)')
|
| 470 |
+
#st.markdown("""
|
| 471 |
+
#I orginally had a third viz here where you could move a slider to see the data I used to make each plot.
|
| 472 |
+
#That viz recalulated every value in the entire app each time the slider moved.
|
| 473 |
+
#I had to remove it to get enough perf for the animation to play correctly.
|
| 474 |
+
#If you're feeling brave, you can follow the Quickstart in the README to run this app yourself.
|
| 475 |
+
#Then you can uncomment that viz to satisfy your curiosity.
|
| 476 |
+
#There's definitely some way to fix it.
|
| 477 |
+
#Maybe another milestone for v2.
|
| 478 |
+
#""")
|
| 479 |
|
| 480 |
|
| 481 |
if __name__=='__main__':
|