http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/data/movielens.txt ---------------------------------------------------------------------- diff --git a/examples/experimental/data/movielens.txt b/examples/experimental/data/movielens.txt deleted file mode 100644 index f0eee19..0000000 --- a/examples/experimental/data/movielens.txt +++ /dev/null @@ -1,1501 +0,0 @@ -0::2::3 -0::3::1 -0::5::2 -0::9::4 -0::11::1 -0::12::2 -0::15::1 -0::17::1 -0::19::1 -0::21::1 -0::23::1 -0::26::3 -0::27::1 -0::28::1 -0::29::1 -0::30::1 -0::31::1 -0::34::1 -0::37::1 -0::41::2 -0::44::1 -0::45::2 -0::46::1 -0::47::1 -0::48::1 -0::50::1 -0::51::1 -0::54::1 -0::55::1 -0::59::2 -0::61::2 -0::64::1 -0::67::1 -0::68::1 -0::69::1 -0::71::1 -0::72::1 -0::77::2 -0::79::1 -0::83::1 -0::87::1 -0::89::2 -0::91::3 -0::92::4 -0::94::1 -0::95::2 -0::96::1 -0::98::1 -0::99::1 -1::2::2 -1::3::1 -1::4::2 -1::6::1 -1::9::3 -1::12::1 -1::13::1 -1::14::1 -1::16::1 -1::19::1 -1::21::3 -1::27::1 -1::28::3 -1::33::1 -1::36::2 -1::37::1 -1::40::1 -1::41::2 -1::43::1 -1::44::1 -1::47::1 -1::50::1 -1::54::1 -1::56::2 -1::57::1 -1::58::1 -1::60::1 -1::62::4 -1::63::1 -1::67::1 -1::68::4 -1::70::2 -1::72::1 -1::73::1 -1::74::2 -1::76::1 -1::77::3 -1::78::1 -1::81::1 -1::82::1 -1::85::3 -1::86::2 -1::88::2 -1::91::1 -1::92::2 -1::93::1 -1::94::2 -1::96::1 -1::97::1 -2::4::3 -2::6::1 -2::8::5 -2::9::1 -2::10::1 -2::12::3 -2::13::1 -2::15::2 -2::18::2 -2::19::4 -2::22::1 -2::26::1 -2::28::1 -2::34::4 -2::35::1 -2::37::5 -2::38::1 -2::39::5 -2::40::4 -2::47::1 -2::50::1 -2::52::2 -2::54::1 -2::55::1 -2::57::2 -2::58::2 -2::59::1 -2::61::1 -2::62::1 -2::64::1 -2::65::1 -2::66::3 -2::68::1 -2::71::3 -2::76::1 -2::77::1 -2::78::1 -2::80::1 -2::83::5 -2::85::1 -2::87::2 -2::88::1 -2::89::4 -2::90::1 -2::92::4 -2::93::5 -3::0::1 -3::1::1 -3::2::1 -3::7::3 -3::8::3 -3::9::1 -3::14::1 -3::15::1 -3::16::1 -3::18::4 -3::19::1 -3::24::3 -3::26::1 -3::29::3 -3::33::1 -3::34::3 -3::35::1 -3::36::3 -3::37::1 -3::38::2 -3::43::1 -3::44::1 -3::46::1 -3::47::1 -3::51::5 -3::52::3 -3::56::1 -3::58::1 -3::60::3 -3::62::1 -3::65::2 -3::66::1 -3::67::1 -3::68::2 -3::70::1 -3::72::2 -3::76::3 -3::79::3 -3::80::4 -3::81::1 -3::83::1 -3::84::1 -3::86::1 -3::87::2 -3::88::4 -3::89::1 -3::91::1 -3::94::3 -4::1::1 -4::6::1 -4::8::1 -4::9::1 -4::10::1 -4::11::1 -4::12::1 -4::13::1 -4::14::2 -4::15::1 -4::17::1 -4::20::1 -4::22::1 -4::23::1 -4::24::1 -4::29::4 -4::30::1 -4::31::1 -4::34::1 -4::35::1 -4::36::1 -4::39::2 -4::40::3 -4::41::4 -4::43::2 -4::44::1 -4::45::1 -4::46::1 -4::47::1 -4::49::2 -4::50::1 -4::51::1 -4::52::4 -4::54::1 -4::55::1 -4::60::3 -4::61::1 -4::62::4 -4::63::3 -4::65::1 -4::67::2 -4::69::1 -4::70::4 -4::71::1 -4::73::1 -4::78::1 -4::84::1 -4::85::1 -4::87::3 -4::88::3 -4::89::2 -4::96::1 -4::97::1 -4::98::1 -4::99::1 -5::0::1 -5::1::1 -5::4::1 -5::5::1 -5::8::1 -5::9::3 -5::10::2 -5::13::3 -5::15::1 -5::19::1 -5::20::3 -5::21::2 -5::23::3 -5::27::1 -5::28::1 -5::29::1 -5::31::1 -5::36::3 -5::38::2 -5::39::1 -5::42::1 -5::48::3 -5::49::4 -5::50::3 -5::51::1 -5::52::1 -5::54::1 -5::55::5 -5::56::3 -5::58::1 -5::60::1 -5::61::1 -5::64::3 -5::65::2 -5::68::4 -5::70::1 -5::71::1 -5::72::1 -5::74::1 -5::79::1 -5::81::2 -5::84::1 -5::85::1 -5::86::1 -5::88::1 -5::90::4 -5::91::2 -5::95::2 -5::99::1 -6::0::1 -6::1::1 -6::2::3 -6::5::1 -6::6::1 -6::9::1 -6::10::1 -6::15::2 -6::16::2 -6::17::1 -6::18::1 -6::20::1 -6::21::1 -6::22::1 -6::24::1 -6::25::5 -6::26::1 -6::28::1 -6::30::1 -6::33::1 -6::38::1 -6::39::1 -6::43::4 -6::44::1 -6::45::1 -6::48::1 -6::49::1 -6::50::1 -6::53::1 -6::54::1 -6::55::1 -6::56::1 -6::58::4 -6::59::1 -6::60::1 -6::61::3 -6::63::3 -6::66::1 -6::67::3 -6::68::1 -6::69::1 -6::71::2 -6::73::1 -6::75::1 -6::77::1 -6::79::1 -6::81::1 -6::84::1 -6::85::3 -6::86::1 -6::87::1 -6::88::1 -6::89::1 -6::91::2 -6::94::1 -6::95::2 -6::96::1 -7::1::1 -7::2::2 -7::3::1 -7::4::1 -7::7::1 -7::10::1 -7::11::2 -7::14::2 -7::15::1 -7::16::1 -7::18::1 -7::21::1 -7::22::1 -7::23::1 -7::25::5 -7::26::1 -7::29::4 -7::30::1 -7::31::3 -7::32::1 -7::33::1 -7::35::1 -7::37::2 -7::39::3 -7::40::2 -7::42::2 -7::44::1 -7::45::2 -7::47::4 -7::48::1 -7::49::1 -7::53::1 -7::54::1 -7::55::1 -7::56::1 -7::59::1 -7::61::2 -7::62::3 -7::63::2 -7::66::1 -7::67::3 -7::74::1 -7::75::1 -7::76::3 -7::77::1 -7::81::1 -7::82::1 -7::84::2 -7::85::4 -7::86::1 -7::92::2 -7::96::1 -7::97::1 -7::98::1 -8::0::1 -8::2::4 -8::3::2 -8::4::2 -8::5::1 -8::7::1 -8::9::1 -8::11::1 -8::15::1 -8::18::1 -8::19::1 -8::21::1 -8::29::5 -8::31::3 -8::33::1 -8::35::1 -8::36::1 -8::40::2 -8::44::1 -8::45::1 -8::50::1 -8::51::1 -8::52::5 -8::53::5 -8::54::1 -8::55::1 -8::56::1 -8::58::4 -8::60::3 -8::62::4 -8::64::1 -8::67::3 -8::69::1 -8::71::1 -8::72::3 -8::77::3 -8::78::1 -8::79::1 -8::83::1 -8::85::5 -8::86::1 -8::88::1 -8::90::1 -8::92::2 -8::95::4 -8::96::3 -8::97::1 -8::98::1 -8::99::1 -9::2::3 -9::3::1 -9::4::1 -9::5::1 -9::6::1 -9::7::5 -9::9::1 -9::12::1 -9::14::3 -9::15::1 -9::19::1 -9::21::1 -9::22::1 -9::24::1 -9::25::1 -9::26::1 -9::30::3 -9::32::4 -9::35::2 -9::36::2 -9::37::2 -9::38::1 -9::39::1 -9::43::3 -9::49::5 -9::50::3 -9::53::1 -9::54::1 -9::58::1 -9::59::1 -9::60::1 -9::61::1 -9::63::3 -9::64::3 -9::68::1 -9::69::1 -9::70::3 -9::71::1 -9::73::2 -9::75::1 -9::77::2 -9::81::2 -9::82::1 -9::83::1 -9::84::1 -9::86::1 -9::87::4 -9::88::1 -9::90::3 -9::94::2 -9::95::3 -9::97::2 -9::98::1 -10::0::3 -10::2::4 -10::4::3 -10::7::1 -10::8::1 -10::10::1 -10::13::2 -10::14::1 -10::16::2 -10::17::1 -10::18::1 -10::21::1 -10::22::1 -10::24::1 -10::25::3 -10::28::1 -10::35::1 -10::36::1 -10::37::1 -10::38::1 -10::39::1 -10::40::4 -10::41::2 -10::42::3 -10::43::1 -10::49::3 -10::50::1 -10::51::1 -10::52::1 -10::55::2 -10::56::1 -10::58::1 -10::63::1 -10::66::1 -10::67::2 -10::68::1 -10::75::1 -10::77::1 -10::79::1 -10::86::1 -10::89::3 -10::90::1 -10::97::1 -10::98::1 -11::0::1 -11::6::2 -11::9::1 -11::10::1 -11::11::1 -11::12::1 -11::13::4 -11::16::1 -11::18::5 -11::19::4 -11::20::1 -11::21::1 -11::22::1 -11::23::5 -11::25::1 -11::27::5 -11::30::5 -11::32::5 -11::35::3 -11::36::2 -11::37::2 -11::38::4 -11::39::1 -11::40::1 -11::41::1 -11::43::2 -11::45::1 -11::47::1 -11::48::5 -11::50::4 -11::51::3 -11::59::1 -11::61::1 -11::62::1 -11::64::1 -11::66::4 -11::67::1 -11::69::5 -11::70::1 -11::71::3 -11::72::3 -11::75::3 -11::76::1 -11::77::1 -11::78::1 -11::79::5 -11::80::3 -11::81::4 -11::82::1 -11::86::1 -11::88::1 -11::89::1 -11::90::4 -11::94::2 -11::97::3 -11::99::1 -12::2::1 -12::4::1 -12::6::1 -12::7::3 -12::8::1 -12::14::1 -12::15::2 -12::16::4 -12::17::5 -12::18::2 -12::21::1 -12::22::2 -12::23::3 -12::24::1 -12::25::1 -12::27::5 -12::30::2 -12::31::4 -12::35::5 -12::38::1 -12::41::1 -12::44::2 -12::45::1 -12::50::4 -12::51::1 -12::52::1 -12::53::1 -12::54::1 -12::56::2 -12::57::1 -12::60::1 -12::63::1 -12::64::5 -12::66::3 -12::67::1 -12::70::1 -12::72::1 -12::74::1 -12::75::1 -12::77::1 -12::78::1 -12::79::3 -12::82::2 -12::83::1 -12::84::1 -12::85::1 -12::86::1 -12::87::1 -12::88::1 -12::91::3 -12::92::1 -12::94::4 -12::95::2 -12::96::1 -12::98::2 -13::0::1 -13::3::1 -13::4::2 -13::5::1 -13::6::1 -13::12::1 -13::14::2 -13::15::1 -13::17::1 -13::18::3 -13::20::1 -13::21::1 -13::22::1 -13::26::1 -13::27::1 -13::29::3 -13::31::1 -13::33::1 -13::40::2 -13::43::2 -13::44::1 -13::45::1 -13::49::1 -13::51::1 -13::52::2 -13::53::3 -13::54::1 -13::62::1 -13::63::2 -13::64::1 -13::68::1 -13::71::1 -13::72::3 -13::73::1 -13::74::3 -13::77::2 -13::78::1 -13::79::2 -13::83::3 -13::85::1 -13::86::1 -13::87::2 -13::88::2 -13::90::1 -13::93::4 -13::94::1 -13::98::1 -13::99::1 -14::1::1 -14::3::3 -14::4::1 -14::5::1 -14::6::1 -14::7::1 -14::9::1 -14::10::1 -14::11::1 -14::12::1 -14::13::1 -14::14::3 -14::15::1 -14::16::1 -14::17::1 -14::20::1 -14::21::1 -14::24::1 -14::25::2 -14::27::1 -14::28::1 -14::29::5 -14::31::3 -14::34::1 -14::36::1 -14::37::2 -14::39::2 -14::40::1 -14::44::1 -14::45::1 -14::47::3 -14::48::1 -14::49::1 -14::51::1 -14::52::5 -14::53::3 -14::54::1 -14::55::1 -14::56::1 -14::62::4 -14::63::5 -14::67::3 -14::68::1 -14::69::3 -14::71::1 -14::72::4 -14::73::1 -14::76::5 -14::79::1 -14::82::1 -14::83::1 -14::88::1 -14::93::3 -14::94::1 -14::95::2 -14::96::4 -14::98::1 -15::0::1 -15::1::4 -15::2::1 -15::5::2 -15::6::1 -15::7::1 -15::13::1 -15::14::1 -15::15::1 -15::17::2 -15::19::2 -15::22::2 -15::23::2 -15::25::1 -15::26::3 -15::27::1 -15::28::2 -15::29::1 -15::32::1 -15::33::2 -15::34::1 -15::35::2 -15::36::1 -15::37::1 -15::39::1 -15::42::1 -15::46::5 -15::48::2 -15::50::2 -15::51::1 -15::52::1 -15::58::1 -15::62::1 -15::64::3 -15::65::2 -15::72::1 -15::73::1 -15::74::1 -15::79::1 -15::80::1 -15::81::1 -15::82::2 -15::85::1 -15::87::1 -15::91::2 -15::96::1 -15::97::1 -15::98::3 -16::2::1 -16::5::3 -16::6::2 -16::7::1 -16::9::1 -16::12::1 -16::14::1 -16::15::1 -16::19::1 -16::21::2 -16::29::4 -16::30::2 -16::32::1 -16::34::1 -16::36::1 -16::38::1 -16::46::1 -16::47::3 -16::48::1 -16::49::1 -16::50::1 -16::51::5 -16::54::5 -16::55::1 -16::56::2 -16::57::1 -16::60::1 -16::63::2 -16::65::1 -16::67::1 -16::72::1 -16::74::1 -16::80::1 -16::81::1 -16::82::1 -16::85::5 -16::86::1 -16::90::5 -16::91::1 -16::93::1 -16::94::3 -16::95::2 -16::96::3 -16::98::3 -16::99::1 -17::2::1 -17::3::1 -17::6::1 -17::10::4 -17::11::1 -17::13::2 -17::17::5 -17::19::1 -17::20::5 -17::22::4 -17::28::1 -17::29::1 -17::33::1 -17::34::1 -17::35::2 -17::37::1 -17::38::1 -17::45::1 -17::46::5 -17::47::1 -17::49::3 -17::51::1 -17::55::5 -17::56::3 -17::57::1 -17::58::1 -17::59::1 -17::60::1 -17::63::1 -17::66::1 -17::68::4 -17::69::1 -17::70::1 -17::72::1 -17::73::3 -17::78::1 -17::79::1 -17::82::2 -17::84::1 -17::90::5 -17::91::3 -17::92::1 -17::93::1 -17::94::4 -17::95::2 -17::97::1 -18::1::1 -18::4::3 -18::5::2 -18::6::1 -18::7::1 -18::10::1 -18::11::4 -18::12::2 -18::13::1 -18::15::1 -18::18::1 -18::20::1 -18::21::2 -18::22::1 -18::23::2 -18::25::1 -18::26::1 -18::27::1 -18::28::5 -18::29::1 -18::31::1 -18::32::1 -18::36::1 -18::38::5 -18::39::5 -18::40::1 -18::42::1 -18::43::1 -18::44::4 -18::46::1 -18::47::1 -18::48::1 -18::51::2 -18::55::1 -18::56::1 -18::57::1 -18::62::1 -18::63::1 -18::66::3 -18::67::1 -18::70::1 -18::75::1 -18::76::3 -18::77::1 -18::80::3 -18::81::3 -18::82::1 -18::83::5 -18::84::1 -18::97::1 -18::98::1 -18::99::2 -19::0::1 -19::1::1 -19::2::1 -19::4::1 -19::6::2 -19::11::1 -19::12::1 -19::14::1 -19::23::1 -19::26::1 -19::31::1 -19::32::4 -19::33::1 -19::34::1 -19::37::1 -19::38::1 -19::41::1 -19::43::1 -19::45::1 -19::48::1 -19::49::1 -19::50::2 -19::53::2 -19::54::3 -19::55::1 -19::56::2 -19::58::1 -19::61::1 -19::62::1 -19::63::1 -19::64::1 -19::65::1 -19::69::2 -19::72::1 -19::74::3 -19::76::1 -19::78::1 -19::79::1 -19::81::1 -19::82::1 -19::84::1 -19::86::1 -19::87::2 -19::90::4 -19::93::1 -19::94::4 -19::95::2 -19::96::1 -19::98::4 -20::0::1 -20::1::1 -20::2::2 -20::4::2 -20::6::1 -20::8::1 -20::12::1 -20::21::2 -20::22::5 -20::24::2 -20::25::1 -20::26::1 -20::29::2 -20::30::2 -20::32::2 -20::39::1 -20::40::1 -20::41::2 -20::45::2 -20::48::1 -20::50::1 -20::51::3 -20::53::3 -20::55::1 -20::57::2 -20::60::1 -20::61::1 -20::64::1 -20::66::1 -20::70::2 -20::72::1 -20::73::2 -20::75::4 -20::76::1 -20::77::4 -20::78::1 -20::79::1 -20::84::2 -20::85::2 -20::88::3 -20::89::1 -20::90::3 -20::91::1 -20::92::2 -20::93::1 -20::94::4 -20::97::1 -21::0::1 -21::2::4 -21::3::1 -21::7::2 -21::11::1 -21::12::1 -21::13::1 -21::14::3 -21::17::1 -21::19::1 -21::20::1 -21::21::1 -21::22::1 -21::23::1 -21::24::1 -21::27::1 -21::29::5 -21::30::2 -21::38::1 -21::40::2 -21::43::3 -21::44::1 -21::45::1 -21::46::1 -21::48::1 -21::51::1 -21::53::5 -21::54::1 -21::55::1 -21::56::1 -21::58::3 -21::59::3 -21::64::1 -21::66::1 -21::68::1 -21::71::1 -21::73::1 -21::74::4 -21::80::1 -21::81::1 -21::83::1 -21::84::1 -21::85::3 -21::87::4 -21::89::2 -21::92::2 -21::96::3 -21::99::1 -22::0::1 -22::3::2 -22::5::2 -22::6::2 -22::9::1 -22::10::1 -22::11::1 -22::13::1 -22::14::1 -22::16::1 -22::18::3 -22::19::1 -22::22::5 -22::25::1 -22::26::1 -22::29::3 -22::30::5 -22::32::4 -22::33::1 -22::35::1 -22::36::3 -22::37::1 -22::40::1 -22::41::3 -22::44::1 -22::45::2 -22::48::1 -22::51::5 -22::55::1 -22::56::2 -22::60::3 -22::61::1 -22::62::4 -22::63::1 -22::65::1 -22::66::1 -22::68::4 -22::69::4 -22::70::3 -22::71::1 -22::74::5 -22::75::5 -22::78::1 -22::80::3 -22::81::1 -22::82::1 -22::84::1 -22::86::1 -22::87::3 -22::88::5 -22::90::2 -22::92::3 -22::95::2 -22::96::2 -22::98::4 -22::99::1 -23::0::1 -23::2::1 -23::4::1 -23::6::2 -23::10::4 -23::12::1 -23::13::4 -23::14::1 -23::15::1 -23::18::4 -23::22::2 -23::23::4 -23::24::1 -23::25::1 -23::26::1 -23::27::5 -23::28::1 -23::29::1 -23::30::4 -23::32::5 -23::33::2 -23::36::3 -23::37::1 -23::38::1 -23::39::1 -23::43::1 -23::48::5 -23::49::5 -23::50::4 -23::53::1 -23::55::5 -23::57::1 -23::59::1 -23::60::1 -23::61::1 -23::64::4 -23::65::5 -23::66::2 -23::67::1 -23::68::3 -23::69::1 -23::72::1 -23::73::3 -23::77::1 -23::82::2 -23::83::1 -23::84::1 -23::85::1 -23::87::3 -23::88::1 -23::95::2 -23::97::1 -24::4::1 -24::6::3 -24::7::1 -24::10::2 -24::12::1 -24::15::1 -24::19::1 -24::24::1 -24::27::3 -24::30::5 -24::31::1 -24::32::3 -24::33::1 -24::37::1 -24::39::1 -24::40::1 -24::42::1 -24::43::3 -24::45::2 -24::46::1 -24::47::1 -24::48::1 -24::49::1 -24::50::1 -24::52::5 -24::57::1 -24::59::4 -24::63::4 -24::65::1 -24::66::1 -24::67::1 -24::68::3 -24::69::5 -24::71::1 -24::72::4 -24::77::4 -24::78::1 -24::80::1 -24::82::1 -24::84::1 -24::86::1 -24::87::1 -24::88::2 -24::89::1 -24::90::5 -24::91::1 -24::92::1 -24::94::2 -24::95::1 -24::96::5 -24::98::1 -24::99::1 -25::1::3 -25::2::1 -25::7::1 -25::9::1 -25::12::3 -25::16::3 -25::17::1 -25::18::1 -25::20::1 -25::22::1 -25::23::1 -25::26::2 -25::29::1 -25::30::1 -25::31::2 -25::33::4 -25::34::3 -25::35::2 -25::36::1 -25::37::1 -25::40::1 -25::41::1 -25::43::1 -25::47::4 -25::50::1 -25::51::1 -25::53::1 -25::56::1 -25::58::2 -25::64::2 -25::67::2 -25::68::1 -25::70::1 -25::71::4 -25::73::1 -25::74::1 -25::76::1 -25::79::1 -25::82::1 -25::84::2 -25::85::1 -25::91::3 -25::92::1 -25::94::1 -25::95::1 -25::97::2 -26::0::1 -26::1::1 -26::2::1 -26::3::1 -26::4::4 -26::5::2 -26::6::3 -26::7::5 -26::13::3 -26::14::1 -26::16::1 -26::18::3 -26::20::1 -26::21::3 -26::22::5 -26::23::5 -26::24::5 -26::27::1 -26::31::1 -26::35::1 -26::36::4 -26::40::1 -26::44::1 -26::45::2 -26::47::1 -26::48::1 -26::49::3 -26::50::2 -26::52::1 -26::54::4 -26::55::1 -26::57::3 -26::58::1 -26::61::1 -26::62::2 -26::66::1 -26::68::4 -26::71::1 -26::73::4 -26::76::1 -26::81::3 -26::85::1 -26::86::3 -26::88::5 -26::91::1 -26::94::5 -26::95::1 -26::96::1 -26::97::1 -27::0::1 -27::9::1 -27::10::1 -27::18::4 -27::19::3 -27::20::1 -27::22::2 -27::24::2 -27::25::1 -27::27::3 -27::28::1 -27::29::1 -27::31::1 -27::33::3 -27::40::1 -27::42::1 -27::43::1 -27::44::3 -27::45::1 -27::51::3 -27::52::1 -27::55::3 -27::57::1 -27::59::1 -27::60::1 -27::61::1 -27::64::1 -27::66::3 -27::68::1 -27::70::1 -27::71::2 -27::72::1 -27::75::3 -27::78::1 -27::80::3 -27::82::1 -27::83::3 -27::86::1 -27::87::2 -27::90::1 -27::91::1 -27::92::1 -27::93::1 -27::94::2 -27::95::1 -27::98::1 -28::0::3 -28::1::1 -28::2::4 -28::3::1 -28::6::1 -28::7::1 -28::12::5 -28::13::2 -28::14::1 -28::15::1 -28::17::1 -28::19::3 -28::20::1 -28::23::3 -28::24::3 -28::27::1 -28::29::1 -28::33::1 -28::34::1 -28::36::1 -28::38::2 -28::39::2 -28::44::1 -28::45::1 -28::49::4 -28::50::1 -28::52::1 -28::54::1 -28::56::1 -28::57::3 -28::58::1 -28::59::1 -28::60::1 -28::62::3 -28::63::1 -28::65::1 -28::75::1 -28::78::1 -28::81::5 -28::82::4 -28::83::1 -28::85::1 -28::88::2 -28::89::4 -28::90::1 -28::92::5 -28::94::1 -28::95::2 -28::98::1 -28::99::1 -29::3::1 -29::4::1 -29::5::1 -29::7::2 -29::9::1 -29::10::3 -29::11::1 -29::13::3 -29::14::1 -29::15::1 -29::17::3 -29::19::3 -29::22::3 -29::23::4 -29::25::1 -29::29::1 -29::31::1 -29::32::4 -29::33::2 -29::36::2 -29::38::3 -29::39::1 -29::42::1 -29::46::5 -29::49::3 -29::51::2 -29::59::1 -29::61::1 -29::62::1 -29::67::1 -29::68::3 -29::69::1 -29::70::1 -29::74::1 -29::75::1 -29::79::2 -29::80::1 -29::81::2 -29::83::1 -29::85::1 -29::86::1 -29::90::4 -29::93::1 -29::94::4 -29::97::1 -29::99::1
http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-helloworld/MyAlgorithm.java ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-helloworld/MyAlgorithm.java b/examples/experimental/java-local-helloworld/MyAlgorithm.java deleted file mode 100644 index 08084aa..0000000 --- a/examples/experimental/java-local-helloworld/MyAlgorithm.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.sample.java.helloworld; - -import org.apache.predictionio.controller.java.*; - -import java.util.Map; -import java.util.HashMap; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class MyAlgorithm extends LJavaAlgorithm< - EmptyAlgorithmParams, MyTrainingData, MyModel, MyQuery, MyPredictedResult> { - - final static Logger logger = LoggerFactory.getLogger(MyAlgorithm.class); - - @Override - public MyModel train(MyTrainingData data) { - Map<String, Double> sumMap = new HashMap<String, Double>(); - Map<String, Integer> countMap = new HashMap<String, Integer>(); - - // calculate sum and count for each day - for (MyTrainingData.DayTemperature temp : data.temperatures) { - Double sum = sumMap.get(temp.day); - Integer count = countMap.get(temp.day); - if (sum == null) { - sumMap.put(temp.day, temp.temperature); - countMap.put(temp.day, 1); - } else { - sumMap.put(temp.day, sum + temp.temperature); - countMap.put(temp.day, count + 1); - } - } - - // calculate the average - Map<String, Double> averageMap = new HashMap<String, Double>(); - for (Map.Entry<String, Double> entry : sumMap.entrySet()) { - String day = entry.getKey(); - Double average = entry.getValue() / countMap.get(day); - averageMap.put(day, average); - } - - return new MyModel(averageMap); - } - - @Override - public MyPredictedResult predict(MyModel model, MyQuery query) { - Double temp = model.temperatures.get(query.day); - return new MyPredictedResult(temp); - } -} http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-helloworld/MyDataSource.java ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-helloworld/MyDataSource.java b/examples/experimental/java-local-helloworld/MyDataSource.java deleted file mode 100644 index e942de0..0000000 --- a/examples/experimental/java-local-helloworld/MyDataSource.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.sample.java.helloworld; - -import org.apache.predictionio.controller.java.*; - -import java.util.List; -import java.util.ArrayList; -import java.io.FileReader; -import java.io.BufferedReader; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class MyDataSource extends LJavaDataSource< - EmptyDataSourceParams, EmptyDataParams, MyTrainingData, MyQuery, EmptyActualResult> { - - final static Logger logger = LoggerFactory.getLogger(MyDataSource.class); - - @Override - public MyTrainingData readTraining() { - List<MyTrainingData.DayTemperature> temperatures = - new ArrayList<MyTrainingData.DayTemperature>(); - - try { - BufferedReader reader = new BufferedReader(new FileReader("../data/helloworld/data.csv")); - String line; - while ((line = reader.readLine()) != null) { - String[] tokens = line.split(","); - temperatures.add( - new MyTrainingData.DayTemperature(tokens[0], Double.parseDouble(tokens[1]))); - } - reader.close(); - } catch (Exception e) { - logger.error("Caught Exception: " + e.getMessage()); - System.exit(1); - } - - return new MyTrainingData(temperatures); - } -} http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-helloworld/MyEngineFactory.java ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-helloworld/MyEngineFactory.java b/examples/experimental/java-local-helloworld/MyEngineFactory.java deleted file mode 100644 index 6c28cb6..0000000 --- a/examples/experimental/java-local-helloworld/MyEngineFactory.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.sample.java.helloworld; - -import org.apache.predictionio.controller.java.*; - -public class MyEngineFactory implements IJavaEngineFactory { - public JavaSimpleEngine<MyTrainingData, EmptyDataParams, MyQuery, - MyPredictedResult, EmptyActualResult> apply() { - - return new JavaSimpleEngineBuilder<MyTrainingData, EmptyDataParams, - MyQuery, MyPredictedResult, EmptyActualResult> () - .dataSourceClass(MyDataSource.class) - .preparatorClass() // Use default Preparator - .addAlgorithmClass("", MyAlgorithm.class) - .servingClass() // Use default Serving - .build(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-helloworld/MyModel.java ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-helloworld/MyModel.java b/examples/experimental/java-local-helloworld/MyModel.java deleted file mode 100644 index 07ccd34..0000000 --- a/examples/experimental/java-local-helloworld/MyModel.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.sample.java.helloworld; - -import java.io.Serializable; -import java.util.Map; - -public class MyModel implements Serializable { - Map<String, Double> temperatures; - - public MyModel(Map<String, Double> temperatures) { - this.temperatures = temperatures; - } - - @Override - public String toString() { - return temperatures.toString(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-helloworld/MyPredictedResult.java ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-helloworld/MyPredictedResult.java b/examples/experimental/java-local-helloworld/MyPredictedResult.java deleted file mode 100644 index 129a5f9..0000000 --- a/examples/experimental/java-local-helloworld/MyPredictedResult.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.sample.java.helloworld; - -import java.io.Serializable; - -public class MyPredictedResult implements Serializable { - Double temperature; - - public MyPredictedResult(Double temperature) { - this.temperature = temperature; - } -} http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-helloworld/MyQuery.java ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-helloworld/MyQuery.java b/examples/experimental/java-local-helloworld/MyQuery.java deleted file mode 100644 index d98e9dc..0000000 --- a/examples/experimental/java-local-helloworld/MyQuery.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.sample.java.helloworld; - -import java.io.Serializable; - -public class MyQuery implements Serializable { - String day; - - public MyQuery(String day) { - this.day = day; - } -} http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-helloworld/MyTrainingData.java ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-helloworld/MyTrainingData.java b/examples/experimental/java-local-helloworld/MyTrainingData.java deleted file mode 100644 index adca58f..0000000 --- a/examples/experimental/java-local-helloworld/MyTrainingData.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.sample.java.helloworld; - -import java.io.Serializable; -import java.util.List; - -public class MyTrainingData implements Serializable { - List<DayTemperature> temperatures; - - public MyTrainingData(List<DayTemperature> temperatures) { - this.temperatures = temperatures; - } - - public static class DayTemperature implements Serializable { - String day; - Double temperature; - - public DayTemperature(String day, Double temperature) { - this.day = day; - this.temperature = temperature; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-helloworld/README.md ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-helloworld/README.md b/examples/experimental/java-local-helloworld/README.md deleted file mode 100644 index 245ba35..0000000 --- a/examples/experimental/java-local-helloworld/README.md +++ /dev/null @@ -1,93 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one or more -contributor license agreements. See the NOTICE file distributed with -this work for additional information regarding copyright ownership. -The ASF licenses this file to You under the Apache License, Version 2.0 -(the "License"); you may not use this file except in compliance with -the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. ---> - -# My First "Hello World" Engine - -``` -$ cd $PIO_HOME/examples/java-local-helloworld -``` - -Prepare training data: -``` -$ cp ../data/helloworld/data1.csv ../data/helloworld/data.csv -``` - -Register engine: - -``` -$ ../../bin/pio build - -``` - -Train: - -``` -$ ../../bin/pio train -``` - -Example output: - -``` -2014-08-11 14:29:35,877 INFO APIDebugWorkflow$ - Metrics is null. Stop here -2014-08-11 14:29:36,099 INFO APIDebugWorkflow$ - Saved engine instance with ID: 201408110004 -``` - -``` -$ ../../bin/pio deploy -``` - -Retrieve prediction: - -``` -$ curl -H "Content-Type: application/json" -d '{ "day": "Mon" }' http://localhost:8000/queries.json -``` - -Output: - -``` -{"temperature":75.5} -``` - -Retrieve prediction: - -``` -$ curl -H "Content-Type: application/json" -d '{ "day": "Tue" }' http://localhost:8000/queries.json -``` - -Output: -``` -{"temperature":80.5} -``` - - -Re-train with new data: - -``` -$ cd $PIO_HOME/examples/java-local-helloworld -$ cp ../data/helloworld/data2.csv ../data/helloworld/data.csv -``` - -``` -$ ../../bin/pio train -$ ../../bin/pio deploy -``` - -```` -$ curl -H "Content-Type: application/json" -d '{ "day": "Mon" }' http://localhost:8000/queries.json - -{"temperature":76.66666666666667} -```` http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-helloworld/build.sbt ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-helloworld/build.sbt b/examples/experimental/java-local-helloworld/build.sbt deleted file mode 100644 index b246d7f..0000000 --- a/examples/experimental/java-local-helloworld/build.sbt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import AssemblyKeys._ - -assemblySettings - -name := "example-java-local-helloworld" - -organization := "org.sample" - -libraryDependencies ++= Seq( - "org.apache.predictionio" %% "core" % "0.9.1" % "provided", - "org.apache.spark" %% "spark-core" % "1.2.0" % "provided") http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-helloworld/engine.json ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-helloworld/engine.json b/examples/experimental/java-local-helloworld/engine.json deleted file mode 100644 index a00e45b..0000000 --- a/examples/experimental/java-local-helloworld/engine.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "id": "org.sample.java.helloworld", - "description": "My Hello World Engine", - "engineFactory": "org.sample.java.helloworld.MyEngineFactory" -} http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-helloworld/project/assembly.sbt ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-helloworld/project/assembly.sbt b/examples/experimental/java-local-helloworld/project/assembly.sbt deleted file mode 100644 index 54c3252..0000000 --- a/examples/experimental/java-local-helloworld/project/assembly.sbt +++ /dev/null @@ -1 +0,0 @@ -addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2") http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-regression/README.md ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-regression/README.md b/examples/experimental/java-local-regression/README.md deleted file mode 100644 index ebf45ab..0000000 --- a/examples/experimental/java-local-regression/README.md +++ /dev/null @@ -1,96 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one or more -contributor license agreements. See the NOTICE file distributed with -this work for additional information regarding copyright ownership. -The ASF licenses this file to You under the Apache License, Version 2.0 -(the "License"); you may not use this file except in compliance with -the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. ---> - -# Java Local Regression Engine - -## Configuration - -### Data Source - -This sample regression engine reads data from file system. - -Edit the file path in `engine.json`, change `filepath` of `datasource` to an absolute path that points to -[lr_data.py](../data/lr_data.txt) - -``` -$ cat engine.json -... -"datasource": { - "filepath": <absolute_path_to_lr_data.txt> -} -... - -``` - -### Algorithms - -This engine comes with two algorithms. - -1. OLS. It is the standard ordinary least square algorithm. It takes no parameter. -2. Default. This algorithm always return the same value `v` defined in the parameter. - -Below is an example of `algorithms` defines in `engine.json`, it invokes three algorithms, - -1. The standard OLS algorithm, -2. A default algorithm which always return 2.0, -3. A default algorithm which always return 4.0. - -```json -"algorithms": [ - { "name": "OLS", "params": {} }, - { "name": "Default", "params": { "v": 2.0 } }, - { "name": "Default", "params": { "v": 4.0 } } -] -``` - -The `Serving` class returns the average of all these prediction to the user. - -## Register engine, train, and deploy. - -``` -$ pio build -$ pio train -$ pio deploy --port 9997 -``` - -## Query the Engine Instance - -``` -$ curl -X POST http://localhost:9997/queries.json -d \ - '[1.80,0.87,2.41,0.35,-0.21,1.35,0.51,1.55,-0.20,1.32]' -2.2434392991944025 -``` - -2.24... is the prediction result. - -## Evaluation - -You can evaluate the engine instance too. -``` -$ pio eval --batch JavaRegressionEval \ ---metrics-class org.apache.predictionio.examples.java.regression.MeanSquareMetrics - -... -2014-09-24 03:23:07,170 INFO spark.SparkContext - Job finished: collect at Workflow.scala:695, took 0.092829 s -2014-09-24 03:23:07,284 WARN workflow.CoreWorkflow$ - java.lang.String is not a NiceRendering instance. -2014-09-24 03:23:07,296 INFO workflow.CoreWorkflow$ - Saved engine instance with ID: OCCUucs7QBOOG--9kIWFEw -``` - -And you will see you result in PredictionIO dashboard. To start dashboard: -``` -$ pio dashboard -``` http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-regression/build.sbt ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-regression/build.sbt b/examples/experimental/java-local-regression/build.sbt deleted file mode 100644 index 92d7416..0000000 --- a/examples/experimental/java-local-regression/build.sbt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import AssemblyKeys._ - -assemblySettings - -name := "java-local-regression" - -organization := "myorg" - -version := "0.0.1-SNAPSHOT" - -libraryDependencies ++= Seq( - "org.apache.predictionio" %% "core" % "0.9.1" % "provided", - "org.apache.spark" %% "spark-core" % "1.2.0" % "provided") http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-regression/engine.json ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-regression/engine.json b/examples/experimental/java-local-regression/engine.json deleted file mode 100644 index a80ef7d..0000000 --- a/examples/experimental/java-local-regression/engine.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "id": "java-local-regression", - "description": "java-local-regression", - "engineFactory": "org.apache.predictionio.examples.java.regression.EngineFactory", - "datasource": { - "params": { - "filepath": "PATH-TO-lr_data.txt" - } - }, - "preparator": { - "params": { - "r": 0.8 - } - }, - "algorithms": [ - { - "name": "OLS", - "params": {} - }, - { - "name": "Default", - "params": { - "v": 2.0 - } - }, - { - "name": "Default", - "params": { - "v": 4.0 - } - } - ] -} http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-regression/project/assembly.sbt ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-regression/project/assembly.sbt b/examples/experimental/java-local-regression/project/assembly.sbt deleted file mode 100644 index 54c3252..0000000 --- a/examples/experimental/java-local-regression/project/assembly.sbt +++ /dev/null @@ -1 +0,0 @@ -addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2") http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-regression/src/main/java/DataSource.java ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-regression/src/main/java/DataSource.java b/examples/experimental/java-local-regression/src/main/java/DataSource.java deleted file mode 100644 index 62be375..0000000 --- a/examples/experimental/java-local-regression/src/main/java/DataSource.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.predictionio.examples.java.regression; - -import org.apache.predictionio.controller.java.LJavaDataSource; - -import scala.Tuple2; -import scala.Tuple3; - -import java.io.IOException; -import java.lang.Iterable; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.regex.Pattern; - -public class DataSource - extends LJavaDataSource<DataSourceParams, Integer, TrainingData, Double[], Double> { - - private static final Pattern SPACE = Pattern.compile(" "); - - public final DataSourceParams dsp; - - public DataSource(DataSourceParams dsp) { - this.dsp = dsp; - } - - public List<Tuple3<Integer, TrainingData, Iterable<Tuple2<Double[], Double>>>> read() { - - List<String> lines; - try { - lines = Files.readAllLines(Paths.get(dsp.filepath), StandardCharsets.UTF_8); - } catch (IOException exception) { - System.out.println("Cannot read file"); - lines = new ArrayList<String>(); - } - - int n = lines.size(); - - int featureCount = SPACE.split(lines.get(0)).length - 1; - - Double[][] x = new Double[n][featureCount]; - Double[] y = new Double[n]; - - for (int i = 0; i < n; i++) { - String[] line = SPACE.split(lines.get(i), 2); - y[i] = Double.parseDouble(line[0]); - - String[] featureStrs = SPACE.split(line[1]); - - for (int j = 0; j < featureCount; j++) { - x[i][j] = Double.parseDouble(featureStrs[j]); - } - } - - TrainingData td = new TrainingData(x, y); - - List<Tuple2<Double[], Double>> faList = new ArrayList<>(); - - for (int i = 0; i < 10; i++) { - faList.add(new Tuple2<Double[], Double>(x[i], y[i])); - } - - List<Tuple3<Integer, TrainingData, Iterable<Tuple2<Double[], Double>>>> results = - new ArrayList <> (); - - results.add(new Tuple3<Integer, TrainingData, Iterable<Tuple2<Double[], Double>>>( - new Integer(0), td, faList)); - - return results; - } -} http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-regression/src/main/java/DataSourceParams.java ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-regression/src/main/java/DataSourceParams.java b/examples/experimental/java-local-regression/src/main/java/DataSourceParams.java deleted file mode 100644 index 1afc919..0000000 --- a/examples/experimental/java-local-regression/src/main/java/DataSourceParams.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.predictionio.examples.java.regression; - -import org.apache.predictionio.controller.java.JavaParams; - -public class DataSourceParams implements JavaParams { - public final String filepath; - public DataSourceParams(String filepath) { - this.filepath = filepath; - } -} http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-regression/src/main/java/DefaultAlgorithm.java ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-regression/src/main/java/DefaultAlgorithm.java b/examples/experimental/java-local-regression/src/main/java/DefaultAlgorithm.java deleted file mode 100644 index 055e5e6..0000000 --- a/examples/experimental/java-local-regression/src/main/java/DefaultAlgorithm.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.predictionio.examples.java.regression; - -import org.apache.predictionio.controller.java.LJavaAlgorithm; - -// This algorithm is for illustration only. It returns a constant. -public class DefaultAlgorithm - extends LJavaAlgorithm<DefaultAlgorithmParams, TrainingData, Object, Double[], Double> { - public final DefaultAlgorithmParams p; - - public DefaultAlgorithm(DefaultAlgorithmParams p) { - this.p = p; - } - - public Object train(TrainingData data) { - return null; - } - - public Double predict(Object nullModel, Double[] query) { - return p.v; - } -} - http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-regression/src/main/java/DefaultAlgorithmParams.java ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-regression/src/main/java/DefaultAlgorithmParams.java b/examples/experimental/java-local-regression/src/main/java/DefaultAlgorithmParams.java deleted file mode 100644 index 28aba37..0000000 --- a/examples/experimental/java-local-regression/src/main/java/DefaultAlgorithmParams.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.predictionio.examples.java.regression; - -import org.apache.predictionio.controller.java.JavaParams; - -public class DefaultAlgorithmParams implements JavaParams { - public final double v; - public DefaultAlgorithmParams(double v) { - this.v = v; - } - - @Override - public String toString() { - return "DefaultAlgorithmParams (k=" + this.v + ")"; - } -} - - http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-regression/src/main/java/EngineFactory.java ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-regression/src/main/java/EngineFactory.java b/examples/experimental/java-local-regression/src/main/java/EngineFactory.java deleted file mode 100644 index 1fe03f3..0000000 --- a/examples/experimental/java-local-regression/src/main/java/EngineFactory.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.predictionio.examples.java.regression; - -import org.apache.predictionio.controller.java.IJavaEngineFactory; -import org.apache.predictionio.controller.java.JavaEngine; -import org.apache.predictionio.controller.java.JavaEngineBuilder; - -public class EngineFactory implements IJavaEngineFactory { - public JavaEngine<TrainingData, Integer, TrainingData, Double[], Double, Double> apply() { - return new JavaEngineBuilder<TrainingData, Integer, TrainingData, Double[], Double, Double> () - .dataSourceClass(DataSource.class) - .preparatorClass(Preparator.class) - .addAlgorithmClass("OLS", OLSAlgorithm.class) - .addAlgorithmClass("Default", DefaultAlgorithm.class) - .servingClass(Serving.class) - .build(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-regression/src/main/java/MeanSquareEvaluator.java ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-regression/src/main/java/MeanSquareEvaluator.java b/examples/experimental/java-local-regression/src/main/java/MeanSquareEvaluator.java deleted file mode 100644 index 13577e7..0000000 --- a/examples/experimental/java-local-regression/src/main/java/MeanSquareEvaluator.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.predictionio.examples.java.regression; - -import org.apache.predictionio.controller.java.JavaEvaluator; -import java.lang.Iterable; -import org.apache.predictionio.controller.java.EmptyParams; -import scala.Tuple2; -import java.util.List; -import java.util.ArrayList; - - -public class MeanSquareEvaluator - extends JavaEvaluator<EmptyParams, Integer, - Double[], Double, Double, Double, Double, String> { - - public Double evaluateUnit(Double[] query, Double prediction, Double actual) { - return (prediction - actual) * (prediction - actual); - } - - public Double evaluateSet(Integer dp, Iterable<Double> mseSeq) { - double mse = 0.0; - int n = 0; - for (Double e: mseSeq) { - mse += e; - n += 1; - } - return mse / n; - } - - public String evaluateAll(Iterable<Tuple2<Integer, Double>> input) { - List<String> l = new ArrayList<String>(); - for (Tuple2<Integer, Double> t : input) { - l.add("MSE: " + t._2().toString()); - } - return l.toString(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-regression/src/main/java/OLSAlgorithm.java ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-regression/src/main/java/OLSAlgorithm.java b/examples/experimental/java-local-regression/src/main/java/OLSAlgorithm.java deleted file mode 100644 index 6ed38f6..0000000 --- a/examples/experimental/java-local-regression/src/main/java/OLSAlgorithm.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.predictionio.examples.java.regression; - -import org.apache.commons.math3.stat.regression.OLSMultipleLinearRegression; -import org.apache.commons.math3.linear.RealVector; -import java.util.Arrays; -import org.apache.predictionio.controller.java.EmptyParams; - -import org.apache.predictionio.controller.java.LJavaAlgorithm; - -public class OLSAlgorithm - extends LJavaAlgorithm<EmptyParams, TrainingData, Double[], Double[], Double> { - - public Double[] train(TrainingData data) { - OLSMultipleLinearRegression r = new OLSMultipleLinearRegression(); - // Convert Double[][] to double[][] - double[][] x = new double[data.r][data.c]; - double[] y = new double[data.r]; - - for (int i=0; i<data.r; i++) { - for (int j=0; j<data.c; j++) { - x[i][j] = data.x[i][j].doubleValue(); - } - y[i] = data.y[i].doubleValue(); - } - - r.newSampleData(y, x); - // Fixme. Add intercept - double[] p = r.estimateRegressionParameters(); - Double[] pp = new Double[data.c]; - for (int j=0; j<data.c; j++) { - pp[j] = p[j]; - } - System.out.println("Regression Algo: " + Arrays.toString(pp)); - return pp; - } - - public Double predict(Double[] model, Double[] query) { - double dotProduct = 0.0; - for (int i = 0; i < model.length; i++) { - dotProduct += model[i] * query[i]; - } - return dotProduct; - } -} http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-regression/src/main/java/Preparator.java ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-regression/src/main/java/Preparator.java b/examples/experimental/java-local-regression/src/main/java/Preparator.java deleted file mode 100644 index f4d46c1..0000000 --- a/examples/experimental/java-local-regression/src/main/java/Preparator.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.predictionio.examples.java.regression; - -import org.apache.predictionio.controller.java.LJavaPreparator; - -// This Preparator is just a proof-of-concept. It removes a fraction of the -// training data to make training more "efficient". -public class Preparator extends LJavaPreparator<PreparatorParams, TrainingData, TrainingData> { - private PreparatorParams pp; - public Preparator(PreparatorParams pp) { - this.pp = pp; - } - - public TrainingData prepare(TrainingData td) { - int n = (int) (td.r * pp.r); - - Double[][] x = new Double[n][td.c]; - Double[] y = new Double[n]; - for (int i=0; i<n; i++) { - for (int j=0; j<td.c; j++) { - x[i][j] = td.x[i][j]; - } - y[i] = td.y[i]; - } - return new TrainingData(x, y); - } -} http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-regression/src/main/java/PreparatorParams.java ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-regression/src/main/java/PreparatorParams.java b/examples/experimental/java-local-regression/src/main/java/PreparatorParams.java deleted file mode 100644 index e4f45fb..0000000 --- a/examples/experimental/java-local-regression/src/main/java/PreparatorParams.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.predictionio.examples.java.regression; - -import org.apache.predictionio.controller.java.JavaParams; - -public class PreparatorParams implements JavaParams { - // Take the r-fraction of data in training. - public double r = 1.0; - public PreparatorParams(double r) { - this.r = r; - } -} - - http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-regression/src/main/java/Run.java ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-regression/src/main/java/Run.java b/examples/experimental/java-local-regression/src/main/java/Run.java deleted file mode 100644 index 76601f4..0000000 --- a/examples/experimental/java-local-regression/src/main/java/Run.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.predictionio.examples.java.regression; - -import org.apache.predictionio.controller.java.EmptyParams; -import org.apache.predictionio.controller.java.IJavaEngineFactory; -import org.apache.predictionio.controller.java.JavaParams; -import org.apache.predictionio.controller.java.JavaEngine; -import org.apache.predictionio.controller.java.JavaEngineBuilder; -import org.apache.predictionio.controller.java.JavaEngineParams; -import org.apache.predictionio.controller.java.JavaEngineParamsBuilder; -import org.apache.predictionio.controller.java.LJavaAlgorithm; -import org.apache.predictionio.controller.java.JavaWorkflow; -import org.apache.predictionio.controller.java.WorkflowParamsBuilder; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import scala.Tuple2; - -public class Run { - // During development, one can build a semi-engine, only add the first few layers. In this - // particular example, we only add until Algorithm Layer. - private static class HalfBakedEngineFactory implements IJavaEngineFactory { - public JavaEngine<TrainingData, Integer, TrainingData, Double[], Double, Double> apply() { - return new JavaEngineBuilder<TrainingData, Integer, TrainingData, Double[], Double, Double> () - .dataSourceClass(DataSource.class) - .preparatorClass(Preparator.class) - .addAlgorithmClass("OLS", OLSAlgorithm.class) - .addAlgorithmClass("Default", DefaultAlgorithm.class) - .build(); - } - } - - public static void runComponents() throws IOException { - JavaEngineParams engineParams = new JavaEngineParamsBuilder() - .dataSourceParams(new DataSourceParams(new File("../data/lr_data.txt").getCanonicalPath())) - .preparatorParams(new PreparatorParams(0.3)) - .addAlgorithmParams("OLS", new EmptyParams()) - .addAlgorithmParams("Default", new DefaultAlgorithmParams(0.2)) - .addAlgorithmParams("Default", new DefaultAlgorithmParams(0.4)) - .build(); - - JavaWorkflow.runEngine( - (new HalfBakedEngineFactory()).apply(), - engineParams, - new WorkflowParamsBuilder().batch("java regression engine").verbose(3).build() - ); - } - - public static void runEngine() throws IOException { - JavaEngineParams engineParams = new JavaEngineParamsBuilder() - .dataSourceParams(new DataSourceParams(new File("../data/lr_data.txt").getCanonicalPath())) - .preparatorParams(new PreparatorParams(0.3)) - .addAlgorithmParams("OLS", new EmptyParams()) - .addAlgorithmParams("Default", new DefaultAlgorithmParams(0.2)) - .addAlgorithmParams("Default", new DefaultAlgorithmParams(0.4)) - .build(); - - JavaWorkflow.runEngine( - (new EngineFactory()).apply(), - engineParams, - MeanSquareEvaluator.class, - new EmptyParams(), - new WorkflowParamsBuilder().batch("java regression engine").verbose(3).build() - ); - } - - public static void main(String[] args) { - try { - runEngine(); - //runComponents(); - } catch (IOException ex) { - System.out.println(ex); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-regression/src/main/java/Serving.java ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-regression/src/main/java/Serving.java b/examples/experimental/java-local-regression/src/main/java/Serving.java deleted file mode 100644 index 24ad092..0000000 --- a/examples/experimental/java-local-regression/src/main/java/Serving.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.predictionio.examples.java.regression; - -import org.apache.predictionio.controller.java.LJavaServing; -import org.apache.predictionio.controller.java.EmptyParams; - -import java.lang.Iterable; - -public class Serving extends LJavaServing<EmptyParams, Double[], Double> { - public Double serve(Double[] query, Iterable<Double> predictions) { - int n = 0; - double s = 0.0; - for (Double d: predictions) { - n += 1; - s += d; - } - return s / n; - } -} http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-regression/src/main/java/TrainingData.java ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-regression/src/main/java/TrainingData.java b/examples/experimental/java-local-regression/src/main/java/TrainingData.java deleted file mode 100644 index c59d0d7..0000000 --- a/examples/experimental/java-local-regression/src/main/java/TrainingData.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.predictionio.examples.java.regression; - -import java.io.Serializable; -import java.util.Arrays; - -public class TrainingData implements Serializable { - public final Double[][] x; - public final Double[] y; - public final int r; - public final int c; - public TrainingData(Double[][] x, Double[] y) { - this.x = x; - this.y = y; - this.r = x.length; - this.c = x[0].length; - } - @Override public String toString() { - return "TrainingData: r=" + this.r + ",c=" + this.c; - } -} http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-regression/src/main/java/examples/algorithmsParams.json ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-regression/src/main/java/examples/algorithmsParams.json b/examples/experimental/java-local-regression/src/main/java/examples/algorithmsParams.json deleted file mode 100644 index e376f2e..0000000 --- a/examples/experimental/java-local-regression/src/main/java/examples/algorithmsParams.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - {"name": "OLS", "params": {}}, - {"name": "Default", "params": {"v": 0.2}}, - {"name": "Default", "params": {"v": 0.4}} -] http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-regression/src/main/java/examples/dataSourceParams.json ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-regression/src/main/java/examples/dataSourceParams.json b/examples/experimental/java-local-regression/src/main/java/examples/dataSourceParams.json deleted file mode 100644 index 8d87c56..0000000 --- a/examples/experimental/java-local-regression/src/main/java/examples/dataSourceParams.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "filepath": "data/lr_data.txt" -} http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-regression/src/main/java/examples/manifest.json ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-regression/src/main/java/examples/manifest.json b/examples/experimental/java-local-regression/src/main/java/examples/manifest.json deleted file mode 100644 index 191de43..0000000 --- a/examples/experimental/java-local-regression/src/main/java/examples/manifest.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "id": "org.apache.predictionio.examples.java.regression", - "version": "0.8.1-SNAPSHOT", - "name": "Apache Java Regression Engine", - "engineFactory": "org.apache.predictionio.examples.java.regression.EngineFactory" -} http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-regression/src/main/java/examples/preparatorParams.json ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-regression/src/main/java/examples/preparatorParams.json b/examples/experimental/java-local-regression/src/main/java/examples/preparatorParams.json deleted file mode 100644 index f5ac299..0000000 --- a/examples/experimental/java-local-regression/src/main/java/examples/preparatorParams.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "r": 0.3 -} http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-tutorial/README.md ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-tutorial/README.md b/examples/experimental/java-local-tutorial/README.md deleted file mode 100644 index 478fa8e..0000000 --- a/examples/experimental/java-local-tutorial/README.md +++ /dev/null @@ -1,29 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one or more -contributor license agreements. See the NOTICE file distributed with -this work for additional information regarding copyright ownership. -The ASF licenses this file to You under the Apache License, Version 2.0 -(the "License"); you may not use this file except in compliance with -the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. ---> - -## TODO: update with new engine.json format and CLI! (updates pending) - -## Download Data from GroupLens - -Execute the following command to download MovieLens 100k to data/ml-100k/. -``` -$ ./fetch.sh -``` - -## Tutorials - -The purpose of this tutorial is to help you to get familiar with each components of the PredictionIO framework. It can be found in `docs/manual/tutorials/enginebuilders/stepbystep`. http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-tutorial/build.sbt ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-tutorial/build.sbt b/examples/experimental/java-local-tutorial/build.sbt deleted file mode 100644 index 077fa0c..0000000 --- a/examples/experimental/java-local-tutorial/build.sbt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import AssemblyKeys._ - -assemblySettings - -name := "java-local-tutorial" - -organization := "org.apache.predictionio" - -version := "0.9.1" - -libraryDependencies ++= Seq( - "org.apache.predictionio" %% "core" % "0.9.1" % "provided", - "org.apache.predictionio" %% "engines" % "0.9.1" % "provided", - "org.apache.mahout" % "mahout-core" % "0.9", - "org.apache.spark" %% "spark-core" % "1.2.0" % "provided") http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-tutorial/data/test/ratings.csv ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-tutorial/data/test/ratings.csv b/examples/experimental/java-local-tutorial/data/test/ratings.csv deleted file mode 100644 index 126ba55..0000000 --- a/examples/experimental/java-local-tutorial/data/test/ratings.csv +++ /dev/null @@ -1,11 +0,0 @@ -1,1,2 -1,2,3 -1,3,4 -2,3,4 -2,4,1 -3,2,2 -3,3,1 -3,4,3 -4,1,5 -4,2,3 -4,4,2 http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-tutorial/fetch.sh ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-tutorial/fetch.sh b/examples/experimental/java-local-tutorial/fetch.sh deleted file mode 100755 index fc42dd4..0000000 --- a/examples/experimental/java-local-tutorial/fetch.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -set -e - -TARGET_BASE_DIR="data" - -mkdir -p $TARGET_BASE_DIR -curl http://files.grouplens.org/papers/ml-100k.zip -o $TARGET_BASE_DIR/ml-100k.zip -cd $TARGET_BASE_DIR -unzip ml-100k.zip - -echo "Data dir: ${TARGET_BASE_DIR}/ml-100k/" - - http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-tutorial/project/assembly.sbt ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-tutorial/project/assembly.sbt b/examples/experimental/java-local-tutorial/project/assembly.sbt deleted file mode 100644 index 54c3252..0000000 --- a/examples/experimental/java-local-tutorial/project/assembly.sbt +++ /dev/null @@ -1 +0,0 @@ -addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2") http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-tutorial/src/main/java/recommendations/.gitignore ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-tutorial/src/main/java/recommendations/.gitignore b/examples/experimental/java-local-tutorial/src/main/java/recommendations/.gitignore deleted file mode 100644 index cc027f5..0000000 --- a/examples/experimental/java-local-tutorial/src/main/java/recommendations/.gitignore +++ /dev/null @@ -1 +0,0 @@ -testdata/ml-100k/ http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-tutorial/src/main/java/recommendations/tutorial1/AlgoParams.java ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-tutorial/src/main/java/recommendations/tutorial1/AlgoParams.java b/examples/experimental/java-local-tutorial/src/main/java/recommendations/tutorial1/AlgoParams.java deleted file mode 100644 index 05ad8b4..0000000 --- a/examples/experimental/java-local-tutorial/src/main/java/recommendations/tutorial1/AlgoParams.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.predictionio.examples.java.recommendations.tutorial1; - -import org.apache.predictionio.controller.java.JavaParams; - -public class AlgoParams implements JavaParams { - public double threshold; - - public AlgoParams(double threshold) { - this.threshold = threshold; - } -} http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/dec9f84c/examples/experimental/java-local-tutorial/src/main/java/recommendations/tutorial1/Algorithm.java ---------------------------------------------------------------------- diff --git a/examples/experimental/java-local-tutorial/src/main/java/recommendations/tutorial1/Algorithm.java b/examples/experimental/java-local-tutorial/src/main/java/recommendations/tutorial1/Algorithm.java deleted file mode 100644 index c2be789..0000000 --- a/examples/experimental/java-local-tutorial/src/main/java/recommendations/tutorial1/Algorithm.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.predictionio.examples.java.recommendations.tutorial1; - -import org.apache.predictionio.controller.java.LJavaAlgorithm; -import org.apache.commons.math3.linear.RealVector; -import org.apache.commons.math3.linear.ArrayRealVector; -import org.apache.commons.math3.linear.OpenMapRealVector; -import scala.Tuple2; -import java.util.Map; -import java.util.HashMap; -import java.util.List; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Queue; -import java.util.PriorityQueue; -import java.util.Comparator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Algorithm extends - LJavaAlgorithm<AlgoParams, TrainingData, Model, Query, Float> { - - final static Logger logger = LoggerFactory.getLogger(Algorithm.class); - - AlgoParams params; - - public Algorithm(AlgoParams params) { - this.params = params; - } - - @Override - public Model train(TrainingData data) { - // pre-process - Map<Integer, Map<Integer, Float>> itemMap = new HashMap<Integer, Map<Integer, Float>>(); - Map<Integer, Integer> userIndexMap = new HashMap<Integer, Integer>(); - Map<Integer, Integer> itemIndexMap = new HashMap<Integer, Integer>(); - - int itemIndex = 0; - int userIndex = 0; - for (TrainingData.Rating r : data.ratings) { - Map<Integer, Float> userRating = itemMap.get(r.iid); - if (userRating == null) { - // new item - userRating = new HashMap<Integer, Float>(); - itemMap.put(r.iid, userRating); - itemIndexMap.put(r.iid, itemIndex); - itemIndex += 1; // increment item index for next item - } - userRating.put(r.uid, r.rating); - - // update user index - Integer u = userIndexMap.get(r.uid); - if (u == null) { - // new user - userIndexMap.put(r.uid, userIndex); - userIndex += 1; - } - } - - int numOfItems = itemIndexMap.size(); - int numOfUsers = userIndexMap.size(); - - Map<Integer, RealVector> itemVectors = new HashMap<Integer, RealVector>(); - Map<Integer, RealVector> userHistory = new HashMap<Integer, RealVector>(); - - for (Map.Entry<Integer, Map<Integer, Float>> entry : itemMap.entrySet()) { - Integer itemID = entry.getKey(); - Integer iindex = itemIndexMap.get(itemID); - Map<Integer, Float> userRatingMap = entry.getValue(); - RealVector item = new ArrayRealVector(numOfUsers); // dimension is numOfUsers - for (Map.Entry<Integer, Float> r : userRatingMap.entrySet()) { - Integer userID = r.getKey(); - Float rating = r.getValue(); - Integer uindex = userIndexMap.get(userID); - item.setEntry(uindex, rating); - // update user History - RealVector user = userHistory.get(userID); - if (user == null) { - user = new OpenMapRealVector(numOfItems); - userHistory.put(userID, user); - } - user.setEntry(iindex, rating); - } - itemVectors.put(itemID, item); - } - - // calculate sim - - Map<Integer, RealVector> itemSimilarity = new HashMap<Integer, RealVector>(); - List<Integer> item1List = new ArrayList<Integer>(itemIndexMap.keySet()); - List<Integer> item2List = new ArrayList<Integer>(item1List); - - int numSimilarItems = 100; - Comparator<IndexAndScore> comparator = new IndexAndScoreComparator(); - Map<Integer, Queue<IndexAndScore>> topItemSimilarity = - new HashMap<Integer, Queue<IndexAndScore>>(); - - for (Integer itemID1 : item1List) { - item2List.remove(0); - Integer index1 = itemIndexMap.get(itemID1); - for (Integer itemID2: item2List) { - RealVector vector1 = itemVectors.get(itemID1); - RealVector vector2 = itemVectors.get(itemID2); - double score = vector1.cosine(vector2); - if (score > params.threshold) { - Integer index2 = itemIndexMap.get(itemID2); - setTopItemSimilarity(topItemSimilarity, itemID1, index2, score, numSimilarItems, - comparator); - setTopItemSimilarity(topItemSimilarity, itemID2, index1, score, numSimilarItems, - comparator); - } - } - } - - for (Map.Entry<Integer, Queue<IndexAndScore>> entry : topItemSimilarity.entrySet()) { - Iterator<IndexAndScore> it = entry.getValue().iterator(); - RealVector vector = new OpenMapRealVector(numOfItems); - while (it.hasNext()) { - IndexAndScore d = it.next(); - vector.setEntry(d.index, d.score); - } - itemSimilarity.put(entry.getKey(), vector); - } - - return new Model(itemSimilarity, userHistory); - } - - private class IndexAndScore { - int index; - double score; - public IndexAndScore(int index, double score) { - this.index = index; - this.score = score; - } - } - - private class IndexAndScoreComparator implements Comparator<IndexAndScore> { - @Override - public int compare(IndexAndScore o1, IndexAndScore o2) { - int r = 0; - if (o1.score < o2.score) - r = -1; - else if (o1.score > o2.score) - r = 1; - return r; - } - } - - private void setTopItemSimilarity(Map<Integer, Queue<IndexAndScore>> topItemSimilarity, - Integer itemID1, Integer index2, double score, int capacity, - Comparator<IndexAndScore> comparator) { - Queue<IndexAndScore> queue = topItemSimilarity.get(itemID1); - if (queue == null) { - queue = new PriorityQueue<IndexAndScore>(capacity, comparator); - topItemSimilarity.put(itemID1, queue); - } - IndexAndScore entry = new IndexAndScore(index2, score); - if (queue.size() < capacity) - queue.add(entry); - else if (comparator.compare(queue.peek(), entry) < 0) { - queue.poll(); - queue.add(entry); - } - } - - @Override - public Float predict(Model model, Query query) { - RealVector itemVector = model.itemSimilarity.get(query.iid); - RealVector userVector = model.userHistory.get(query.uid); - if (itemVector == null) { - // cold start item, can't be handled by this algo, return hard code value. - return Float.NaN; - } else if (userVector == null) { - // new user, can't be handled by this algo, return hard code value. - return Float.NaN; - } else { - //logger.info("(" + query.uid + "," + query.iid + ")"); - //logger.info(itemVector.toString()); - //logger.info(userVector.toString()); - double accum = 0.0; - double accumSim = 0.0; - for (int i = 0; i < itemVector.getDimension(); i++) { - double weight = itemVector.getEntry(i); - double rating = userVector.getEntry(i); - if ((weight != 0) && (rating != 0)) { - accum += weight * rating; - accumSim += Math.abs(weight); - } - } - - if (accumSim == 0.0) { - return Float.NaN; - } else { - return (float) (accum / accumSim); - } - } - } - -}
