📜 ⬆️ ⬇️

Determining gender by navigation history, step 2

Good day.
First link: guess the gender of the visitor.

On the history of navigation with js, you can determine the sex of the visit, this has already been written . In short, we create links with js and see what colors they are, and by this we determine whether they are visited or not. Then we combine the information obtained with demographic data about the sites visited.

But foreign determinants work for us not so much, because consider sites popular in the USA.
I collected information on Russian sites, rewrote scripts a little.
Practical application (ha, very important and useful): there is a form on the site where you need to specify your gender. If a person has not previously indicated a gender, then using this technology, the site tries to guess it and substitute the desired one.
')
If someone wants to do it at home, then I post the work : there is a django server application, a js file, a dump of the collected database. The license, if not indicated elsewhere, is MIT. Without jangi, everything can also be used easily.


If you are using django, then for the server part you can connect the demography application.
(as usual, add to INSTALLED_APPS, if desired, use prepared urls). For testing, you may need the template gender_test.html somewhere, well, everything is clear in urls.py.
Demographic data can be set using the command
manage.py loaddata <-->/demography.json
They can also be imported from a database dump (demography.sql) - if django is not used.

If you are not using django, you will need to write the server part yourself. Everything is simple there: a page should be accessible along some path, which through POST accepts the parameter “links”, which contains an array of visited pages serialized in json and returns the json data dictionary (at least, I think, the probability that the visitor is a man).

The probability is calculated by the formula x / (1 + x), where x = r1 * r2 * ... * rn, where r1, r2, etc. - male_ratio of visited sites.

In principle, you can easily transfer the logic to the client, eliminating the server part altogether.

The client part consists of 2 parts (all in one file demography.js).
1. a bit simplified SocialHistory function from Aza Raskin (the speed of work has been improved, everything has been renamed to VisitHistory).
2. Demography mootools-class for working with the Jang server part.
I think everything is simple there, and whoever wants it will easily rewrite Demography to jQuery, etc., or make everything work with another server part, or transfer all the logic to the client.

Demography usage example:

//
var callback = function(response){
alert(response.male); // , - ,
}
// . - , .
var stats = new Demography('/gender/gender');

//
stats.get_gender_info(callback);


PS there is a suspicion that something is not working. But nothing, I will probably fix it in the evening.
UPD. It seems that the alarm is false, and everything works.

UPD2. Dear girls! I offer a formal apology if your gender was determined wrong. The fact is that according to statistics, the imbalance to the male side on computer-related sites is stronger than on pornographic sites, hence the inconsistencies. For example, you went to Habr - the probability that you are a man is already 88%. Do not be angry)

Source: https://habr.com/ru/post/57827/


All Articles