etsy / conjecture Goto Github PK
View Code? Open in Web Editor NEWScalable Machine Learning in Scalding
License: MIT License
Scalable Machine Learning in Scalding
License: MIT License
A simple example (in Clojure) showing how the FTRLOptimizer
modifies an instance during an update:
(defn opt [] (doto (FTRLOptimizer.)
(.setBeta (double 0.1))
(.setAlpha (double 0.1))
(.setGaussianRegularizationWeight (double 0.00000001) )
(.setLaplaceRegularizationWeight (double 0.00000001))
(.setExamplesPerEpoch (double 10000.0))
(.setUseExponentialLearningRate false)
(.setExponentialLearningRateBase (double 0.99))
(.setInitialLearningRate (double 0.01) )))
(defn LogRegModel []
(doto (LogisticRegression. (opt))
(.setTruncationPeriod (int Integer/MAX_VALUE))
(.setTruncationThreshold (double 0.0))
(.setTruncationUpdate (double 0.0))))
;; initialize LogisticRegression Model object:
(def m (LogRegModel))
;; a simple BinaryLabeledInstance
(def ex
(BinaryLabeledInstance. (double 1.0) ;; label
(StringKeyedVector. {"height" 5.11 "weight" 165.0}))) ;; features
;; update the model with the example
(doto m (.update ex))
;; the example feature-values have changed!
(.getVector ex)
;; ==> #<StringKeyedVector {"height":-2.555,"weight":-82.5}>
Thanks for the great library. I'm working with ALSjob, but I'm missing a bit of detail on subsequent steps for producing item-item and item-user style recs. Any chance we can get some commenting on the FactorizationTools code if this is what this is? i.e I'd like to compute the outer product of U and V after the ALS job.
I'm not sure if I'm setting the model parameters right, but here's a Clojure example of how after updating the model on just 100 random examples, the coefficients become huge:
;; helper fn to create a BinaryLabeledInstance from a feature->value map
(defn map2labex
"Create a BinaryLabeledInstance from a map and label"
[m lab]
(BinaryLabeledInstance. (double lab)
(StringKeyedVector.
(into {} (for [[k v] m] [k (double v)]) ) )))
(defn rand-labex
"create a vector of n random labeled examples with d numerical features in [0,1]"
[n d]
(let
[num-fields (map #(str "n" %) (range d))
one-ex (fn [] (map2labex (zipmap num-fields (repeatedly d rand))
(if (> 0.5 (rand)) 0 1 )))] ;; random 0/1 label
(repeatedly n one-ex)))
;; create 100 random examples with 3 numerical features in [0,1]
(def examples (rand-labex 100 3))
;; update an initial model with all 100 examples
(def final-model (reduce #(doto %1 (.update %2)) (LogRegModel) examples) )
;; model coefficients are huge:
(-> final-model .getParam .getMap)
;;==> {"n2" 5.381797927731191E49, "n1" -2.010128381640754E45, "n0" 1.2177646948602788E44}
When I do sbt clean assembly
I get this error:
[error] /Users/prasadch/Git/Conjecture/src/main/scala/com/etsy/scalding/jobs/conjecture/NNMFTest.scala:31: value updateGaussianWeighted is not a member of object com.etsy.conjecture.scalding.NNMF
[error] val HW_ = NNMF.updateGaussianWeighted(A, HW._1, HW._2, alpha)
So I deleted the NNMFTest.scala
and it built fine. However now when I try to run the demo (with the proper snapshot version number) I get this error because the gaussianRegularizationWeight
defaults to 0, and that's not valid:
Caused by: java.lang.IllegalArgumentException: gaussian regularization weight must be positive, given: %f [0.0]
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:119)
at com.etsy.conjecture.model.SGDOptimizer.setGaussianRegularizationWeight(SGDOptimizer.java:148)
at com.etsy.conjecture.scalding.train.MulticlassModelTrainer.<init>(MulticlassModelTrainer.scala:144)
at com.etsy.conjecture.demo.LearnMulticlassClassifier.<init>(LearnMulticlassClassifier.scala:27)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.