Mahoutのシステム要件を確認する。
Java 1.6.x or greater. Maven 3.x to build the source code. CPU, Disk and Memory requirements are based on the many choices made in implementing your application with Mahout (document size, number of documents, and number of hits retrieved to name a few.) Several of the Mahout algorithms are implemented to work on Hadoop clusters. If not advertised differently, those implementations work with Hadoop 0.20.0 or greater.
Java
JREおよびJSDKをインストールする
yum install java yum install java-devel
Maven
Mavenの.3.1.1をダウンロード
wget http://ftp.tsukuba.wide.ad.jp/software/apache/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.zip
解凍する
unzip apache-maven-3.1.1-bin.zip
/usr/localの下に移動する
mv apache-maven-3.1.1 /usr/local/
シンボリックリンクをはり、今後のバージョン変更時の対応を簡単にする
ln -s /usr/local/apache-maven-3.1.1 /usr/local/maven
環境変数を指定する
export M2_HOME=/usr/local/maven export M2=$M2_HOME/bin export PATH=$M2:$PATH
mavenのバージョンを確認する
mvn -version
hadoop
hadoopのインスト―トルはこちらを参照
Mahout
mahoutをダウンロード
wget http://ftp.riken.jp/net/apache/mahout/0.8/mahout-distribution-0.8-src.zip
解凍する
unzip mahout-distribution-0.8-src.zip
mvnでmahoutをインストール
cd mahout-distribution-0.8 mvn install
ディレクトリを移す
mv mahout-distribution-0.8 /usr/local ln -s /usr/local/mahout-distribution-0.8/ /usr/local/mahout
環境変数を設定 .bash_profileを編集する
export HADOOP_HOME=/usr/local/hadoop export JAVA_HOME=/usr/lib/jvm/java-openjdk export M2_HOME=/usr/local/maven export M2=$M2_HOME/bin export PATH=/usr/local/mahout/bin:$M2:$PATH
Mahout Exampleのbuild
cd /usr/local/mahout mvn install
classify-20newsgroups.sh
./classify-20newsgroups.sh ======================================================= Summary ------------------------------------------------------- Correctly Classified Instances : 6780 90.9945% Incorrectly Classified Instances : 671 9.0055% Total Classified Instances : 7451 ======================================================= Confusion Matrix ------------------------------------------------------- a b c d e f g h i j k l m n o p q r s t <--Classified as 314 0 0 0 0 0 0 0 0 0 0 0 1 0 2 4 0 0 13 0 | 334 a = alt.atheism 1 300 3 12 8 12 4 0 0 0 0 4 4 0 2 2 0 0 0 0 | 352 b = comp.graphics 0 15 228 82 9 12 4 0 0 0 0 3 2 1 0 0 0 1 0 0 | 357 c = comp.os.ms-windows.misc 0 8 0 335 16 1 5 3 0 1 1 2 6 0 0 0 0 0 0 0 | 378 ======================================================= Statistics ------------------------------------------------------- Kappa 0.8821 Accuracy 90.9945% Reliability 86.1972% Reliability (standard deviation) 0.2147
factorize-movielens-1M
mahoutへのパスを変更する。
MAHOUT="/usr/local/mahout/bin/mahout"
データをダウンロードする。
mkdir ./testdata wget http://files.grouplens.org/datasets/movielens/ml-1m.zip unzip ./ml-1m.zip
実行する
./factorize-movielens-1M.sh ./testdata/ml-1m/ratings.dat
shufがないためにエラーになる。。。