You are on page 1of 10

2015/2/10

AutomatingTinderwithEigenfaces

Thanks for reading

crockpotveggies

(/)

AUTOMATING TINDER WITH EIGENFACES ()


While my friends were getting sucked into "swiping" all day on their phones
with Tinder, I eventually got fed up and designed a piece of software that
automates everything on Tinder.

http://crockpotveggies.com/2015/02/09/automatingtinderwitheigenfaces.html

1/10

2015/2/10

AutomatingTinderwithEigenfaces

Since Tinders rising popularity, including its use by Olympic athletes such as
snowboarder Rebecca Torr, Tinder has achieved critical adoption as a
launchpoint for singles meeting singles. Its rising popularity has encouraged
a wave of "Tinderbot" inventions by nerds doing things such as "swiping
right" for everyone near their location (and of course those pesky
spammers). It wasn't my intention to "one-up" the competition, but using
the facial recognition algorithm Eigenfaces I built a bot that learns when to
swipe right (like a person) AND swipe left (dislike a person) AND start your
conversations.
Dubbed "Tinderbox", the first version only took 3 weeks to build. It uses an
existing Tinder account and taps into Tinder APIs, which is nice so you don't
have to create an entirely new account. Tinderbox recreates the Tinder app
in your browser, including the inbox and discovery preferences. The
workflow is simple:
The built-in bot builds facial models using your likes/dislikes
Bot examines profile images, cropping faces
Faces are loaded into an "average" face representing choices
Eigenfaces are computed from average faces
Bot then makes future selections based on Eigenface comparison
Comparisons are essentially k-nearest neighbor selection

