April 2017
Intermediate to advanced
532 pages
12h 39m
English
We ran custom logic to reduce the number of features to two, so that we can visualize the dataset in a two-dimensional plane, keeping the lines in the dataset constant.
{ val sc = new SparkContext("local[1]", "Classification") // get StumbleUpon dataset 'https://www.kaggle.com/c/stumbleupon' val records = sc.textFile( SparkConstants.PATH + "data/train_noheader.tsv").map( line => line.split("\t")) val data_persistent = records.map { r => val trimmed = r.map(_.replaceAll("\"", "")) val label = trimmed(r.size - 1).toInt val features = trimmed.slice(4, r.size - 1).map( d => if (d == "?") 0.0 else d.toDouble) val len = features.size.toInt val len_2 = math.floor(len/2).toInt val x = features.slice(0,len_2) ...Read now
Unlock full access