HN user

benfrederickson

1,767 karma
Posts22
Comments41
View on HN
jacobtomlinson.dev 3y ago

Narrative Driven Development

benfrederickson
3pts0
eugeneyan.com 3y ago

Simplicity Is an Advantage but Sadly Complexity Sells Better

benfrederickson
58pts6
danluu.com 4y ago

Individuals Matter

benfrederickson
774pts398
github.com 4y ago

Show HN: Transformers4Rec -a new library for Transformers on Recommender Systems

benfrederickson
5pts0
www.benfrederickson.com 6y ago

Profiling Native Python Extensions

benfrederickson
3pts0
github.com 7y ago

Show HN: Py-spy – A new sampling profiler for Python programs

benfrederickson
286pts43
www.benfrederickson.com 8y ago

Writing Python Extensions in Rust Using PyO3

benfrederickson
2pts0
erikbern.com 8y ago

Missing the point about microservices

benfrederickson
3pts0
www.benfrederickson.com 8y ago

Where Do the World's Software Developers Live?

benfrederickson
2pts0
www.benfrederickson.com 8y ago

Why GitHub Won't Help with Hiring

benfrederickson
105pts103
benfrederickson.com 8y ago

Approximate Nearest Neighbours for Recommender Systems

benfrederickson
1pts0
www.benfrederickson.com 9y ago

An Interactive Tutorial on Numerical Optimization

benfrederickson
6pts0
www.benfrederickson.com 11y ago

Unicode is Kind of Insane

benfrederickson
32pts6
karpathy.github.io 11y ago

The Unreasonable Effectiveness of Recurrent Neural Networks

benfrederickson
913pts207
www.benfrederickson.com 11y ago

Building a ‘People Who Like This Also Like’ Feature

benfrederickson
108pts17
www.benfrederickson.com 11y ago

People Who Like This Also Like

benfrederickson
13pts1
www.benfrederickson.com 12y ago

Don't Pickle Your Data

benfrederickson
36pts22
www.benfrederickson.com 12y ago

Visualizing min-heap algorithms with D3.js

benfrederickson
3pts0
www.benfrederickson.com 13y ago

Why you can't dislike something on Facebook

benfrederickson
49pts43
www.benfrederickson.com 13y ago

Data Visualization using Multidimensional Scaling

benfrederickson
1pts0
www.benfrederickson.com 13y ago

Creating Venn Diagrams with D3.js

benfrederickson
4pts0
www.cnn.com 13y ago

CNN Exclusive: McAfee comes out of hiding to talk about life on the run

benfrederickson
2pts0

While there are some implementation differences (py-spy is written in rust, profiling.sampling is a mix of python and C etc), the end result seems pretty similar to me.

One thing to note is that there are some differences in blocking behaviour of the target process. Py-spy blocks by default and profiling.sampling doesn't. I wrote a bit about why py-spy blocks by default here https://www.benfrederickson.com/why-python-needs-paused-duri... - the first version of py-spy also didn't block and since we got incredibly misleading results at times this was one of the first changes I made to py-spy

you can either race with the program and hope that you read its memory to get the function stack before it changes what function it's running (and you're likely to win the race, because C is faster than Python), or you can pause the program briefly while taking a sample.

Py-spy defaults to blocking because the results can be pretty wrong otherwise: https://github.com/benfred/py-spy/issues/56 . You can see this problem profiling a program like https://github.com/benfred/py-spy/blob/master/tests/scripts/... with or without the nonblocking flag in py-spy - the nonblocking version produces garbage output.

Somewhat interestingly, this problem doesn't seem to occur with Ruby - and rbspy can get away without pausing the target program with only minor errors seen when profiling a similar function. I suspect this is because of differences between how the Ruby and Python interpreters store call stack information, but haven't had a chance to dig into the specifics.

Interesting article. While I definitely think you should be profiling your code to figure out the hot spots, cProfile has some limitations for profiling: cProfile doesn't give you line numbers, doesn’t work with threads, and significantly slows your program down.

I wrote a tool py-spy (https://github.com/benfred/py-spy) that is worth checking out if you’re interesting in profiling python programs. Not only does it solve those problems with cProfile - py-spy also lets you generate a flamegraph, profile running programs in production, works with multiprocess python applications, can profile native python extensions etc.

Author here. It's worth noting that since I wrote this post, py-spy has gained the ability to profile multiprocess python applications - and can also now show local variables in the dump command.

There is a pretty good breakdown of a bunch of different options for visualizing sets here: http://www.cvast.tuwien.ac.at/SetViz

Venn/Euler diagrams don't work all that well past 3 sets, not all areas will be shown if using circles - so unless some of the sets are disjoint it will be a misleading diagram (like in the music example). However, I think it works well for 3 set diagams, I have an interactive example on last.fm data here https://www.benfrederickson.com/distance-metrics/ in the context of explaining some simple distance metrics.

Alias tables are pretty cool, I wrote an interactive visualization of how they get built as part of this post a while ago: http://engineering.flipboard.com/2017/02/storyclustering . We used alias tables with MCMC and the hastings metropolis test to build a super fast LDA.

Also worth reading up on are sum-heaps. Alias tables are O(1) to sample from but O(n) to build/modify. Sum-heaps let you modify in O(log(n)) at the cost of sampling in O(log(n)) as well. A good writeup is here: https://timvieira.github.io/blog/post/2016/11/21/heaps-for-i...

I just saw your question on proggit, and I lazily cut-and-paste the answer for here =):

For your first question - yes this means few people use more than one language in a month. There is also a power law distribution happening with user activity each month, so most users only have a handful of events each month (which happen to be mostly in a single language). I'm trying to measure how broad support it so this was mostly done on purpose. I was finding counting total events was getting biased by things that I most have been automatic activity (I was seeing single accounts with 10K commits a day for instance).

Percent of MAU in the charts is the total percentage of unique users who were active that month. I haven't tried out with yearly active users =(

For the venn code, I wrote up the approach here : http://www.benfrederickson.com/better-venn-diagrams/

Basically though, I'm using the non-linear CG method - so it doesn't require a positive definite matrix. The loss function is a little funky with handling the disjoint set/ subset relationships in the euler diagrams appropriately (defines the loss/gradient to be 0 if these constraints are satisfied), but this approach still works pretty well.

That venn diagram post has a couple interactive demos of how this works, and also a randomized test showing overall performance.

I actually believe its the best known algorithm for laying out area proportional venn diagrams. I benchmarked against the code from the venneuler paper here: http://benfred.github.io/venn.js/tests/venneuler_comparison/

Author here! This post is really just me messing around with Javascript, and trying to make some pretty graphs with D3. All the code is up on my github account, http://github.com/benfred/fmin if you want to check it out.

While these algorithms aren't maybe the most useful thing to have in JS, I am using both the nelder-mead and CG code to calculate area proportional venn diagrams in my venn.js project (which is why I originally wrote all this code in the first place).

Once I figured out the solution, I was kicking myself for not figuring it our earlier =)

I think I went wrong in 2 ways. My first attempt was to solve using calculus, and though I came up with a solution for the 2 circle case - I totally failed at finding the integral for 3+ circles.

My bigger mistake was to google for papers after I failed initially. I looked for other peoples venn diagram solutions, and found that they were using approximation techniques to calculate. Since the people writing these papers have a much better math pedigree than I do, it made me think I should use an approximation too.

While I did waste a bit of extra time on this, most of the time was spent in writing javascript code. Since the whole point of the venn diagram library in the first place was to learn javascript, I can’t really say it was a total waste. Also I used the quad tree estimate to verify the exact solution.

Author here. I wrote this post a while back, but never submitted to HN. Its one of those posts that I wasn't sure if it would really resonate with anyone (like my most recent one on venn diagram layout algorithms).

Anyways, If you have any questions ask away =).

Its amazing and insane =). I was trying to highlight the complexities behind something that many people people naively think is simple - I probably should have made the clearer based on the reaction elsewhere though