プリンキピア

第3章データ構造とアルゴリズム

INDUSTRY SPOTLIGHT産業の現場から
Machine Learning Algorithms機械学習アルゴリズム
A machine learning algorithm addresses these kinds of problems by using an alternative model of computation, one that focuses on generalized algorithms designed to solve problems with a massive model of the underlying phenomena. Instead of attempting to identify a few key variables for facial recognition, for instance, machine learning algorithms can take as input a digital image represented as a rectangular grid of colored pixels. While each pixel in the image offers very little information about the person in mind, the facial features unique to each human arise from the arrangements and patterns of pixels that result from seeing many images of the same person.
英語のヒント
機械学習アルゴリズムは、別の計算モデルを使って、この種の問題に取り組む。これは、背後の現象を大規模に表したモデルを使って問題を解くように設計された、汎用的なアルゴリズムを中心とする計算モデルである。たとえば顔認識では、少数の重要な変数を特定しようとする代わりに、色付きの画素を長方形の格子状に並べて表したデジタル画像を、機械学習アルゴリズムの入力にできる。画像の各画素が、対象の人物について与える情報はわずかだが、同じ人の多くの画像を見ることから得られる画素の配置やパターンによって、その人固有の顔の特徴が現れる。
Think about the way your Apple iPhone or Google Pixel phone may look at you when you try to access it and have facial recognition enabled. The algorithm is not going to try to match your face to a saved picture of you because it would not work all the time if you do not look exactly like you did in the picture. Rather, it uses machine learning to extract patterns out of a person's face and match them, making it possible to recognize people all the time even if they are wearing glasses but was not wearing them when they set up facial recognition on their phone. This method does seem to mimic the way humans recognize people, even if they have not seen them for decades.
英語のヒント
AppleのiPhoneやGoogle Pixelで顔認識を有効にしていると、端末を使おうとしたときに顔が読み取られる。その仕組みを考えてみよう。アルゴリズムは、保存された本人の写真と今の顔を単純に照合しようとはしない。写真のときとまったく同じ見た目でなければ、いつも成功するとは限らないからである。代わりに、機械学習で人の顔からパターンを取り出して照合する。これにより、スマートフォンで顔認識を設定したときには眼鏡をかけていなかった人が、今は眼鏡をかけていても、いつでも認識できるようになる。この方法は、何十年も会っていない人でも見分けられる、人間の認識の仕方に確かに似ている。
Machine learning algorithms offer a more robust approach to modeling these kinds of problems that are not easily expressed in formal logic. But in this chapter, we focus on the earlier, classical perspective on algorithmic problem-solving with the end goal of designing specialized algorithms to solve problems with modest models of the underlying phenomena.
英語のヒント
機械学習アルゴリズムは、形式論理では表しにくいこの種の問題をモデル化するための、より頑健な方法を提供する。しかし、本章では、それ以前の古典的なアルゴリズムによる問題解決の見方に注目する。最終的な目標は、背後の現象を比較的小規模に表したモデルを使って問題を解く、特化したアルゴリズムを設計することである。
Search Algorithms探索アルゴリズム
In computer science, searching is the problem of retrieving a target element from a collection that contains many elements. There are many ways to understand search algorithms; depending on the exact context of the problem and the input data, the expected output might differ. For example, suppose we want to find the target term in a dictionary that contains thousands or millions of terms and their associated definitions. If we represent this dictionary as a list, the search algorithm would return the index of the term in the dictionary. If we represent this dictionary as a set, the search algorithm would return whether the target is in the dictionary. If we represent this dictionary as a map, the search algorithm would return the definition associated with the term. The dictionary data structure has implications on the output of the search algorithm. Algorithmic problem-solving tends to be iterative because we might sometime later realize that our data structures need to change. Changing the data structures, in turn, often also requires changing the algorithm design.
英語のヒント
コンピューターサイエンスにおける探索は、多数の要素を含む集まりから、目的の要素を取得する問題である。探索アルゴリズムの捉え方は多様で、問題の具体的な状況や入力データによって、期待される出力が異なることがある。たとえば、数千から数百万の語と、それに対応する定義を含む辞書から、目的の語を見つけたいとしよう。この辞書をリストとして表せば、探索アルゴリズムは辞書内の語のインデックスを返す。集合として表せば、目的の語が辞書に含まれるかどうかを返す。マップとして表せば、その語に対応する定義を返す。辞書のデータ構造は、探索アルゴリズムの出力に影響する。アルゴリズムによる問題解決は、繰り返し検討する過程になりやすい。後になって、データ構造を変える必要に気付くことがあるからである。データ構造を変更すると、それに伴ってアルゴリズムの設計も変更する必要が生じることが多い。
Despite these differences in output, the underlying canonical searching algorithm can still follow the same general procedure. The two most well-known canonical searching algorithms are known as sequential search and binary search, which are conducted on linear data structures, such as array lists.
英語のヒント
このように出力に違いがあっても、基礎となる標準的な探索アルゴリズムは、同じ一般的な手順に従うことができる。最もよく知られている2つの標準的な探索アルゴリズムは、逐次探索と二分探索と呼ばれ、配列リストなどの線形データ構造に対して行われる。
• Sequential search (Figure 3.9). Open the dictionary to the first term. If that term happens to be the target, then great—we have found the target. If not, then repeat the process by reading the next term in the dictionary until we have checked all the terms in the dictionary.
英語のヒント
・逐次探索(図3.9)。辞書の最初の語を開く。その語が偶然、目的の語なら、それでよい。目的の語が見つかったことになる。そうでなければ、辞書の次の語を読み、辞書内のすべての語を確認し終えるまで、この過程を繰り返す。
• Binary search (Figure 3.10). Open the dictionary to a term in the middle of the dictionary. If that term happens to be the target, then great—we have found the target. If not, then determine whether the target comes before or after the term we just checked. If it comes before, then repeat the process except on the first half of the dictionary. Otherwise, repeat the process on the second half of the dictionary. Each time, we can ignore half of the remaining terms based on the place where we would expect to find the target in the dictionary.
英語のヒント
・二分探索(図3.10)。辞書の中央にある語を開く。その語が偶然、目的の語なら、それでよい。目的の語が見つかったことになる。そうでなければ、目的の語が今確認した語よりも前に来るか、後に来るかを判断する。前に来るなら、今度は辞書の前半だけを対象に、同じ過程を繰り返す。そうでなければ後半で繰り返す。毎回、目的の語が辞書のどこにあると予想されるかに基づき、残っている語の半分を無視できる。
Figure 3.9

attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license · CC BY 4.0 · Source出典

Figure 3.9 A sequential search can find the number 47 in an array by checking each number in order. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)
図3.9 逐次探索は、数を1つずつ順に確認することで、配列内の数47を見つけることができる。(出典表記:著作権者 Rice University、OpenStax、CC BY 4.0ライセンス)
Figure 3.10

attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license · CC BY 4.0 · Source出典

Figure 3.10 A binary search can find the number 47 in an array by determining whether the desired number comes before or after a chosen number. It eliminates half of existing data points and then searches in the remaining half, repeating the pattern, until the number is found. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)
図3.10 二分探索は、目的の数が、選んだ数より前にあるか後にあるかを判断して、配列内の数47を見つけることができる。対象のデータ点の半分を除外して残り半分を探す。このパターンを、数が見つかるまで繰り返す。(出典表記:著作権者 Rice University、OpenStax、CC BY 4.0ライセンス)