Hands-on with Machine Learning

Etienne Bernard & Piyush Kumar, Wolfram Research

Join the Conversation #WolframTechConf

High-level Machine Learning in the WL

URLShorten["https://www.dropbox.com/s/nhub5dcq9krgko3/2016_WTC_Workshop.nb?dl=1"]

Supervised Learning

Classify **

Predict **

FindFormula

Unsupervised Learning

DimensionReduction **

FeatureExtraction **

ClusterClassify **

ClusteringTree

FindDistribution

“Active” Learning

BayesianMinimization **

11.1:

ActiveClassification

ActivePrediction

Wikipedia topics

Create a classifier to identify the topic of a Wikipedia snippet

topics={"Science","Sports","Politics","Music"}

Image classification

Use BingSearch to download images from the web:

ServiceConnect["BingSearch"]

queries={};

images=ServiceExecute["BingSearch","Search",{"Query"->#,"SearchType"->"Images","MaxItems"->60,"Elements"->"Thumbnails"}] & /@ queries;

Label the images:

labeledimages=RandomSample[DeleteDuplicates[Flatten[Thread /@ Thread[images->queries]]]];

Create a classifier and test its performance

Dataset Visualization

Extract feature-vectors from a set of images:

Reduce the dimension of the feature-vectors to 2:

xy=

Visualize the resulting feature-vectors using ListPlot:

ListPlot[List/@xy,PlotMarkers->(Image[#,ImageSize->30]& /@ images),ImageSize->1000]

Image-search system

Separate the images into a dataset and queries:

dataset=...
queries=...

Generate a feature extractor using the dataset:

Create a function that, from a new image, outputs the closest image in the dataset in the feature spaces:

Redefining colors

From real images extract a list of their pixel colors

Find a clustering of these colors

Name each cluster and create a color-naming classifier

Optimal Parameters of a Classifier

Load a dataset and split it into a training set and a test set:

data=RandomSample[ExampleData[{"MachineLearning","Titanic"},"Data"]];
training=data[[;;1000]];
test=data[[1001;;]];

Define a function computing the performance of a classifier as a function of its (hyper) parameters:

loss[{c_,gamma_,b_,d_}]:=-ClassifierMeasurements[Classify[training,Method->{"SupportVectorMachine","KernelType"->"Polynomial","SoftMarginParameter"->Exp[c],"GammaScalingParameter"->Exp[gamma],"BiasParameter"->Exp[b],"PolynomialDegree"->d}],test,"LogLikelihoodRate"];

Define the possible value of the parameters using ImplicitRegion:

-3. ≤ c ≤3.

-3. ≤ gamma ≤ 3.

-1. ≤ b ≤ 2.

1 ≤ d ≤ 3 and d ∈ Integers

Search for a good set of parameters using BayesianMinimization:

Train a classifier with these parameters: