JavaRDD<MatrixEntry> entries = ata.toCoordinateMatrix().entries().toJavaRDD(); JavaRDD<String> output = entries.map(new Function<MatrixEntry, String>() { public String call(MatrixEntry e) { return String.format("%d,%d,%s", e.i(), e.j(), e.value()); } }); output.saveAsTextFile("data/output1");
Double rowSum = rowSums.get(entry.row()); rowSums.put(entry.row(), (rowSum == null) ? entry.value() : rowSum + entry.value()); Double rowSumDouble = rowSums.get(entry.row()); double rowSum = (rowSumDouble == null) ? 0 : rowSumDouble; double probability = entry.value() / rowSum; rowEntropy[entry.row()] += probability * log2(probability);
Double rowSum = rowSums.get(entry.row()); rowSums.put(entry.row(), (rowSum == null) ? entry.value() : rowSum + entry.value()); Double rowSumDouble = rowSums.get(entry.row()); double rowSum = (rowSumDouble == null) ? 0 : rowSumDouble; double probability = entry.value() / rowSum; rowEntropy[entry.row()] += probability * log2(probability);
if (entry.value() == 0d) continue; double rowDelta = (countRowOccurrances) ? 1 : entry.value(); rowCountMap.put(entry.row(), (occurance == null) ? rowDelta double columnDelta = (countColumnOccurrances) ? 1 : entry.value(); colCountMap.put(entry.column(), (occurance == null) ? columnDelta : occurance + columnDelta); matrixSum += entry.value();
if (entry.value() == 0d) continue; double rowDelta = (countRowOccurrances) ? 1 : entry.value(); rowCountMap.put(entry.row(), (occurance == null) ? rowDelta double columnDelta = (countColumnOccurrances) ? 1 : entry.value(); colCountMap.put(entry.column(), (occurance == null) ? columnDelta : occurance + columnDelta); matrixSum += entry.value();