The Data Mining Forum                             open-source data mining software data mining conferences Data Science for Social and Behavioral Analytics DSSBA 2022 data science journal
IMPORTANT: This is the old Data Mining forum.
I keep it online so that you can read the old messages.

Please post your new messages in the new forum: https://forum2.philippe-fournier-viger.com/index.php
 
Output path for results in KMeans and Apriori
Posted by: Dishita
Date: October 27, 2012 10:56PM

Hello,
I am new to Java. I run the test code for KMeans (with all the packages in the right folder as mentioned in the installation procedure). The code compiles error free and Builds the XML file too; But the needed results are not written to the output file given in the path.
The code:

package ca.pfv.spmf.tests;

import ca.pfv.spmf.clustering.kmeans.AlgoKMeans;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;

public class MainTestKMeans_saveToFile {

public static void main(String []args) throws NumberFormatException, IOException{

String input = fileToPath("configKmeans.txt" );
String output;
output = "C:\\patterns\\clusters.txt";

int k=3;

// Apply the algorithm
AlgoKMeans algoKMeans = new AlgoKMeans(); // we request 3 clusters
algoKMeans.runAlgorithm(input, k);
algoKMeans.printStatistics();
algoKMeans.saveToFile(output);

}

public static String fileToPath(String filename) throws UnsupportedEncodingException{
URL url = MainTestKMeans_saveToFile.class.getResource(filename);
return java.net.URLDecoder.decode(url.getPath(),"UTF-8" );
}


}

I tried explicitly creating the path and the file, but the code still wont write the result into it.
Please reply with a solution to this.
Thanks in advance

Options: ReplyQuote
Re: Output path for results in KMeans and Apriori
Date: October 28, 2012 05:49AM

Hi,

Welcome to the forum. It should works. I tested it on my computer and it works.

Could you tell me what is shown in the console when you run the algorithm? Is there some errors?

Are you using Eclipse? Please provide me some more information so that I can help you.

Best,
Philippe

Options: ReplyQuote
Re: Output path for results in KMeans and Apriori
Posted by: Dishita
Date: October 30, 2012 07:40AM

I tried it on both the IDEs- Eclipse and Netbeans.
I get 0 errors.
But when I search for the output in the specified path, I get nothing. :|
What could be the reason?

Options: ReplyQuote
Re: Output path for results in KMeans and Apriori
Date: October 30, 2012 07:57AM

There could be a problem with administrative rights on that drive (C:\) or folder? Maybe try changing the path for another path.

You could also update your Java installation...

I mean, it must be some kind of problem like that, because many people use this code and it works.

Philippe

Options: ReplyQuote
Re: Output path for results in KMeans and Apriori
Posted by: Dishita
Date: October 30, 2012 08:32AM

Changing path doesnt help, also am using the latest Java update.
Guess there is some other configuration fault that I cant figure. Thanks for the time, great work! smiling smiley

Options: ReplyQuote
Re: Output path for results in KMeans and Apriori
Date: October 30, 2012 08:37AM

Thanks. Hope you can find out what the problem is....

If you find out, please let me know.

Philippe

Options: ReplyQuote
Re: Output path for results in KMeans and Apriori
Posted by: Dishita
Date: October 30, 2012 09:54AM

Works fine on my other computer, so it was some system inconsistency I guess, will figure it out later.
Thanks smiling smiley

Options: ReplyQuote
Re: Output path for results in KMeans and Apriori
Date: October 30, 2012 04:48PM

Glad to know that!

Philippe

Options: ReplyQuote


This forum is powered by Phorum and provided by P. Fournier-Viger (© 2012).
Terms of use.