How to pick up 13 girls an hour using machine learning and Tinder

*Exclusively for the sake of studying Machine Learning, of course. Under the slightly displeased gaze of his beloved wife.

There is probably no application as simple to the level of spinal reflexes as Tinder. In order to use it, one finger is enough to swipe and some neurons to choose the girls or men that you like best. The ideal implementation of brute force in choosing a pair.

I thought this was a good way to get a little taste of machine learning on a new graphics card. All that remains is to explain to my wife that I don’t need a new thicker woman, but I’m just training neural networks.

How to pick up 13 girls an hour using machine learning and Tinder

What is the problem with dating networks

There was such a resource - Ashley Madison. Specific, with the slogan β€œLife is short. Have an affair. The main audience is married men looking for an affair on the side. Monetization is also fun - in addition to the standard "spend points to like and write," they asked for $19 to delete a user's account without a trace.

In 2015, the site naturally leaked and 60 GB of personal data leaked into the public domain. In addition to the many destroyed families, this leak gave a lot of interesting information to analysts. I always suspected that there were a lot more men on dating sites, but in this case it turned out to be quite interesting. Annalee Newitz journalist analyzing leaked data found that out of 5 million users, only 12 looked like real girl accounts and were used regularly. The rest were just bots that interacted with male visitors.

Such a preponderance towards male accounts is typical not only for this resource, but also for most other dating sites. I am sure that many have come across this undoubtedly unfair situation, when you have to carefully think over an acquaintance, and a girl just needs to register. Let's leave the quality of this crowd of fans aside, but the fact is undeniable, the balance of supply and demand is clearly shifted in favor of girls.

Tinder Feature

How to pick up 13 girls an hour using machine learning and Tinder
The ideal brute-forcer in gender relations

The main feature of this platform is the low cost per acquaintance. The coincidence of two swipes is enough and you are already talking with a potentially interesting person. The problem is that the same gender imbalance leads to the fact that most girls will have dozens of matches per day. This means that they will most likely have no time to pay attention to you among other candidates.

It is quite clear that the platform implies few opportunities to assess the deep inner world of a person by a one and a half second look at a photo in a swimsuit or driving a trendy tinted car. Therefore, if you do not look simply divine in your photos, you have no choice but to increase your chances by adopting r-strategy in some species. Simply put, we will brute force and take in volume to increase our chances of breeding success. Since you need to sometimes be distracted by food and sleep, and swipes are limited, you will probably prefer that automation selects the girls or men that suit your tastes the most. Small redheads or tall brunettes - this is up to you.

Collecting data

First of all, you need a lot of data for normal accuracy. Anyone who has dealt with machine learning knows how difficult it can be to type a correctly assembled and labeled dataset. Theoretically, any similar resource is suitable as a data source, be it Instagram or other social networks. But it is best to train on those samples on which the network will work in the future.

Let's take the repository as a basis Tinder Automation. Photos on Tinder are always public, but the "likes" feature is already limited. Therefore, it is necessary to extract all living things in the radius and carefully mark them. To get started, you need to use a fairly simple script:

from skimage.io import imread, imsave, imshow, show
import matplotlib.pyplot as plt
import pynder
from helpers import get_access_token, get_login_credentials
from io_helper import save_image

email, password, FBID = get_login_credentials()
FBTOKEN = get_access_token(email, password)
session = pynder.Session(facebook_token=FBTOKEN)

while True:
    users = session.nearby_users()
    for user in users:
        photos = user.get_photos()
        print("Fetched user photos..")
        for photo in photos:
            print(photo)
            image = imread(photo)
            imshow(image)
            show()

            input_string = "Write 1 to like. Write 2 to dislike."
            ans = str(input(input_string)).lower()

            if ans == "1":
                save_image(image, photo, True)
            else:
                save_image(image, photo, False)

It will allow you to mark up the dataset as quickly as possible with just two buttons. The key pitfall is that the werkzeug library has broken backwards compatibility and will have to be forced downgraded. Otherwise it throws this error.

Traceback (most recent call last):
  File "img_scrape.py", line 4, in <module>
    from helpers import get_access_token, get_login_credentials
  File "/home/someone/tmp/TinderAutomation/helpers.py", line 1, in <module>
    import robobrowser
  File "/home/someone/tmp/TinderAutomation/venv/lib/python3.6/site-packages/robobrowser/__init__.py", line 3, in <module>
    from .browser import RoboBrowser
  File "/home/someone/tmp/TinderAutomation/venv/lib/python3.6/site-packages/robobrowser/browser.py", line 8, in <module>
    from werkzeug import cached_property
ImportError: cannot import name 'cached_property'

