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.
こんにちは クリスチャン・ラダーです 私たちが始めた OkCupidは 現在アメリカで 最大手の出会いサイトです 他のスタッフの 多くと同様 私も数学専攻で 私たちは恋愛への 分析的アプローチで 知られています 私たちは マッチング・アルゴリズムと 呼んでいますが これは 2人の人が デートすべきかの判断を 助けるものです これが私たちの事業の 中心にあるものです アルゴリズムというと 何かかっこよくて みんな何かすごいもののように 口にしますが 実際のところは 段階を追って問題を 機械で解く手順ということで 別にすごいものとは 限りません このビデオでは 私たちのアルゴリズムが どのようにできているのかを 説明します アルゴリズムは なぜ重要なのか? そもそもこのビデオは なぜ存在するのか? 注意して欲しいのは 私が 「段階を追って解く」 と言ったことです コンピュータが 段階を追った処理に向いているのは 知っていると思います アルゴリズムがなければ コンピュータは高価な 漬け物石に過ぎません コンピュータは 身の回りの至る所にあり それはすなわちアルゴリズムが どこにでもあるということです OKCupidの 背後にある数学は ごく簡単なものです 足し算 掛け算 それにルートを 少し使うくらいです このアルゴリズムの設計で 難しいのは 人が惹かれ合うという 不可解な現象を 要素に分解し 機械で 扱えるようにすることです 人のマッチングをする上で まず必要なのは アルゴリズムが使うための データです 人からデータを手早く得る 最良の方法は 単に聞いてみることです それで OkCupidでは ユーザーに質問することにしました 「いつか子供が欲しいですか?」 「歯磨きを日に何度しますか?」 「怖い映画は好きですか?」 それに「神を信じますか」のような 大きな質問もあります 多くの質問は 2人が同じような 答えをする時 相性が良いと 考えられます 例えば 2人がどちらも 怖い映画が好きな場合 1人は好きで もう1人は嫌い という場合よりも おそらく相性が 良いでしょう しかし もし質問が 「場の中心になるのが好きですか?」 ならどうでしょう? 付き合っている2人が どちらも中心にいたいタイプだと 大きな問題がありそうです それで私たちは それぞれの質問に対して もう少しデータを 取ることにしました 自分自身についての 答えだけでなく 相手に望む答えも 聞くことにしたんです これはうまくいきましたが さらにもう1つの要素が 必要でした ある種の質問は 他の質問よりも 多くのことを教えてくれるからです たとえば政治的な質問である 「本を燃やすのと国旗を燃やすのとでは どちらがより悪いか?」のような質問は 映画の好みなどより 重要な意味を持つかもしれません あらゆる質問を 同様に扱うのは問題があるので もう1つデータを 付け加えました OkCupidが聞く質問ではすべて 自分にとっての重要性を 「どちらでもよい」から「必須」まで 指定することができます これで各質問について アルゴリズムに使えるものが 3つあることになります 1 自分の答え 2 付き合う相手に望む答え 2 付き合う相手に望む答え 2 付き合う相手に望む答え 3 その質問の重要度です これらの情報を元に OKCupidは2人の 相性の良さを判断でき アルゴリズムが データから答えを算出します 具体的な例で あなたと 別の誰かBさんの 相性が良いかを どのように判断するのか 見てみましょう 相性度は 2人とも答えた 質問を元に求めます この共通の質問の集まりを Sと呼ぶことにしましょう 話を簡単にするため Sはたった2つの 質問からなることにして それを元に相性度を 計算してみます その2つの質問の 1つは たとえば「散らかし屋さんですか?」で 答えの選択肢は 「散らかし屋」 「ふつう」 「きれい好き」 だったとします あなたは「きれい好き」で 相手にも「きれい好き」 であることを望み この問題はとても重要 だったとしましょう あなたは超きれい好きで 自分だけでなく 相手にも きれい好きなことを 強く求めています Bさんは少し違います 彼自身は「きれい好き」ですが 相手は「ふつう」でかまわず 相手は「ふつう」でかまわず 彼にとって この問題は あまり重要ではありません 2番目の質問に 移りましょう 前に質問例として挙げた 「場の中心になるのが好きですか?」で 選択肢は「はい」か「いいえ」です あなたの答えは「いいえ」で 相手にも「いいえ」であることを望み この問題はあまり 重要でなかったとします Bさんの方は 自分が「はい」で 相手には「いいえ」を望み — なにしろ自分が中心でいたいので — そして この問題は彼にとって まあまあ重要だったとします それでは計算してみましょう まずはじめに コンピュータを使うので 「まあまあ重要」とか 「とても重要」のような概念に 数値を割り当てる 必要があります コンピュータはすべて 数字で計算するからです OkCupidではこんな重み付けを することにしました 「どうでもよい」は 0点 「あまり重要でない」は 1点 「まあまあ重要」は 10点 「とても重要」は 50点 「必須」は 250点です つぎにアルゴリズムは 簡単な計算を2つします 1つはBさんが あなたにとって どれくらい満足のいく人かで これはBさんが取り得る点数のうちの 何点を取ったかということです 最初の質問 散らかし屋かどうかは あなたにとって とても重要で Bさんは正しく答えたので 50点になります 2番目の質問は あまり重要でなかったので 1点分の価値しかなく Bさんは間違った 答えをしました だからBさんの点数は 50/51となり 98%の満足度です これはかなり良い点数です 次にアルゴリズムが見るのは あなたが どれくらいBさんを 満足させるかということです Bさんは散らかし屋の 質問には1点 Bさんは散らかし屋の 質問には1点 場の中心の質問には 10点を設定しました 満点は 1 + 10 = 11 点で あなたは2番目の質問で 希望に合っていたので 10点を取りました あなたの点数は10/11で Bさんにとっての 満足度は91%です 悪くありません 最後のステップとして この2つのパーセントの数字から 2人の相性度を計算します アルゴリズムは 2つの値を掛け合わせて n 乗根を求めます ここで n は質問の個数です 今の場合 質問の数は 2つだけだったので 相性度は 98% × 91% の 2 乗根で — 相性度は 98% × 91% の 2 乗根で — 94% となります 94% があなたと Bさんの相性度です あなた方が付き合った時に 予想される幸福度を 得られているデータを元に 数学的に求めた値です なぜこのアルゴリズムでは 2つの点数の平均を取らずに 掛け算して累乗根を 求めているのか? 一般にこのような式は 幾何平均と呼ばれ 広い幅のある 異なる性質の値を 組み合わせる 優れた方法なんです つまり恋愛の相性には ぴったりということです 広い範囲の たくさんの異なる データがあります 映画だとか 政治 宗教 その他あらゆることです 直感的にも これは 意味のあることです 互いに50%の満足度の2人は 0%と100%の2人よりも 相性が良いと言えるでしょう 恋愛は相互的である 必要があるからです 誤差に対応するために 若干の補正をすれば完了です たとえば今の場合だと 質問の数が少なすぎる という問題がありました OkCupidが 2人を引き合わせる場合 今説明したような 手順を辿ります まずみんなの答えを データとして集め 本人の選択と 相手への希望を 単純な数学的方法で 付き合わせていくんです この 現実の世界の現象を マイクロチップが理解できる形に 変える能力は 今の時代 最も重要なスキルだと思います 人に対して文章を使って 物語るように コンピュータに対しては アルゴリズムを使って物語るのです 言語を学べば 物語を語れるようになります このビデオが その役に立てば幸いです