Wolfram Language

Optimize Code with ActiveClassification

Considering two programs implementing the same function, construct a classifier able to predict which program is the fastest for a given input. The classifier has access to features of the program input (matrix sizes here), and is obtained using ActiveClassification, a function to learn from a "teacher" (a benchmarking function here) instead of a labeled dataset.

Consider two implementations of the same function.

In[1]:=1
In[2]:=2
In[3]:=3
Out[3]=3
In[4]:=4
Out[4]=4

Create an input sampler and benchmarking function.

In[5]:=5
In[6]:=6
In[7]:=7
Out[7]=7
In[8]:=8
Out[8]=8

Create a logistic classifier that imitates the benchmarking function.

In[9]:=9
Out[9]=9

Extract the classifier and analyze its performances.

In[10]:=10
Out[10]=10
In[11]:=11
Out[11]=11

Use the classifier to create an optimized function.

In[12]:=12
In[13]:=13
Out[13]=13

Obtain a simple function from the classifier to simplify the optimized function.

In[14]:=14
Out[14]=14
In[15]:=15

Related Examples

Find out if you already have access to Wolfram tech through your organization
×