People on r/datascience are making fun of this image because they believe its cliche. However its only cliche because its repeated a ton. Its repeated a ton because its true. The entire value proposition of software is the efficient computation of data. Data is the fuel of all software. This is true independently of Machine Learning, âAIâ, or âBig Dataâ. Simple applications like TurboTax, are manipulating user data to generate outcomes, in that case tax returns.Â
Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
â Live Streamingâ Interactive Chatâ Private Showsâ HD Qualityâ Free Actions
Free to watch ⢠No registration required ⢠HD streaming
Dealing with duplicate places is a challenging task. If you look at standard ways of dealing with duplicates, they revolve around string similairty algorithms. Let's explore some novel ways to tackle this problem.
Not the easiest to follow but an interesting technique if you are interested in entity resolution. In a bit, Iâll probably take a stab at wrapping this up in a nice golang library. Honestly this might even work as a Postgres extension. Deduplicating user inputs like names could be extremely valuable in a CMS.
However I will say the time complexity for this is a bit ugly. n^2 time complexity on the entire name space is a bit extreme.Â
There are a number of ways to build upon this:
Matching Core words via a distance function (Jaccard, Levenshtein, etc)
Matching based on Core Vector Distance or Cosine Similarity
Avoid one hot encoding the entire vocabulary. Look into combining with something like Word2Vec
An open-source differential privacy functions fully compatible with Postgres for keeping user data private
Iâve been thinking a bunch about Differential Privacy ever since I wrote about it a few weeks ago. Inspired by the work the Timescale team has done with TimeSeries, I think having an extension with tools for privacy in Postgres could be a great first step to getting developers to utilize differential privacy.Â
Right now what I have is really only useful for binary variables in the Dimension tables of a Star schema model. However, Iâm brainstorming ideas on how to handle Fact tables. One method Iâm playing around with is creating an abstraction on top of a transaction table that is equivalent to a Bloom Filter. I read this paper on Bloom Filters and Differential Privacy and it seems its possible to offer similar guarantees to Random Response.Â
The challenge is implementing this while maintaining the following:
Just some of the stuff Iâve been working on infrastructure side at GIPHY. This process has taught me a lot about Redshift though Iâm still wary of it. Its idiosyncrasies make it frustrating to optimize. Iâm curious how Snowflake or Databricksâ new Delta platform compare. Especially since GDPR is coming and a data warehouse based on immutability may not be a feasible reality.Â
Technology allows companies to collect more data and with more detail about their users than ever before. Sometimes that data is sold to third parties, other times itâs used to improve producâŚ
I think this is going to become a larger part of the conversation around data and data science. The EU is launching new regulations in May and those will have large implications on how we store, query, and action on data. Most of the architectures Iâve worked in before are nowhere near GDPR compliant and Differential Privacy is laughably far away.Â
Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
â Live Streamingâ Interactive Chatâ Private Showsâ HD Qualityâ Free Actions
Free to watch ⢠No registration required ⢠HD streaming
How to deploy a Microservice in 5 Minutes with AWS Fargate
If you are like us at GIPHY, you have joined the hype over containers. AS far as Iâm concerned, Docker is possibly the greatest thing to happen to development in the last few years. We have containerized nearly all of our services at GIPHY and its made our lives so much easier. Developers can develop on different operating systems without worrying about compatibility. The hardest part now, is setting up all our infrastructure to be container first. Weâve been adopting Kubernetes at GIPHY. However, we did spend some time with the AWS team and they taught us some really cool alternatives. The following is how to use AWS Fargate to make deploying a breeze.Â
For this to work I assume you have the following:
An HTTP(S) service written in any language
A Dockerfile for the service in the root of the repository
Repository hosted on github
For the sake of this example, Iâm going to deploy the go-whenami microservice that I open sourced a while back. The AWS Team has created some amazing cloud formation templates that allow you to deploy this stuff without writing a line of code. Simply head over to this github repo and checkout out the README.Â
At the bottom of the page there are preconfigured launch forms for the different cloud formation scripts. Just use the one Iâve highlighted. My Timezone microservice does not have an RDS database so I will use the one without DB checked. However if your service has a DB, use that form. It will allow you to configure an RDS instance to be e spun up with your service and will pass credentials as environment variables to your Docker container. The following form choices are important, everything else can probably be left default in most cases:
Environment: picking prod makes it available in multiple regions
EC2 Pair: This is the ssh key youâll use to login to the bastion host
Health Check Path: This is the endpoint of your health check. Mine is defaulted to the root endpoint so I wonât make a change. This endpoint should return 200 when your service is fine and 500 when its facing problems so that AWS can attempt to spin up another instance and replace the unhealthy container with a healthy one.
Hosted Zone: This is usually the same as your domain name. ie âwhenami.ioâ. If you donât have a hosted zone setup in AWS Route 53, this will create it for you.
Domain: This is the subdomain you want the service to live on. I would choose something like âapi.whenami.ioâ for this. However you could make it the same as the hosted zone if you want it on the root.
Github (Repo/User/Branch/Token): These settings are how Fargate will find your code and deploy it. Just follow the links on the form if you donât have a Github token. For simplicity choose master, but if you are using Github flow it could make sense to deploy another Fargate cluster after that looks at develop. This would be your QA instance.
Anything Else: Configure to your liking. This might be CPU or max number of concurrent instances. These options really come down to the performance and cost constraints you have for your service.
Okay so once youâve done all that, just hit create, kick back, and wait for your service to spin up. Its possible you will get failures if hit soft limits on things like VPCs or Elastic IPs. So make sure you donât have extra resources running. Depending on the traffic AWS is experiencing, it will take 15 minute to an hour to spin up. Once its setup you will have the following:
Service Running on the domain you specified
Load Balancing and Elastic Scaling. Meaning when there is high volume, Fargate will spin up parallel instances of your container and split the load amonsgt them, scaling it back down when traffic decreases.
Continuous Deployment! Go to your repo, run git commit --allow-empty -m "Trigger build" to make an empty commit. Push that to master (or whatever branch you configured) and Fargate will notice the change and redeploy your service with the changes. no more manual deploys!
CloudWatch Logging & Alerting. All of your services logs are captured by CloudWatch and you can setup alerts so that if your production systems are experiencing lots of issues, you know about it.
Extra Security via a Bastion Host. As a part of this deploy, a server called a Bastion Host was deployed as well. Your main service is only visible to the load balancer and to the Bastion Host. But the bastion host is visible to the public internet. You can use the keys you setup earlier to ssh into this instance, and from that instance interact with your service. This reduces the surface area for attack and AWS provisions special resources to monitor the host in case of attack. Even better, you can always stop the instance when you arenât using it so others canât try to penetrate and you donât have to pay.
Overall when it comes to devops I still look like the above. But using the tools that the AWS team has created, I was able to deploy an entire service with production level monitoring, alerting, and scaling, without having to write a single line of code. Whatâs even better, is that Fargate will have support for EKR (Elastic Kubernetes Service) which is AWSâ managed Kubernetes product coming out this year. So setting your infrastructure up this way is future proof against a later move to K8s.
go-whenami - Go Rest Microservice for Finding Timezone of a Coordinate
So my team has been working on a project to identify viral search behavior in semi real time. One initial problem we faced, was that search behavior in England should be different than behavior in Japan. We use a combination of language, country and timezone to localize behavior so that we can identify local trends. However, we realized that timezone was not a piece of data that we had in our logs. We did however have location data passed to us via our CDN from our API Partners.
The way we actually solved the problem was by modifying both pythonâs tzgeo and an equivalent Scala package so that we could use them in a distributed manor via Spark. There was nothing out of the box that worked and there were a lot of services offering to do it for a fee per API call. I realized working on this that this is a fairly simple problem. Paying for it just doesnât make sense.
At the end of the day, all that happens at runtime is a query against geospatial data to see if the coordinate is within a given timezone (represented as a polygon). There are only 24 timezones, so this is actually quite trivial to accomplish. Rather than running a full hosted geospatial database, we can leverage Spatialite. Spatialite is an open source, geospatial extension for SQLite. Its essentially what PostGIS is to Postgres but for SQLite. Spatialite, like SQLite, is a file based embedded DB. This is a perfect use case as there are no writes in our pacakge, only concurrent reads, which is the ideal scenario for a file based database.
So to help anyone else out who has this problem. I created a small go package that abstracts this all away to a single function. Additionally I created a docker container and small microservice so that anyone can just upload the container to their Kubernetes cluster or AWS Elastic Container Service setup and use this in a non Golang language.Â
I was very interested in reading this piece when I first saw it on r/datascience. Mr. Miller attempts to answer the question, "what percentage of impressions, yielded a retweet?" The Twitter API only provides the total number of retweets and the number of followers of the original user that posted the tweet. This means that there is no way to query the API to deduce whether a tweet received a ton of retweets because a high proportion of users retweeted it, or because the person who wrote the tweet has a ton of followers. Miller creates a statistical model in order to find an answer. Tweets are seen by followers. Followers arrive according to some poisson arrival process. Each follower who views the tweet has the same probability (p) of retweeting a tweet. From there he attempts to come up with a closed form solution for computing p, given the number of retweets, tweet lifetime, and the number of followers of the original poster. All in all my feelings on that are as follows.
I think I could do better....
Assumptions
Having studied Operations Research, I'm a big fan of Monte Carlo Simulation. One of my professors at Columbia bragged about how much more flexible a simulation based solution can be versus a closed form solution. First, I want to address the assumptions made by Mr. Miller. He makes 3 big assumptions
Followers arrive according to a single poisson process at rate once per hour
Whenever a follower arrives on Twitter, they will always see the tweet we are modeling.
Each follower, and their followers, has the same probability(p) of retweeting the tweet
All of these assumptions are definitely innacurate. First, followers cannot be coming at a constant rate for every user, especially not in a system where every user of twitter is refereshing once per hour. In Miller's example A with a 1000 followers, that means that all 1000 followers will check Twitter within 1 hour. On top of that, his model assumes that the rate at which Followers appear will be the same, regardless of the number of followers one has.
So I'm altering that slightly for my simulation. Instead I'll make an assumption, that the rate of arrival of my followers is the number of seconds in a day over the number of followers. This essentially assumes that all my followers, will on average, show up once in a day.It also assumes that time of day is not a factor. This is also not true, but you have to make some assumptions for the simplicity of the model. I'm also going to keep the latter two assumptions (seeing a tweet and constant probability(p)). I will explain at the end how this simulation provides the foundation to start to replace these constants with better interactions.
Simulation
var _giphy_tv_tag="typing"; var g = document.createElement('script'); g.type = 'text/javascript'; g.async = true; g.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'giphy.com/static/js/widgets/tv.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(g, s);
So I whipped up an iPython Notebook with a Discrete Event Monte Carlo simulation of this scenario. It was actually quite trivial and only amounted to about 50 lines of code. I won't overly explain the simulation here, view the code if you want to see how it works. But in a nutshell for a fixed probability of retweet p, I simulate a poison process of followers arriving and then retweeting with the given probability. Miller's closed form solution relied on limiting the retweet chain to 2 in order to reduce the complexityof the algebra. My simulation does not have this same constraint. In order to optimize runtime, I did limit the length of retweet chain to 6. However, this limit was based on research conducted by Twitter.
A Test Problem
Miller's test case is two tweets, A and B.
Tweet A was posted by a user with 1000 followers and received 25 retweets in an hour
Tweet B was posted by a user with 2000 followers and received 25 retweets in 30 minutes
Ideally these should be quite similar. This is asking what the tradeoff is between the time the tweet had to be seen and the number of followers the user has. Without any kinds of decays these should be relatively equal tradeoffs. i.e. showing the tweet longer to more followers should yield similar results to showing it to more people for a shorter amount of time.
Which tweet had a high retweet percentage?
via GIPHY
My iPython Notebook also incldues the answer to this. According to my simulation, A most likely had a retweet percentage of 8.2% while B had a retweet percentage of 8.21%. At the moment I haven't been able to figure out a good signifigance test for this. But for now, I'll assume its close enough to demonstrate equivilance. If you have any ideas, reach out I'd be quite interested. However, I think this answer is far more satisfying than Miller's original answer of around 2% for each.
Miller's model, with each person averaging a reload per hour, will see both tweet A and B having 1000 people expected to view the tweet. He then assumes that each of those people will retweet with a 2.1% probability and that their ~90 followers will do the same. One thing to note, all 90 followers for each person who retweeted, won't see the tweet. Only those who manage to arrive in the time remaining between the time the retweeter actually retweeted and the end of duration have the opportunity to retweet further in the chain. In the first order, the direct followers, 20ish people should retweet and then in the remaining time only 5 of those second order followers will retweet.
My model yields a quite different answer. By allowing higher order retweeting and not assuming that all of a users followers will appear within the hour, the model assumes a far higher percent of fewer incoming viewers need to retweet. To make it simple, if only 1/24 of my followers are expected to show up within an hour, then a lot higher of a percent of them need to retweet. Even then, my impression rate is a bit too high for reality, market sentiment says that the average tweet only has around a 2% impression rate.
How to get a better model?
via GIPHY
via GIPHY
Miller's model has so many assumptions and constraints that it doesn't realy accurately model the system. My simulation is also too limited in its current form. However the magic of simulation is that we can introduce more complex elements to the model quite easily. Miller's work is essentially a manipulation of a poisson process and a binomial distribution. While not trivial, finding a closed form solution is certainly doable. But if we wanted to take into account time of day, or decay the retweet probability as it gets further from the source, it will become ridiculously complicated to find a closed form solution.
So what would I do to get a better model?
Add a decay factor to the retweet rate the higher the order ( distance from the original poster) the tweet is
Introduce a decay factor due to time. This should capture the fact that the older a tweet is, the less likely arriving users are to even see it
Make the arrival process a mixture of poisson processes based on the time of day or switch distributions entirely to something that weights more heavily toward more active times
Randomly generate the number of followers each retweeter has according to the researched power law, rather than using the expected value. Should help to give better information on the variance
What's beautiful about simulation is that all of these are relatively trivial to add to the code. And so within 20 minutes I can have a new answer. Which is far better than the potential days the closed form solution would take. As a data scientist working in industry, its a lot more powerful for me to have approximately correct answers quickly than it is to be bogged down in theory. If you aren't in finance, business decisions are probably not being made on exact figures but rather relative magnitudes. So next time you encounter a problem like this, consider writing a simulation instead of doing a bunch of math, the result will be something that tends to be a lot more flexible.
Because moving your eyes is for those without technology
So I havenât stopped making side projects. This is a small computer vision POC that I put together. It scrapes comics from the web and uses Hough Transforms to convert a comic into an animated GIF. Its actual been met with a surprising amount of vitriol on Reddit by people who hate the idea of not seeing the whole comic at once. Personally I think its nice since the eye wonât be drawn to the end panels which could potentially ruin the joke/punch line of the comic. But then again what do I know.Â
Hey Niger, I'm presently thinking about joining Enigma's data team. I was wondering whether you'd recommend joining the company to someone interested in joining what externally appears to be a "less-evil Palantir", given that you were part of the data team and recently left / what sort of person you think might enjoy working at a company like this.
Wow sorry I took so long to respond to this. Enigma definitely views itself internally as a less-evil Palantir and in that regard I do think there are a lot of employees and leaders within the company dedicated to that vision. I think what you should think about is the industry itself. By that I mean Corporate Data Science.Â
Like Palantir Enigma works with a number of fortune 500 businesses and financial institutions. A lot of the challenges that one faces working with these companies are not engineering or data challenges but rather organization inertia. The work you do in this space can have great impact but it definitely moves a lot slower than in the technology space where âmove fast and break thingsâ is a much more accepted mantra.Â
So in terms of what kind of person would enjoy it, I think someone with a lot of patience and an appreciation of the long game will thrive in that kind of environment. If you find yourself being someone who likes more instant results, you may find things frustrating.Â
If you wanna have a more extended chat, hit me up on LinkedIn or something.Â
Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
â Live Streamingâ Interactive Chatâ Private Showsâ HD Qualityâ Free Actions
Free to watch ⢠No registration required ⢠HD streaming
Truly awesome work that Iâve already put into action at GIPHY. I might have to completely rethink time series anomaly detection to start using this work as its a lot more robust at decomposing a time series than Twitterâs STL methodology is.Â
On HN a lot of people are calling this a âPop Scienceâ article but I donât think thatâs a bad thing. Its easy to understand communication like this that makes the techniques we use digestible to non technical people. I wouldnât send this to someone looking to implement a Fourier Transform for Anomaly Detection or Signal Processing but I totally would send it to my mom so she can understand some of the techniques that I use. It concerns me how little the general public understands  the technologies they rely on everyday.Â
One way to deduplicate users, is to do what Google Recommends, and utilize a Rollup. A Rollup is a Google Analytics project that combines multiple other projects and aggregates them. Hits on this combined project are charged half the price of a normal project. This means the process of de-duplication will increase costs by 50%!
Another way to go is by setting up a BigQuery integration. Google is trying really hard to gain market share from Amazon and is offering very favorable pricing for BigQuery. In fact, premium Google Analytics users can get their first $500 of billing for free from BigQuery for being Google Analytics users. BigQuery allows users to interact with the raw request data from their GoogleAnalytics tracking logs. BigQuery offers a SQL like query language to pull data and compute metrics.
How do I get de duplicated uniques? Just do a union between the tables of each property, group by fullVisitorId(formerly client_id) and then SELECT count(*). This works because the client_id that google logs in each of your requests, is consistent regardless of property. In general, most people use the standard Google Analytics tracking cookie. When this cookie first was created on a userâs browser, either by one of your properties or any site, that cookie generated a unique ID. Google logs this ID with each request made and when you export to BigQuery every row will have that id, uniquely identifying the user. In fact, all Rolllups do in reality is the SQL I described above. So rather than pay Google, you can just do it yourself.
What about user_id? User_Id is a feature that google offers to allow developers to create their own tracking ids. This way you could theoretically track between devices and even OS!. For example, one could use a hash of someoneâs email associated with their account as the the user_id. That way, even if they login on a separate device you can track their sessions. If you are using user_id, then all the steps are the same except you join on that instead of fullVisitorId.
Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
â Live Streamingâ Interactive Chatâ Private Showsâ HD Qualityâ Free Actions
Free to watch ⢠No registration required ⢠HD streaming
Subreddit Algebra is super cool and this is a great exceution of the embedding principles everyone has gotten into since Word2Vec. Dango has also done some cool stuff with this, but using Emoji. I think techniques like this actually have a lot of potential to be crucial for transfer learning. The next generation of search, especially for non text content is upon us.Â
Iâve been reading a lot about Generative Adversarial Networks recently. The Wasserstein paper is extremely interesting given its about a month old and attempts to solve some of the problems in the original paper Goodfellow released 2 years ago. For those not familiar with GANs, its essentially the idea that to make a better generator algo, you train two competing algorithms that will make each other better. Imagine training two models, one that tries to write a fake essay and one that tries to catch a fake essay. By training them against each other, they should make each other better over time. This situation is essentially a game theory problem with the optimal solution being a nash equilibrium.Â
Optimizing your generator is just a matter of attempting to get the models probability distribution to match as closely as possible to that of the training data. Or at least enough so that the competing modelâs classification accuracy falls to 50% meaning the generator is optimal. Goodfellow, in his original paper,  was able to demonstrate that his cost function to get to that distribution was really equivalent to a Jenson-Shannon (JS) divergence. JS divergence is really just a mixture function of Kullback-Leibler (KL) divergence. KL divergence is just an entropy based measure of the difference of two distributions.
Goodfellowâs method had a number of weaknesses that he attempted to address in a follow up paper in 2016. Specifically issues around convergence of the loss function and actually generating things, in this case images, that were not only from the same distribution, but actually were intelligible to humans
The Wasserstein Gan paper attempts to solve a lot of these problems by introducing a new cost function. This cost function is based on Wasserstein Distance, also known as Earth Mover distance. Wasserstein distance is actually a measure of the amount of change a distribution would have to go through to become another one. It has the convenient properties of being able to converge on everything that KL and JS divergence can and it can also converge on a number of additional cases. Specially cases where KL and JS resolve to infinity which will through off gradient descent methods.Â
Wasserstein Gan also addresses a big problem with the orignal Gan methodology. Specifically that the Discriminator model was never fully converged because of concerns about saturation. The Wasserstein based cost function has properties that prevent these scenarios and so its possible to converge the Discriminator. A more competitive discriminator leads to a better generator.Â
I will say that Wasserstein Gans donât solve some larger problems I have with Gans. First is that while the two models compete over classification, they are not technically competing in a way that optimizes for a generator of human intelligible images. There are some other techniques Goodfellow has attempted to optimize for this but no one has yet made a Gan that can say generate real world images off of imagenet. Gans still lack any real usefulness in NLP since slightly changing a letter or a word in a sentence does not necessarily yield a valid sentence or one that makes any semantic sense. Iâd say the biggest value in Gans is using them to augment datasets for classification problems or to use insights from the discriminator for some kind of classification problem.