Eigenface (https://en.wikipedia.org/wiki/Eigenface) is a quick and easy


algorithm to implement facial recognition without the use of complex
software like OpenCV. Tinderbox first extracts faces using the Viola-Jones
framework - specifically the jViolaJones (https://github.com/tc/jviolajones)
implementation - and converts them to grayscale. Only pictures with single,

http://crockpotveggies.com/2015/02/09/automatingtinderwitheigenfaces.html

2/10

2015/2/10

AutomatingTinderwithEigenfaces

identifiable faces are used (to filter out false positives). Then after each
image is normalized, its pixels are converted into a matrix where they are
then appended to a list of models. The models are then averaged into a
single face used for future comparison (as noted in the workflow above).
The bot requires you to make 60 yes/no choices before it has enough data
to choose on your behalf. Then its on full auto-pilot.
If you're interested in the code behind this, here's a snippet of the two main
defs for computing Eigenfaces:

http://crockpotveggies.com/2015/02/09/automatingtinderwitheigenfaces.html

3/10

2015/2/10

AutomatingTinderwithEigenfaces

/**
*ComputestheEigenFacesmatrixusingapixelmatrixofmultipleima
ges.
*@parampixelMatrix
*@parammeanColumn
*/
defcomputeEigenFaces(pixelMatrix:Array[Array[Double]],meanColumn:A
rray[Double]):DoubleMatrix2D={
valdiffMatrix=MatrixHelpers.computeDifferenceMatrixPixels(pixelMa
trix,meanColumn)
valcovarianceMatrix=MatrixHelpers.computeCovarianceMatrix(pixelMa
trix,diffMatrix)
valeigenVectors=MatrixHelpers.computeEigenVectors(covarianceMatri
x)
computeEigenFaces(eigenVectors,diffMatrix)
}
/**
*ComputestheEigenFacesmatrixforadatasetofEigenvectorsanda
diffmatrix.
*@parameigenVectors
*@paramdiffMatrix
*/
defcomputeEigenFaces(eigenVectors:DoubleMatrix2D,diffMatrix:Array[
Array[Double]]):DoubleMatrix2D={
valpixelCount=diffMatrix.length
valimageCount=eigenVectors.columns()
valrank=eigenVectors.rows()
valeigenFaces=Array.ofDim[Double](pixelCount,rank)
(0to(rank1)).foreach{i=>
varsumSquare=0.0
(0to(pixelCount1)).foreach{j=>
(0to(imageCount1)).foreach{k=>
eigenFaces(j)(i)+=diffMatrix(j)(k)*eigenVectors.get(i,k)
}
sumSquare+=eigenFaces(j)(i)*eigenFaces(j)(i)
}
varnorm=Math.sqrt(sumSquare)
(0to(pixelCount1)).foreach{j=>
eigenFaces(j)(i)/=norm
}
}
valeigenFacesMatrix=newDenseDoubleMatrix2D(pixelCount,rank)
eigenFacesMatrix.assign(eigenFaces)
}

And computing the distance is just as easy:

http://crockpotveggies.com/2015/02/09/automatingtinderwitheigenfaces.html

4/10

2015/2/10

AutomatingTinderwithEigenfaces

/**
*Computesthedistancebetweentwoimages.
*@parampixels1
*@parampixels2
*/
privatedefcomputeImageDistance(pixels1:Array[Double],pixels2:Arra
y[Double]):Double={
vardistance=0.0
valpixelCount=pixels1.length
(0to(pixelCount1)).foreach{i=>
vardiff=pixels1(i)pixels2(i)
distance+=diff*diff
}
Math.sqrt(distance/pixelCount)
}

If you're interested learning more about Eigenfaces, this paper


(https://dl.dropboxusercontent.com/u/37572555/Github/Face%20Recognition/FaceRecognition.pdf)
has a relatively good overview of the math/matrix operations as well as a
selection process using k-nearest neighbor. The paper is a description of
another Eigenface facial recognition system.
I also added a couple of features that are only in the paid version of Tinder.
"Undo" buttons are there in the event a wrong swipe was made or the bot
made a poor choice. Also, you can set your location to anywhere in the
world for travel or curiosity purposes.
The bot that runs in the background also has a messaging system that starts
conversations. Using StanfordNLP (http://nlp.stanford.edu/), the bot
analyzes the sentiment of each chat response and classifies it as positive or
negative. Using a "message tree" (see diagram below), the bot selects from
pre-programmed chat messages as a response based on the sender's
sentiment. This continues up to 3 replies until the user is notified that a chat
is ready to enter. The advantage of this? It removes the time involved in
filtering new Tinder matches since a lot of people tend to drop off and "go
dark" early in the process. Extended conversation is a strong indicator of
interest.

http://crockpotveggies.com/2015/02/09/automatingtinderwitheigenfaces.html

5/10

2015/2/10

AutomatingTinderwithEigenfaces

What are the results so far? The bot is amazingly effective. I would estimate
an accuracy of up to 70% in its selections - though there may be a hindsight
bias. Using a brand new account, I did a quick test to see how quickly the
bot could get results. In 48 hours, the bot registered 21 matches (starting all
of those conversations), made 4 extended conversations, and the bot itself
made over 300 moves. A "move" is any step the bot makes in either sending
a message or making a swipe. And in that time I barely needed to touch the
app. I also created a dashboard to give me an overview of my metrics (see
screenshot below).

http://crockpotveggies.com/2015/02/09/automatingtinderwitheigenfaces.html

6/10

2015/2/10

AutomatingTinderwithEigenfaces

What do girls think of the bot? I've gone on at least 10 dates with the help of
the bot and I've shown my partners the bot in its entirety. One date literally
didn't believe me and thought I was pulling her leg. Another person thought
it was really cool and wanted the full tour. All were in agreement that it is

not creepy, though some felt it was borderline. Kind of nice considering it's
not something you'd come across everyday.
Am I still using the bot? I've actually turned it off for now. Admittedly, it
worked too well and started to conflict with work. Although in a couple
cases I had follow-ups and I'm still seeing one person.
Check out the code online: https://github.com/crockpotveggies/tinderbox
(https://github.com/crockpotveggies/tinderbox). Please feel free to
contribute. I don't have current plans to pursue this commercially, though
the license allows personal use and modification.

Automating Tinder with Eigenfaces

While my friends were getting sucked into


"swiping" all day on their phones with
Tinder, I eventually got fed up and
designed a piece of software that
automates everything on Tinder.

(/2015/02/09/automating-tinder-with-eigenfaces.html)

Public Company; Our Humility

http://crockpotveggies.com/2015/02/09/automatingtinderwitheigenfaces.html

7/10

2015/2/10

AutomatingTinderwithEigenfaces

Not nearly as big as a Facebook IPO, our


company, 3 Tier Logic, will be publicly
traded starting November 10. I'm about to
make a big change in my own life and I
have no idea how it will play out.

(/2014/11/01/public-company-public-humility.html)
(/2014/10/30/amelia-earhart-metal-fragment-2-2-v-1.html)

Reopening Fragment 2-2-V-1, Amelia Earhart's Plane?

(/2014/10/30/amelia-earhart-metalfragment-2-2-v-1.html)

On October 29, (/2014/10/30/ameliaearhart-metal-fragment-2-2-v1.html)TIGHAR gained attention


(www.history.com/news/researchersidentify-fragment-of-amelia-earhartsplane/?
cmpid=Social_Facebook_HITH_10292014_1)
speculating that growing evidence
suggests fragment 2-2-V-1 may belong to
Amelia Earhart's plane. However, this is far
from new, and has been refuted as far
back as 1992.

Finding Centrality, There's More to Betweenness

Being immersed in my own graph research


and development, I quickly ran into the
common problems with centrality in social
network analysis. Does it scale? Can it be
parallelized? Is it going to be effective in
my own problem solving?

http://crockpotveggies.com/2015/02/09/automatingtinderwitheigenfaces.html

8/10

2015/2/10

AutomatingTinderwithEigenfaces

(/2014/10/14/centrality-algorithms-betweenness-markov.html)

Reviewing the (now) ancient Graph, Jung

At 3 Tier Logic I've been building a


prototype for a future product behind the
scenes, and to demonstrate some of the
concepts I actually went with a Graph that
is now becoming a little outdated: Jung.

(/2014/08/25/review-ancient-jung-java.html)
(/2014/07/06/tried-capture-bear-got-deer.html)

Got Deer, No Bear, But...

(/2014/07/06/tried-capture-bear-gotdeer.html)
In a follow up to my most

(/2014/07/06/tried-capture-bear-gotdeer.html) recent post


(http://crockpotveggies.com/2014/07/04/huntingfor-bear-photography.html) I set out to see
if I could photograph bears out in the
British Columbia backcountry. The local
black bears didn't make an appearance,
but there's hope I still might see some type
of bear.

CONTACT
http://crockpotveggies.com/2015/02/09/automatingtinderwitheigenfaces.html

9/10

2015/2/10

AutomatingTinderwithEigenfaces

(https://twitter.com/crockpotveggies)

(https://github.com/crockpotveggies)

(http://linkedin.com/in/justinlongfellow)

Copyright Justin Long

(https://mixpanel.com/f/partner)

http://crockpotveggies.com/2015/02/09/automatingtinderwitheigenfaces.html

10/10

You might also like