Last active
December 27, 2015 22:29
-
-
Save alienrobotwizard/7399003 to your computer and use it in GitHub Desktop.
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
%default STEPSIZE 0.1 | |
import 'macros/linear_model.pig'; | |
data = load '$data' as (x:double, y:double); | |
-- | |
-- The weights are given a schema file by the python driver script | |
-- to avoid having to manually specify and arbitrarily large schema | |
-- with identical column schemas | |
-- | |
weights = load '$input_weights' using PigStorage('\t', '-schema'); | |
features = foreach data generate y as response, TOTUPLE(1.0,x) as vector; | |
weights = foreach weights generate TOTUPLE(w0,w1) as weights; | |
new_weights = sounder_lm_gradient_descent(features, weights, $STEPSIZE); | |
new_weights = foreach new_weights generate flatten($0); | |
-- | |
-- Store weights in the same way they were came in. The | |
-- python driver copies the input weights schema to the output | |
-- dir (since it's the same). The reason for this is to avoid | |
-- having to manually specify an as clause, in the project | |
-- expression above, with over 100 fields. | |
-- | |
store new_weights into '$output_weights'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment