It almost goes without saying that Tinder has taken the dating world by storm. Stats released late last year revealed that Tinder’s 50-million-strong userbase complete over a billion left and right swipes every single day. The success has often been attributed to the fact that Tinder is the closest virtual simulation of the bar experience; you see an attractive person across the bar, and in the that moment- having only seen them, and knowing precious little about them other than the way they look (and maybe their tipple of choice), you decide whether or not to make your approach. It’s virtual speed dating, where every encounter can end in the few moments it takes for you to swipe left or right without your potential partner ever even knowing.

However, another stat released by Tinder exposes that the average user spends 90 minutes a day swiping and reviewing their matches. That is a huge investment in terms of time and effort, without any guarantee you’ll end up matched with anyone.

BydYe6kIMAAHpAw

Objectively the best Tinder profile of all time. 

For Justin Long, a Canadian entrepreneur & Chief of Research for a disruptive technology company, this was the biggest turn-off on Tinder. “Tinder has reached critical mass; I feel it’s been adopted by relatable people and the right variety of women. I became aware of how enjoyable it was to keep matching and swiping for the next match; however, I was dissatisfied with how much time I had to invest in it. Swiping is both Tinder’s best and worst feature.”

His solution? Automate the entire process. Of course, bots have already been created by other Tinder users which swipe right (accept) all possible matches. Whilst inventive, these bots don’t take into account personal preference, or get rid of spammers. Long had something a little more sophisticated in mind- a bot which learns your physical “type” using the Eigenfaces facial recognition algorithm, and automatically got the conversation going with your matches.

The code, dubbed Tinderbox, requires you to make 60 “swipes”- then, the model has enough data to understand your preferences and make auto-pilot matches on your behalf. Long’s blogpost outlines the workflow on the backend like so:

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

The bot first extracts the faces using the Viola-Jones framework, and converts them to greyscale. Photos containing more than one identifiable face are filtered out, to avoid false positives. The pictures are then normalised, and the pixels are converted into a matrix, and used to create single, “average” faces for your “Yes” and “No” swipes for Eigenface comparison. The average face representations look a little something like this:

Hacking Tinder Eigenfaces
Implementing the algorithm and trying to find the best matrix library proved to be the trickiest part. “There’s more than one way to bake a cake,” Long says, “and finding the right recipe was difficult.” For those of you interested in the code, here’s a snippet that computes the Eigenfaces matrix using a pixel matrix of multiple images:

/**
   * Computes the EigenFaces matrix using a pixel matrix of multiple images.
   * @param pixelMatrix
   * @param meanColumn
   */
  def computeEigenFaces(pixelMatrix: Array[Array[Double]], meanColumn: Array[Double]): DoubleMatrix2D = {
    val diffMatrix = MatrixHelpers.computeDifferenceMatrixPixels(pixelMatrix, meanColumn)
    val covarianceMatrix = MatrixHelpers.computeCovarianceMatrix(pixelMatrix, diffMatrix)
    val eigenVectors = MatrixHelpers.computeEigenVectors(covarianceMatrix)
    computeEigenFaces(eigenVectors, diffMatrix)
  }

  /**
   * Computes the EigenFaces matrix for a dataset of Eigenvectors and a diff matrix.
   * @param eigenVectors
   * @param diffMatrix
   */
  def computeEigenFaces(eigenVectors: DoubleMatrix2D, diffMatrix: Array[Array[Double]]): DoubleMatrix2D = {
    val pixelCount = diffMatrix.length
    val imageCount = eigenVectors.columns()
    val rank = eigenVectors.rows()
    val eigenFaces = Array.ofDim[Double](pixelCount, rank)

    (0 to (rank-1)).foreach { i =>
      var sumSquare = 0.0
      (0 to (pixelCount-1)).foreach { j =>
        (0 to (imageCount-1)).foreach { k =>
          eigenFaces(j)(i) += diffMatrix(j)(k) * eigenVectors.get(i,k)
        }
        sumSquare += eigenFaces(j)(i) * eigenFaces(j)(i)
      }
      var norm = Math.sqrt(sumSquare)
      (0 to (pixelCount-1)).foreach { j =>
        eigenFaces(j)(i) /= norm
      }
    }
    val eigenFacesMatrix = new DenseDoubleMatrix2D(pixelCount, rank)
    eigenFacesMatrix.assign(eigenFaces)
  } 

