-
Create a new Predictive Service
Be sure to give it a unique S3 state path. Pass in values for previous API keys and admin keys to the create method. And set the number of hosts as desired.
import graphlab as gl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def time[R](block: => R): R = { | |
val t0 = System.nanoTime() | |
val result = block // call-by-name | |
val t1 = System.nanoTime / 1.0e9 // seconds | |
println("Elapsed time: " + (t1 - t0) + "s") | |
result | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [48]: m = gl.logistic_classifier.create(data, target="rating") | |
PROGRESS: Logistic regression: | |
-------------------------------------------------------- | |
Number of examples : 5 (2 positives, 3 negatives) | |
Number of feature columns : 2 | |
Number of unpacked features : 2 | |
PROGRESS: Number of coefficients : 3 | |
PROGRESS: Starting Newton Method | |
-------------------------------------------------------- | |
PROGRESS: Iter Grad-Norm Loss Step size Elapsed time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <graphlab/sdk/toolkit_function_macros.hpp> | |
#include <graphlab/sdk/gl_sarray.hpp> | |
#include <cmath> | |
using namespace graphlab; | |
gl_sarray bigram_pmi(long total_count, gl_sarray x, gl_sarray y, gl_sarray xy) { | |
// assert same lengths | |
assert(x.size() == y.size() && y.size() == xy.size()); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <graphlab/sdk/toolkit_function_macros.hpp> | |
#include <graphlab/sdk/gl_sarray.hpp> | |
#include <cmath> | |
using namespace graphlab; | |
gl_sarray bigram_pmi(long total_count, gl_sarray x, gl_sarray y, gl_sarray xy) { | |
// assert same lengths | |
assert(x.size() == y.size() && y.size() == xy.size()); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
domain | query | count | |
---|---|---|---|
data.nola.gov | city council members | 1 | |
data.nola.gov | parcels | 6 | |
data.nola.gov | vacant lots | 8 | |
data.nola.gov | permits | 108 | |
data.nola.gov | hospitals | 1 | |
data.nola.gov | schools | 4 | |
data.nola.gov | grocery | 4 | |
data.nola.gov | mayor office contact information | 6 | |
data.nola.gov | green space | 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query | domain | diff | |
---|---|---|---|
homeless | data.cityofnewyork.us | 0.368034002369 | |
housing | data.kcmo.org | -0.349383730996 | |
2006 | data.kcmo.org | -0.310913691903 | |
business | data.ny.gov | 0.242477991954 | |
santa monica renters rights | data.smgov.net | -0.218647589981 | |
champaign | data.illinois.gov | -0.215919011572 | |
parking | data.kcmo.org | -0.158675636039 | |
office of engineering and construction | data.baltimorecity.gov | -0.141422934483 | |
public safety | data.raleighnc.gov | 0.135683158642 |