Tested with Apache Spark 1.5.1, Python 3.3 and Java 1.8.0_60
Download and install JDK from oracle.com
Tested with Apache Spark 1.5.1, Python 3.3 and Java 1.8.0_60
Download and install JDK from oracle.com
| import numpy as np | |
| from math import exp, log | |
| """ | |
| SGD for logistic loss + factorization machines | |
| The code follows this paper: | |
| [1] http://www.ics.uci.edu/~smyth/courses/cs277/papers/factorization_machines_with_libFM.pdf | |
| """ | |
| def sigmoid(x): |
| frugal <- function(stream) { | |
| m <- 0 | |
| for (val in stream) { | |
| if (val > m) | |
| m = m + 1 | |
| else if (val < m) | |
| m = m - 1 | |
| } | |
| return(m) | |
| } |