Therefore, werkzeug==0.16.1 must be written in requirements.txt. Then it will take off.
The second problem is to get this very token. The standard method from the repository did not take off for me, but I managed to get it from the developer console. To do this, go to link and pull out the response to the POST request in www.facebook.com/v2.6/dialog/oauth/confirm?dpr=1. Inside we are looking for 'access_token'. For some reason it didn't work the first time, but then I found it and hardcoded it into a script.

dataset requirements

There are several key requirements for machine learning datasets:

  1. Adequacy
  2. Uniformity
  3. Π Π°Π·Π½ΠΎΠΎΠ±Ρ€Π°Π·ΠΈΠ΅

Sufficiency in this case requires at least 10000 photographs to build an adequate model. Yes, that's a lot. That's why there are services like Amazon Mechanical Turk, where for a fee you can outsource the markup of your dataset to other people. On the other hand, do you really want your bot to like beautiful moon-faced Asian girls or equally beautiful girls with Indian roots? Still, the model should reflect exactly your taste.

There are no particular problems with the variety, all photographs are presented in a variety of angles and lighting. In glasses, dresses, swimsuits and ski suits. The problem may arise with the uniformity of the dataset. Ideally, when we mark up our sample, it should consist of approximately equal parts. If you have a β€œskewed” dataset, then you will have to dilute it with photographs from other sources. Prettier ones will need to be added, or vice versa, you will determine by the result of the markup. I got something in the region of 60% cute. Either I'm not too picky, or I'm just lucky and there are a lot of pretty girls around.

I also do not dismiss the hypothesis that there are many bots among them. We train a bot that will like other bots. There is some irony in this.

Data processing

We have a bunch of tagged photos, but they're very mixed. Day, night, from the back and others. With regret, I understand that it’s not particularly possible to train on photographs from the reverse angle, since the sample will be very uneven. Therefore, the best option would be to use faces as a reference sign of "prettyness". Still, for us, as for other primates, this is a key parameter.

Therefore, we use cascades of haar. This is an excellent algorithm that allows you to find faces in images with a low percentage of false positive errors.

How to pick up 13 girls an hour using machine learning and Tinder
This is described in more detail in the manual for OpenCV

At the next stage, after only faces are in the sample, it makes sense to remove the color. In fact, you are unlikely to have to choose between a beautiful blue Pandora woman or a green-skinned beauty.

How to pick up 13 girls an hour using machine learning and Tinder
Source

In Hue people, the skin color parameter does not significantly contribute to the cuteness score.
Therefore, it is worth simplifying the work of the neural network and leaving only grayscale.

Building the model

I want to say right away that without a good video card and CUDA, you most likely simply won’t get a trained model in an adequate time frame. Therefore, immediately aim for calculations in specialized clouds or using python-CUDA.

I took a basic three-layer example from the author of the repository and, surprisingly, it showed an accuracy of around 72%, which is quite a good result.

model = Sequential()
model.add(Convolution2D(32, 3, 3, activation='relu', input_shape=(img_size, img_size, 3)))
model.add(MaxPooling2D(pool_size=(2,2)))

model.add(Convolution2D(32, 3, 3, activation='relu'))
model.add(MaxPooling2D(pool_size=(2,2)))

model.add(Convolution2D(64, 3, 3, activation='relu'))
model.add(MaxPooling2D(pool_size=(2,2)))
          
model.add(Flatten())
model.add(Dense(128, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(2, activation='softmax'))

adam = optimizers.SGD(lr=1e-4, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='categorical_crossentropy',
              optimizer= adam,
              metrics=['accuracy'])

If there is a good sample, then it may well be enough to get a workable model.

Launching the bot

How to pick up 13 girls an hour using machine learning and Tinder

Thanks to the author of the repository for the ready-made version to quickly test the idea. In fact, it works quite well in the basic version and can, in principle, be launched on our ready rented server. It will not be possible to train yet, at the moment we do not provide virtual machines with CUDA support for calculations, but you can run something for 24/7 work without problems. The bot is quite lightweight, so it would be more profitable to take a tariff with payment for the resources used.

The results

How to pick up 13 girls an hour using machine learning and Tinder
I must be very cute. And I have a rich inner world. Got something in the region of 13 matches within an hour. Moreover, several times the girls wrote first.
As a result, very nice dialogues were obtained, where I said that I had only come to play with machine learning and data markup. One of the girls was extremely interested, since she herself is a developer. There is a strong feeling that she will eventually read this post on HabrΓ©. I really hope that Oksana will keep my anonymity. πŸ™‚
*waves paw and says hello

A little about the ethical side of the issue

To be honest, I don't like the idea of ​​robotization of relations between men and girls at all. There is something very right about throwing your jacket over the shoulders of a frozen stranger who stands alone. Or approach a pretty girl in a summer cafe and drink coffee together. Get out from behind the monitors.

Around summer. It's time to get acquainted.

How to pick up 13 girls an hour using machine learning and Tinder

How to pick up 13 girls an hour using machine learning and Tinder

Source: habr.com

Add a comment