This page provides a walkthrough of a simple machine learning situation, and is intended to demonstrate a typical machine learning architecture.

Before you start

Go to the Download and Setup page and follow the instructions to get the RAPID-MIX API. The code discussed on this page is the example called HelloRapidMix, in the /examples folder.

What we’re doing

It is possible to think of a machine learning algorithm like any other algorithm or transfer function — the user provides an input, the algorithm is applied, and a specific output is returned. For this example, we are going to try to make a machine learning algorithm, or model, that takes MIDI note numbers as input, and outputs the frequency in Hertz that corresponds with that note. That formula can be expressed mathematically like this:

{\displaystyle f=2^{(d-69)/12}\cdot 440\ \mathrm {Hz} \,}

d is the MIDI note number and f is the output frequency. We don’t really need machine learning to do this conversion. Rather, we’re looking at a familiar case and seeing if and how we can reproduce it in a new way.

Choose your machine learning

The RAPID-MIX API gives users access to many machine learning algorithms that fit different use cases. For this case, we want a static algorithm. (Terms in bold are also defined on the General Concepts page.) We’re choosing static because we are just looking at individual MIDI note numbers; the concept of time is not involved. If we were looking at a melody with rhythm, we would prefer a temporal algorithm.

Classification algorithms identify data by discrete label — this is a circle, that is a square, etc. We might use one to identify pitch class. But in this case, we want a continuous range of frequencies, including values between or outside of examples we might provide. For that, we want regression.

The simplest static regression object can be created like this:

You need to include the rapidmix header, and create a a staticRegression object in the rapidmix namespace.

Training Data

The other object that this application requires is a place to store examples, or training data, that the machine learning algorithm can use to train. There is one training data class that works with any algorithm. It can be instantiated like this:

 This new trainingData object has some complexity, because it can handle both temporal and static data. But, we can ignore the temporal features for now and use it simply.

Adding elements

An element, or example, is a data point that contains a specific output associated with a specific input. When we train, we are tell the algorithm that “When I send in this input, I want to get back this output.” Both inputs and outputs can be single values or multiple values. In practice, we can send algorithms input values that are not in the training data and expect (or hope) to get a reasonable output.

We can add an element to our Training Data Set like this: