Hello, my name is Christian Rudder, and I was one of the founders of OkCupid. It's now one of the biggest dating sites in the United States. Like most everyone at the site, I was a math major, As you may expect, we're known for the analytic approach we take to love. We call it our matching algorithm. Basically, OkCupid's matching algorithm helps us decide whether two people should go on a date. We built our entire business around it. Now, algorithm is a fancy word, and people like to drop it like it's this big thing. But really, an algorithm is just a systematic, step-by-step way to solve a problem. It doesn't have to be fancy at all. Here in this lesson, I'm going to explain how we arrived at our particular algorithm, so you can see how it's done. Now, why are algorithms even important? Why does this lesson even exist? Well, notice one very significant phrase I used above: they are a step-by-step way to solve a problem, and as you probably know, computers excel at step-by-step processes. A computer without an algorithm is basically an expensive paperweight. And since computers are such a pervasive part of everyday life, algorithms are everywhere. The math behind OkCupid's matching algorithm is surprisingly simple. It's just some addition, multiplication, a little bit of square roots. The tricky part in designing it was figuring out how to take something mysterious, human attraction, and break it into components that a computer can work with. The first thing we needed to match people up was data, something for the algorithm to work with. The best way to get data quickly from people is to just ask for it. So we decided that OkCupid should ask users questions, stuff like, "Do you want to have kids one day?" "How often do you brush your teeth?" "Do you like scary movies?" And big stuff like, "Do you believe in God?" Now, a lot of the questions are good for matching like with like, that is, when both people answer the same way. For example, two people who are both into scary movies are probably a better match than one person who is and one who isn't. But what about a question like, "Do you like to be the center of attention?" If both people in a relationship are saying yes to this, they're going to have massive problems. We realized this early on, and so we decided we needed a bit more data from each question. We had to ask people to specify not only their own answer, but the answer they wanted from someone else. That worked really well. But we needed one more dimension. Some questions tell you more about a person than others. For example, a question about politics, something like, "Which is worse: book burning or flag burning?" might reveal more about someone than their taste in movies. And it doesn't make sense to weigh all things equally, so we added one final data point. For everything that OkCupid asks you, you have a chance to tell us the role it plays in your life. And this ranges from irrelevant to mandatory. So now, for every question, we have three things for our algorithm: first, your answer; second, how you want someone else -- your potential match -- to answer; and third, how important the question is to you at all. With all this information, OkCupid can figure out how well two people will get along. The algorithm crunches the numbers and gives us a result. As a practical example, let's look at how we'd match you with another person. Let's call him "B." Your match percentage with B is based on questions you've both answered. Let's call that set of common questions "s." As a very simple example, we use a small set "s" with just two questions in common, and compute a match from that. Here are our two example questions. The first one, let's say, is, "How messy are you?" And the answer possibilities are: very messy, average and very organized. And let's say you answered "very organized," and you'd like someone else to answer "very organized," and the question is very important to you. Basically, you're a neat freak. You're neat, you want someone else to be neat, and that's it. And let's say B is a little bit different. He answered "very organized" for himself, but "average" is OK with him as an answer from someone else, and the question is only a little important to him. Let's look at the second question, from our previous example: "Do you like to be the center of attention?" The answers are "yes" and "no." You've answered "no," you want someone else to answer "no," and the question is only a little important to you. Now B, he's answered "yes." He wants someone else to answer "no," because he wants the spotlight on him, and the question is somewhat important to him. So, let's try to compute all of this. Our first step is, since we use computers to do this, we need to assign numerical values to ideas like "somewhat important" and "very important," because computers need everything in numbers. We at OkCupid decided on the following scale: "Irrelevant" is worth 0. "A little important" is worth 1. "Somewhat important" is worth 10. "Very important" is 50. And "absolutely mandatory" is 250. Next, the algorithm makes two simple calculations. The first is: How much did B's answers satisfy you? That is, how many possible points did B score on your scale? Well, you indicated that B's answer to the first question, about messiness, was very important to you. It's worth 50 points and B got that right. The second question is worth only 1, because you said it was only a little important. B got that wrong, so B's answers were 50 out of 51 possible points. That's 98% satisfactory. Pretty good. The second question the algorithm looks at is: How much did you satisfy B? Well, B placed 1 point on your answer to the messiness question and 10 on your answer to the second. Of those 11, that's 1 plus 10, you earned 10 -- you guys satisfied each other on the second question. So your answers were 10 out of 11 equals 91 percent satisfactory to B. That's not bad. The final step is to take these two match percentages and get one number for the both of you. To do this, the algorithm multiplies your scores, then takes the nth root, where "n" is the number of questions. Because s, which is the number of questions in this sample, is only 2, we have: match percentage equals the square root of 98 percent times 91 percent. That equals 94 percent. That 94 percent is your match percentage with B. It's a mathematical expression of how happy you'd be with each other, based on what we know. Now, why does the algorithm multiply, as opposed to, say, average the two match scores together, and do the square-root business? In general, this formula is called the geometric mean. It's a great way to combine values that have wide ranges and represent very different properties. In other words, it's perfect for romantic matching. You've got wide ranges and you've got tons of different data points, like I said, about movies, politics, religion -- everything. Intuitively, too, this makes sense. Two people satisfying each other 50 percent should be a better match than two others who satisfy 0 and 100, because affection needs to be mutual. After adding a little correction for margin of error, in the case where we have a small number of questions, like we do in this example, we're good to go. Any time OkCupid matches two people, it goes through the steps we just outlined. First it collects data about your answers, then it compares your choices and preferences to other people's in simple, mathematical ways. This, the ability to take real-world phenomena and make them something a microchip can understand, is, I think, the most important skill anyone can have these days. Like you use sentences to tell a story to a person, you use algorithms to tell a story to a computer. If you learn the language, you can go out and tell your stories. I hope this will help you do that.
Bună, mă numesc Christian Rudder, și am fost unul dintre fondatorii OK Cupid. E printre cele mai mari site-uri de dating din SUA. Ca mai toți de la site, am terminat matematica și cum deja știți, suntem faimoși pentru viziunea analitică asupra iubirii. Îl numim algoritmul potrivirii. Algoritmul Ok Cupid ne ajută să aflăm dacă doi oameni ar putea ieși la o întâlnire. Întreaga noastră afacere se bazează pe el. „Algoritm" e un termen pretențios, iar oamenii îl folosesc ca pe ceva important, însă, de fapt, un algoritm e doar o cale sistematică de a rezolva o problemă. Nu are de ce să fie pretențios. În această lecție voi explica cum am creat și cum folosim acest algoritm special. Care e importanța algoritmilor? De ce există de fapt? Rețineți una dintre frazele folosite anterior: sunt căi sistematice spre rezolvarea unei probleme, și, după cum știți, calculatoarele excelează la astfel de procese. Un computer fără algoritm e practic un teanc de hârtii costisitor. Și cum aceasta sunt esențiale vieții de zi cu zi, algoritmii sunt pretutindeni. Matematica folosită de algoritmul nostru e surprinzător de simplă. Constă în adunare, înmulțire și câteva operații cu radicali. Dificultatea întâlnită la construirea lui a constat în felul în care ceva misterios, ca atracția umană, poate fi transformată în ceva procesat de calculatoare. Întâi am avut nevoie de date pentru a potrivi oamenii, ce erau apoi prelucrate de algoritm. Cel mai bun mod de a le obține de la oameni e pur și simplu să întrebi. Am decis ca OK Cupid să pună întrebări utilizatorilor precum, „Vă doriți copii într-o bună zi?" „De câte ori vă spălați pe dinți?" „Vă plac filmele de groază?" și lucruri mai importante precum „Credeți în Dumnezeu?" Majoritatea întrebărilor ajută la găsirea similarităților când două persoane răspund la fel. Astfel, doi oameni cărora le plac filmele de groază ar fi un cuplu mai bun decât cineva căruia-i plac și altcineva căruia îi displac. Dar cu întrebări ca „Doriți să fiți în centrul atenției?" Dacă ambii parteneri răspund da, atunci s-ar putea să aibă mari probleme. Am realizat asta din timp și am decis că aveam nevoie de mai multe detalii la fiecare întrebare. Am rugat oamenii să specifice nu doar propriul răspuns, ci și cel dorit de la partener. A funcționat bine, dar aveam nevoie de încă o dimensiune. Unele întrebări oferă mai multe detalii decât altele. De exemplu, o întrebare legată de politică precum: „Ce e mai rău, incendierea cărților sau cea a drapelului?" poate dezvălui mai mult decât gustul cuiva în filme. Cum nu toate lucrurile pot fi evaluate la fel, am adăugat un aspect final datelor. Pentru toate întrebările de la OK Cupid, puteți specifica rolul acestora în viața dumneavoastră, de la irelevant la obligatoriu. Deci la fiecare întrebare, algoritmul dispune acum de trei lucruri: răspunsul dumneavoastră; apoi, cum doriți ca posibila pereche să răspundă, și, în final, importanța întrebării pentru dumneavoastră. Cu aceste informații, OK Cupid poate stabili dacă doi oameni se potrivesc. Algoritmul preschimbă numerele în rezultate. Uitați un exemplu practic: să vedem cum putem să vă potrivim cu o altă persoană, să zicem B. Rata compatibilității cu B depinde de întrebările răspunse în comun. Să le spunem întrebărilor comune „s". Într-un exemplu simplu, folosim un set „s" limitat, cu doar două întrebări în comun, după care vom calcula compatibilitatea. Uitați cele două întrebări exemplu. Să zicem că prima e: „Cât de dezordonat sunteți?" iar răspunsurile posibile sunt: foarte dezordonat, acceptabil și foarte organizat. Să zicem că ați răspuns „foarte organizat" și doriți pe altcineva cu același răspuns, iar întrebarea e foarte importantă pentru dumneavoastră. Adică sunteți foarte îngrijit. Sunteți îngrijit, și doriți ca și celălalt să fie așa. Să spunem că B e puțin diferit. Deși a răspuns foarte organizat, „acceptabil” e tot un răspuns bun și întrebarea e puțin relevantă pentru el. să ne uităm la a doua întrebare, cea din exemplul anterior: „Vă place să fiți în centrul atenției?" Răspunsurile pot fi doar da sau nu. Ați răspuns „nu", doriți ca și celălalt să răspundă „nu", iar întrebarea e doar puțin importantă. B a răspuns „da", vrea ca celălalt să răspundă „nu", astfel ca el să fie în centrul atenției, iar întrebarea e destul de importantă pentru el. Să calculăm toate acestea. Primul pas este, devreme ce folosim calculatoare, să atribuim valori numerice ideilor ca „destul de important" și „foarte important", deoarece calculatoarele pot procesa doar cifre. Aici, la OK Cupid, am ales următoarea scală: „irelevant" are valoarea 0, „puțin important" valorează 1, „destul de important" valorează 10, „foarte important" înseamnă 50 și „obligatoriu" 250. Apoi, algoritmul efectuează două operații simple. Prima calculează în ce măsură v-a mulțumit răspunsul lui B, adică, numărul posibil de puncte obținut de B pe scala dumneavoastră. Ați menționat că răspunsul dat de B la prima întrebare legată de dezordine contează foarte mult. Valorează deci 50 de puncte și B a răspuns corect. A doua întrebare valorează doar 1, fiind puțin importantă, iar B a răspuns greșit. Deci răspunsurile lui B valorează 50 de puncte din 51. Sau satisfacție de 98%. Destul de bine. A doua întrebare verificată de algoritm e cât de mult l-ați mulțumit pe B. Pentru B răspunsul la prima întrebare valorează un punct și 10 la cea de-a doua. Din cele 11 puncte, adică 1 plus 10, ați obținut 10, mulțumindu-vă reciproc la a doua întrebare. Răspunsurile date au obținut 10 din 11, adică 91% satisfacție pentru B. Nu e deloc rău. La urmă se obține un singur număr pentru ambii parteneri din cele două procentaje. Pentru asta, algoritmul vă înmulțește scorurile, apoi extrage un radical de ordin n, unde n înseamnă numărul întrebărilor. Deoarece s, sau numărul întrebărilor, din acest exemplu e doar 2, scorul final va însemna rădăcina pătrată din 98% înmulțit cu 91%. Adică 94%. Acel 94% semnifică compatibilitatea cu B. Sau expresia matematică a fericirii determinată de ceea ce cunoaștem deja. De ce folosim înmulțirea și nu extragem radical din media celor două punctaje? Formula se numește medie geometrică, un mod bun de a combina valori numerice extinse reprezentând proprietăți diferite. Ideală pentru compatibilitatea romantică. Aveți mulțimi variate și tone de informații despre filme, politică, religie, practic despre orice. Acest lucru se înțelege chiar și intuitiv. Când doi oameni se satisfac 50%, aceștia ar face un cuplu mai bun decât doi oameni ce se satisfac în materie de 0, respectiv 100%, fiindca iubirea trebuie împărtășită. Mai adăugăm o mică corecție marginii de eroare, dacă avem, să zicem, un număr mic de întrebări, ca în exemplu, și suntem practic gata. Atunci când OK Cupid combină doi oameni, se urmează pașii menționați. Întâi se adună informația din răspunsurile date, apoi vi se compară alegerile și preferințele cu cele ale altora, prin procese matematice simple. Abilitatea de a transforma date reale în ceva ce poate fi utilizat de un microcip este, cred eu, cea mai importantă aptitudine a cuiva în ziua de azi. Așa cum folosiți fraze pentru a relata ceva, folosiți algoritmi pentru a povesti ceva unui computer. Învățând limbajul, vă puteți împărtăși poveștile. Sper ca asta să vă fie de ajutor.