Sunday, 21 June 2015

step to set up mahout and maven in eclipse

Installing/setting up mahout and Building a Recommender System
Part 1: installing mahout
Step 1:
Install m2eclipse from within eclipse using the link below:
Start eclipse > help > install new software > Add > enter m2eclipe as name and paste the URL above into the URL field. Next > install (this will take a while) > next > next > accept agreement … > next > restart eclipse to complete installation
Part 2: Building a User Recommender System
Step 1: create a project in eclipse
Creating the project: File > new > others > maven project > next > select eg quickstart > enter names eg:
group id: com.recommender
artifacts id: RecommenderApp
package: com.recommender1.RecommenderApp1
Click on Finish

The project will be created in eclipse and the source file will be located under:
project-name/src/main/java

Issues you might encounter:
1.       The build path error/warning:
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
To eliminate the build path warning in eclipse > right click on project > properties > java build path > libraries > add library > JRE System library > Alternative JRE > select JRE System library 1.5 > Remove
Edit pom.xm;l

 To the Official Release site: https://mahout.apache.org/general/downloads.html

 And copy: For Maven users please include the following snippet in your pom:
In eclipse ecpand the project and fine the file pom.xml > double click on it and it will show on the right side of the workspace (underneath) >



Click on the pom.xml and it will open the following:
BEFORE:
-----------------------------------------------------------------------------------------------------------------------
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.cold-start-rsystem</groupId>
  <artifactId>cold-start</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>cold-start</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

--------------------------------------------------------------------------------
Add the below to the file:
<dependency>
    <groupId>org.apache.mahout</groupId>
    <artifactId>mahout-core</artifactId>
    <version>${mahout.version}</version>
</dependency>

So once again: in eclipse > click on pom.xml on the bottom of the page > paste it in just above the last entry as shown below:
AFTER:
---------------------------------------------------------------------------------------------------------------
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
       <modelVersion>4.0.0</modelVersion>

       <groupId>com.cold-start-rsystem</groupId>
       <artifactId>cold-start</artifactId>
       <version>0.0.1-SNAPSHOT</version>
       <packaging>jar</packaging>

       <name>cold-start</name>
       <url>http://maven.apache.org</url>

       <properties>
              <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
       </properties>

       <dependency>
              <groupId>org.apache.mahout</groupId>
              <artifactId>mahout-core</artifactId>
              <version>0.9</version>
       </dependency>


       <dependencies>
              <dependency>
                     <groupId>junit</groupId>
                     <artifactId>junit</artifactId>
                     <version>3.8.1</version>
                     <scope>test</scope>
              </dependency>
       </dependencies>
</project>
 ---------------------------------------------------------------------------------------------------------------
Edit the version to correspond with your version as shown above for version 0.9
1.  eg enter 0.9 like: <version>0.9</version>
2.  Select all (ctrl + A)
3.  Space it all nicely (ctrl + i)
4.  Save it (ctrl + s)
5.       Close > . This is the end of the quick start outlined here: https://mahout.apache.org/users/basics/quickstart.html

Next step:  Get the dataset and add the dataset
1.       Get the dataset eg from movielens or from link below: https://mahout.apache.org/users/recommender/userbased-5-minutes.html
2.       Copy the data
3.       Create folder in the project: right click on project > new > folder > name it eg data
4.       Create file in the newly created folder: right click on the folder > new file > name it eg dataset.csv > drag and drop the file to the work-area of eclipse (it has to be an empty wordarea) > paste the data into it > save it: ctrl +s > close it
5.       Now to the projectApp (RecommenderApp) > src/main/java > com/App.java
Issues: error import cannot be resolved ….
The import org.apache cannot be resolved
Resolution:  download and import maven libraries
1.       Download your version from: http://www.whoishostingthis.com/mirrors/apache/mahout/
1.       unzip to a directory
2.       from eclipse import the libraries: right click on the project > build path > configure build path > libraries > add external jar files > browse to the directory > click on
3.       mahout-core-0.9.jar > open
4.       mahout-core-0.9-job.jar > open
5.       mahout-integration-0.9.jar > open
6.       mahout-math-0.9.jar (if needed) > open

Issues and problem encountered:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Resolution is:
1.       Create a folder called lib
2.       Download the file slf4j-nop-1.7.5 from (make sure it is a trusted site): http://mvnrepository.com/artifact/org.slf4j/slf4j-nop/1.7.5
3.       drag the file to the lib folder created in the project

4.       right click on the file – slf4j-nop-1.7.5 > build path > add to build path > refresh project > run project and issue should be resolved

No comments:

Post a Comment