April 26, 2015 Leave a comment
How to compile and execute weka source code on your computer- Part 1
Off recently, It so happened that I required the need to understand the working of Weka algorithms. The question was how to do it?
Step 1: Download the latest version of Weka from here
Step 2: install the software
Step 3: Search for the “weka src jar” file on your computer. Typical location will be at “C:\Program Files\Weka-3-7\weka-src.jar”
Step 4: Now create a folder called “Data_Analysis” in your Documents or any convenient location you like. For example C:\Users\UserName\Documents\Data_Analysis
Step 5: Copy the wek-src.jar file found in Step 3 and paste it in the Data_Analysis folder at Step 4
Step 6: Extract the contents of the jar file using WinRar or WinZip software in a temporary folder in the Documents folder like temp. So after extraction, you should have folders like lib, src, meta-inf, test and build.xml file in the temp folder.
Now, move over to NetBeans IDE
Step 7: Open Netbeans IDE and create a new java application project as following. In the New Project dialog box that appears chose
- Categories: General
- Projects: Java Application
- Click on next button
In the Name and location appears
- Project Name: weka
- Project Location: C:\Users\UserName\Documents\Data_Analysis
- Project Folder: C:\Users\UserName\Documents\ Data_Analysis \weka
- Put tick mark in Set as Main project, create main class
- Fill the text box with “weka.gui.Main”
- Click on Finish button
Now the important step;
Step 8: in step 6, we had extracted the contents of the weka src jar folder. So browse to the location “C:\Users\UserName\Documents\temp\src\main\java\weka” and copy the folder, “weka”. Next, paste this folder into “C:\Users\UserName\Documents\DataAnalysis\src\main\java\weka”. You will see a warning message that there is already a folder called weka. Click on merge to continue.
Click on yes to all button
Step 9: Now switch to Net beans and click on Weka project and Source Package, we can observe that all the earlier files such as classification, gui, clustering, filters etc are dumped in to it.
Step 10: Click on Build Menu\Build Main Project, weka project will be compiled
Step 11: Click on Run Menu \Run Main Project, weka project will be executed
In the next sequel to this post we will see how to add a new algorithm in Weka in the Netbeans environment.