Tag Archives: python
I’ve got a fun little viz that I need to demo for Important People (IP) in early March [editor’s note: still not done… that deadline was highly optimistic!]. How to do it?
In Python? Sure. In a Jupyter notebook? Maybe. With Matplotlib? Probably not… at least I better have a look at the state of the alternatives.
Did I mention that it is essential for this viz to be *interactive*? It needs to allow the Important People to explore the predictions of some ML model, or at least allow me to explore them while they call out how to explore.
Years ago, I attempted to designate a particular plot the “hello, world” of data viz. Remember that? I think we should extend it to a hello world of interactive data viz. Maybe just choosing the number of digits is enough. Or should it follow the visual information seeking mantra? But “hello, world” cannot be too complicated.
I have been a fan of this educational offering for a while now, and I have been mentioning that for a while now, too. But I am moved to say it again, because I’m planning a four-session Intro to Python training for aspiring Health Metrics Scientists, and the SWC curriculum is making that so easy. It could have been so hard. ❤ u SWC.
This turned out to be a bit of a downer, but it was a good learning exercise, and the general approach will be useful for generating test data on a different project. See notebook here.
Just before that year of not writing anything here, I mentioned that I have a new microsimulation platform, and it is called Vivarium. That is still true, and now it even has some documentation: https://vivarium.readthedocs.io/en/latest/
It has been the thing that kept me too busy to blog for the last year. But it did generate some aesthetically pleasing figures for test purposes, as well as some population health results of interest. More details to come.
Did you know you can change the signature of functions dynamically in Python 3? It is a bit nasty, and maybe will make things look nicer for vivarium users.
SO question that got me started: https://stackoverflow.com/a/33112180/1935494
I’ve had a new line of research developing for the last 18 months or so—*microsimulation*. It started when I stepped in to help with the “Cost Effectiveness Analysis with Microsimulation” (or CEAM) project at IHME. Now it is growing and growing to take over all of my research and recreation time. Is that bad or good?
Some of this work has now seen daylight from our presentations at SummerSim and iHEA in July, and today I am please to introduce a python package that you can use, too.
The programmers I’ve been working with on this convinced me that it is not just for cost effectiveness analysis and we need a more expansive name for it. So I present to you: vivarium. https://github.com/ihmeuw/vivarium
I had to put an icon on a chart in Python last week, and I couldn’t find a good brief blog about how to do it. Here is what I cobbled together:
1. Find a free, appropriate image from The Noun Project.
2. Load it into Python with
3. Draw it in the proper place on a figure with
plt.imshow and some cryptic, hacky options.
See this all in action here: https://gist.github.com/aflaxman/c171050384471636e8f23f322ba7e9c5
The first release of nbtutor (“Visualize Python code execution (line-by-line) in Jupyter Notebook cells.”) is available on pypi:
pip install nbtutor jupyter nbextension install --sys-prefix --overwrite --py nbtutor jupyter nbextension enable --sys-prefix --py nbtutor
Potentially of interest, although I’ve done enough d3js to think that .select .head is fine notation:
dfply Version: 0.2.4
GitHub – kieferk from November 28, 2016
“The dfply package makes it possible to do R’s dplyr-style data manipulation with pipes in python on pandas DataFrames.”
from dfply import * diamonds >> select(X.carat, X.cut) >> head(3) carat cut 0 0.23 Ideal 1 0.21 Premium 2 0.23 Good