Skip to content

Instantly share code, notes, and snippets.

@apc3n
apc3n / simulated_hyperplane.R
Created October 30, 2014 19:39
Simulated Hyperplane Dataset
# This code generates the simulated hyperplane dataset used in many stream learning papers. In addition to outputting the dataset itself it also outputs the dimension weights over time. I used these dimension weights as a measure of true feature importance in a paper I discuss here: http://www.ccri.com/2014/10/30/calculating-feature-importance-in-data-streams-with-concept-drift-using-online-random-forest/
drift = function(start, numberToGenerate, magnitudeOfChange, probDirectionChange) {
directions = rep(magnitudeOfChange, numberToGenerate - 1)
for (i in 2:(numberToGenerate-1)) {
if(!(runif(1) >= probDirectionChange)) {
directions[i] = (directions[i-1] * -1)
} else {
directions[i] = (directions[i-1])
}