Skip to content

Instantly share code, notes, and snippets.

def printConfusionMatrix(labelAndPred: List[(Int,Int)]) = {
// labelAndPred
println(" " + (0 until classCount).mkString(" ") + " <- predicted ")
println((0 until 2*classCount).map(x => "--").mkString)
for(i <- 0 until classCount) {
for(j <- 0 until classCount) {
// i is actual
// j is classified as
print(" " + labelAndPred.count{ case (label,pred) => label == i && pred == j })
}
package experiments.old
import org.apache.spark.mllib.classification.NaiveBayesModel
import org.apache.spark.mllib.evaluation.BinaryClassificationMetrics
import org.apache.spark.mllib.linalg.Vector
import org.apache.spark.mllib.regression.LabeledPoint
import org.apache.spark.rdd.RDD
import org.apache.spark.mllib.linalg.Vectors
import scala.collection.mutable.ArrayBuffer
@jdeloach
jdeloach / PathToContentURI.java
Created July 24, 2012 21:22
File Path to Android Content URI, credit to http://stackoverflow.com/a/11603841/1079757. Some modifications to use as an image and more polished this way. Took forever to find. Useful for working with the Android Gallery App
/**
* Returns the Uri which can be used to delete/work with images in the photo gallery.
* @param filePath Path to IMAGE on SD card
* @return Uri in the format of... content://media/external/images/media/[NUMBER]
*/
private Uri getUriFromPath(String filePath) {
long photoId;
Uri photoUri = MediaStore.Images.Media.getContentUri("external");
String[] projection = {MediaStore.Images.ImageColumns._ID};
@jdeloach
jdeloach / twitterParser.php
Created May 16, 2012 02:30
Twitter Archiver Script
<?php
/**
* Simple, not the prettiest method to get your latest 3200 tweets (Twitter imposed limit). Thrown together in 20 minutes, not expected to be the greatest.
* Author: Jordan DeLoach (Twitter: @jtmcgee Github: @jdeloach Web: jordandeloach.com)
*
* Step One (insert your username):
* curl -s --user-agent 'Mozilla' --insecure 'https://twitter.com/statuses/user_timeline/YOUR_USERNAME_HERE.xml?count=100&page=[1-32]' >> tweets.txt
*
* Step Two: