Predictions

Home / Predictions
In this Chapter we will create an application which predicts the chance the visitor will perform a conversion. For this application we will use MOA and the naïve Bayes classification algorithm. More details on MOA can be found at http://en.wikipedia.org/wiki/Massive_Online_Analysis.

Copy the following code to the sandbox

concept all { 
 	match '*'

  	const features = `{
    	title:['title A','title B'],
    	section:['section C', 'section D', 'section E'],
    	conversion:['0','1']
  	}`

  	val title= 'titel B'
  	val section= 'section C'
  	val conversion = '0'

 	flow
   => filter['title:string','section:string','conversion:number']
   => moa:naivebayes[model = `features`, class = 'conversion']

  	flow
   => code[orgConversion = `conversion`@groovy, conversion = `1`@groovy]
   => moa:classify[model = `features`]
   => debug

  	plugin debug
}
The constant features contains all parameters and possible values the model can use. The 3 vals contain actual values for the parameter for the current page. The first flow contains the actual training of the model which start with defining the types of each parameter. The second flow results in the parameter conversion containing the predicted conversion chance. In order to do this, the parameter needs to be set to 1 (which will be replace with the actual conversion chance).

  1. Publish the file and open several pages. Update the title, section and conversion to other values and open several pages. Check the console to see the parameters. Note that if you leave conversion to 1 and refresh the page, the conversion chance will increase, while if you leave it 0, the chance will decrease
  1. Update the vals to actually dynamically generate a values. Note that you have to make sure only a fixed number of values is possible, which you define in the const
  1. Chance the second flow such that an additional parameter is available containing “yes” or “no” based on the conversion prediction being higher or lower than 0.5.