Created
February 4, 2014 03:30
-
-
Save earino/8797738 to your computer and use it in GitHub Desktop.
Logistic Regression Example from http://spark.incubator.apache.org/examples.html
This file contains hidden or 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
points = spark.textFile(...).map(parsePoint).cache() | |
w = numpy.random.ranf(size = D) # current separating plane | |
for i in range(ITERATIONS): | |
gradient = points.map( | |
lambda p: (1 / (1 + exp(-p.y*(w.dot(p.x)))) - 1) * p.y * p.x | |
).reduce(lambda a, b: a + b) | |
w -= gradient | |
print "Final separating plane: %s" % w |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment