classification - Using mahout in java code, not cli -
i want able build model using java, able cli folowing:
./mahout trainlogistic --input candy-crush.twtr.csv \ --output ./model \ --target hd_click --categories 2 \ --predictors click_frequency country_code ctr device_price_range hd_conversion time_of_day num_clicks phone_type twitter is_weekend app_entertainment app_wallpaper app_widgets arcade books_and_reference brain business cards casual comics communication education entertainment finance game_wallpaper game_widgets health_and_fitness health_fitness libraries_and_demo libraries_demo lifestyle media_and_video media_video medical music_and_audio news_and_magazines news_magazines personalization photography productivity racing shopping social sports sports_apps sports_games tools transportation travel_and_local weather app_entertainment_percentage app_wallpaper_percentage app_widgets_percentage arcade_percentage books_and_reference_percentage brain_percentage business_percentage cards_percentage casual_percentage comics_percentage communication_percentage education_percentage entertainment_percentage finance_percentage game_wallpaper_percentage game_widgets_percentage health_and_fitness_percentage health_fitness_percentage libraries_and_demo_percentage libraries_demo_percentage lifestyle_percentage media_and_video_percentage media_video_percentage medical_percentage music_and_audio_percentage news_and_magazines_percentage news_magazines_percentage personalization_percentage photography_percentage productivity_percentage racing_percentage shopping_percentage social_percentage sports_apps_percentage sports_games_percentage sports_percentage tools_percentage transportation_percentage travel_and_local_percentage weather_percentage reads_magazine_sum reads_magazine_count interested_in_gardening_sum interested_in_gardening_count kids_birthday_coming_sum kids_birthday_coming_count job_seeker_sum job_seeker_count friends_sum friends_count married_sum married_count charity_donor_sum charity_donor_count student_sum student_count interested_in_real_estate_sum interested_in_real_estate_count sports_fan_sum sports_fan_count bascketball_sum bascketball_count interested_in_politics_sum interested_in_politics_count gamer_sum gamer_count activist_sum activist_count traveler_sum traveler_count likes_soccer_sum likes_soccer_count interested_in_celebs_sum interested_in_celebs_count auto_racing_sum auto_racing_count age_group_sum age_group_count healthy_lifestyle_sum healthy_lifestyle_count interested_in_finance_sum interested_in_finance_count sports_teams_usa_sum sports_teams_usa_count interested_in_deals_sum interested_in_deals_count business_oriented_sum business_oriented_count interested_in_cooking_sum interested_in_cooking_count music_lover_sum music_lover_count beauty_sum beauty_count follows_fashion_sum follows_fashion_count likes_wrestling_sum likes_wrestling_count name_sum name_count shopper_sum shopper_count golf_sum golf_count vegetarian_sum vegetarian_count dating_sum dating_count interested_in_fashion_sum interested_in_fashion_count interested_in_news_sum interested_in_news_count likes_tennis_sum likes_tennis_count male_sum male_count interested_in_cars_sum interested_in_cars_count follows_bloggers_sum follows_bloggers_count entertainment_sum entertainment_count interested_in_books_sum interested_in_books_count has_kids_sum has_kids_count interested_in_movies_sum interested_in_movies_count musicians_sum musicians_count tech_oriented_sum tech_oriented_count female_sum female_count has_pet_sum has_pet_count practicing_sports_sum practicing_sports_count \ --types numeric word numeric word word word numeric word word word numeric \ --features 100 --passes 1 --rate 50
i cant understand 20 news group example because big learn from. can give me code doing same cli command?
to clarify:
i need this:
model.train(1,0,"monday",6,44,1,7,4,6,78,7,3,4,6,........,"good"); model.train(1,0,"sunday",6,44,5,7,9,2,4,6,78,7,3,4,6,........,"bad"); model.train(1,0,"monday",4,99,2,4,6,3,4,6,........,"good"); model.writetofile("mymodel.model");
plese not answer if not familiar classification , want tell me how execute cli command java
i not 100% familiar mahout api (i agree documentation sparse) can give pointers, hope helps:
the java source code trainlogistic
example can found in mahout-examples
library - it's on maven [0] (in org.apache.mahout.classifier.sgd.trainlogistic
). suppose if wanted to, use exact same source code, depends on couple of utility classes in mahout-examples
library (and it's not clean, either).
the class performing training in example org.apache.mahout.classifier.sgd.onlinelogisticregression
[1], although considering large number of predictor variables have might want use adaptivelogisticregression
[2] (same package), uses number of onlinelogisticregression
s internally. have see works best data.
the api straightforward, there's train
method takes vector
of input data , classify
method test model, learningrate
, others change model's parameters.
to save model disk command line tool does, use org.apache.mahout.classifier.sgd.modelserializer
, has straightforward api write , read model. (there's write
, readfields
methods in olr class itself, frankly, i'm not sure or if there's difference modelserializer
- they're not documented either.)
lastly, aside source code in mahout-examples
, here's 2 other example of using mahout api directly, might useful [3, 4].
sources:
[0] http://repo1.maven.org/maven2/org/apache/mahout/mahout-examples/0.8/
[4] http://skife.org/mahout/2013/02/14/first_steps_with_mahout.html
Comments
Post a Comment