Mathematica 10における
機械学習

PredictとClassify

Wolfram Research
Etienne Bernard
training@wolfram.com

画像の認識

-> “cat”,   -> “dog”, ...

テキストの分類

特徴の集合から変数を予測...

自動の事前処理

メソッドの自動選択

パラメータの自動選択

Classifyを使った基本的な例

c=Classify[{1.->"A", 2.->"A", 3.2->"B", 4.->"B"}]

c[1.5]

Predictを使った基本的な例

p=Predict[{1.->1.5, 2.->1.8, 3.->2.4, 4.5->2.9}]

p[1.5]

タイタニック号の乗客の生存確率

titanicdata = ExampleData[{"MachineLearning","Titanic"},"TrainingData"];

RandomSample[titanicdata,10]

survival= Classify[titanicdata, Method->"LogisticRegression"]

survival[{"2nd",28.`,"male"}]

survival[{"2nd",28.`,"male"}, "Probabilities"]

proba[class_,age_,sex_]:=survival[{class,age,sex},{"Probability","survived"}];
Plot[{proba["1st",x,"female"],proba["3rd",x,"female"],proba["1st",x,"male"],proba["3rd",x,"male"]}, {x,0,100},PlotLegends->{"female, 1st class", "female, 3rd class", "male, 1st class", "male, 3rd class"}, Frame->True,FrameLabel-> {"Age (years)", "Survival probability"}]

手書きの数字の認識

digitdata = ExampleData[{"MachineLearning","MNIST"},"TrainingData"];

RandomSample[digitdata,20]

digit = Classify[RandomSample[digitdata,10000], PerformanceGoal->"TrainingSpeed"]

digittestdata = ExampleData[{"MachineLearning","MNIST"},"TestData"];

RandomSample[digittestdata,10]

digit[]

cm = ClassifierMeasurements[digit, digittestdata]

cm["Accuracy"]

cm["ConfusionMatrixPlot"]

cm[{"Examples", 5->6}]

基本的なテキストの例

catordog=Classify[{"the cat is grey"->,"my cat is fast"->,"this dog is scary"-> ,"the big dog"->}]

catordog[{"nice cat","what a dog"}]

ゲージ値の予測器

gaugeset=Image[AngularGauge[#]]->#&/@RandomReal[1,100];

RandomSample[gaugeset,5]

gaugevalue=Predict[gaugeset]

gaugevalue[]

gaugevalue[, "Distribution"]

DynamicModule[{x=0},Row[{AngularGauge[Dynamic[x]],Dynamic[gaugevalue[Image[AngularGauge[x]]]]}]]

Language（言語）

Classify["Language", "what is this language?"]

Classify["Language", {"the house is blue", "la maison est bleu", "la casa es azul", "das Haus ist blau", "房子是蓝色的", "المنزل باللون الأزرق", "будинок синій"}]

DynamicModule[{text = "" },Column[{InputField[Dynamic[text], String, ContinuousAction-> True, FieldHint->"Enter a string"],
Dynamic[Classify["Language",text, "TopProbabilities"]]}
]
]

FacebookTopic（Facebookのトピック）

Classify["FacebookTopic", {"I love carrots!", "I bought a new computer.", "Happy birthday!", "This skirt looks nice."}]

NameAge（名前と年齢）

Predict["NameAge", {"Tom", "Stacy", "Claire"}]

distribution = Predict["NameAge", "Claire", "Distribution"]

Plot[PDF[distribution,x],{x,0,100},Exclusions->None,Frame->True, Filling->Bottom, PlotLabel->"Age distributions of persons named Claire", FrameLabel->{"Age", "Probability density"}]

Sentiment（感情）

Classify["Sentiment",{"I love this movie","so depressed today","My phone broke again"}]

CountryFlag（各国の旗）

Classify["CountryFlag", {, , }]

http://reference.wolfram.com/language/ref/Classify.html

http://reference.wolfram.com/language/ref/Predict.html

http://reference.wolfram.com/language/guide/MachineLearning.html

http://www.wolfram.com/mathematica/new-in-10/highly-automated-machine-learning/

http://www.wolfram.com/mathematica/new-in-10/built-in-classifier-collection/

http://blog.wolfram.com/2014/06/20/predicting-who-will-win-the-world-cup-with-wolfram-language/