And computing the distance between two images:

 /**
   * Computes the distance between two images.
   * @param pixels1
   * @param pixels2
   */
  private def computeImageDistance(pixels1: Array[Double], pixels2: Array[Double]): Double = {
    var distance = 0.0
    val pixelCount = pixels1.length
    (0 to (pixelCount-1)).foreach { i =>
      var diff = pixels1(i) - pixels2(i)
      distance += diff * diff
    }
    Math.sqrt(distance / pixelCount)
  } 

So Long’s bot is now able to automate all of the swiping. But what about all of those matches that clutter up your notifications, where the person you’ve matched to never replies? Long wanted to go one step further, and identify only the women who genuinely wanted to strike up a conversation. For this, he programmed the bot to start conversations, and use StanfordNLP to analyse the sentiment of responses. “I’ll admit that StanfordNLP’s approach isn’t the best for examining sentiment,” Long confessed. “This is because it tries to analyze the message by its structure and not necessarily by its content. Sarcasm can register as negative (and humor is actually an expression of positive sentiment). Additionally, messages classified as neutral could still be positive – this is because in the bigger picture any message at all still indicates interest. If I were to do this again I would be much more comprehensive.”

If the sentiment was deemed positive, the bot sends out pre-programmed replies. Once three replies have been given, the user receives a conversation that their match is genuinely interested and the conversation is ready to enter. The process looks a little something like this:

Hacking Tinder Eigenfaces Bot
Getting the bot up and running didn’t go without a hitch. In terms of technical snags, “The bug where all of my matches were repeatedly messaged tops the cake”, he said. “I had just revised the messaging system and when I went to test it, the bot just harassed all of my chats with constant openers. I think I got a couple spam reports from that. No long-term damage though!”

Still, within 3 weeks, the bot was up and running, and Long was presented with a list of matches who were genuinely interested in speaking with him. But did this actually improve his Tinder experience? Famously, Chris McKinlay spent months using K-modes to hack OkCupid, only to end up on a string of disappointing dates- and then met his future wife when she messaged him out of the blue.

Long’s strategy, I’m happy to report, seems to be more effective. “I made a huge mistake here by not keeping track of my before/after data, so most of my feedback is anecdotal,” he says. “I discovered two huge improvements: 1) massive increase in personal time, and 2) I had a large increase in the quality of my matches. People that I not only found more attractive, but also were better conversationalists.”

He also set up a new account, to see how it would perform with a fresh dataset in 48 hours. In that short time frame, the bot made over 300 “moves” (swipes and messages), established 21 matches, and sparked 4 extended conversations. All this is two days, requiring just 60 swipes from the user.

Of course, the point of TinderBox is not to find love- or whatever else you happen to be looking for. It’s supposed to filter out the hours of wading through incompatible matches, and starting conversations which never get a response. What happens from there is up to you; it’s safe to say that Long made the most it. Speaking about his post-bot dates, he told us “I probably made someone’s night running around the beach in our socks and kissing in the rain. I also came up with one of my best date ideas: bake some cookies, show up at the nearest firehouse, bribe firemen with said cookies, and take a tour.”

His blogpost intimates he’s now turned off the bot. “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.”

For those of you curious about TinderBox, Long has uploaded the code to Github for “personal use”. We asked Long how he’d react if he went on a date with a girl who’d used the TinderBox code to set up the match. “I’d be totally shocked because I actually tried using the bot with a female friend previously, and it freaked her out. So she’s either got some balls to be turning over her Tinder account to the bot, or she’s super smart to modify the code and make it work for her. Either way, those are people I want to know.”

(Image credit: Unsplash)

Previous post

Avox Launches Web-Based API for Rapid Legal Entity Data Access

Next post

25th February, 2015- "Dell Software Makes You Better Together", Frankfurt