gpt4 book ai didi

java - Apriori 算法给出内存位置

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:23:30 25 4
gpt4 key购买 nike

我的应用程序需要通过Apriori 算法 获取关联。为了获得结果,我使用 Weka 依赖项。虽然我想获得关联,但它会打印内存位置。我也附上了输出。谢谢。

这是我的代码:

public class App 
{
static Logger log = Logger.getLogger(App.class.getName());
public static BufferedReader readDataFile(String filename) {
BufferedReader inputReader = null;

try {
inputReader = new BufferedReader(new FileReader(filename));
} catch (FileNotFoundException ex) {
}
return inputReader;
}
public static void main( String[] args ) throws Exception {
//Define ArrayList to Add Clustered Information
ArrayList<FastVector[]> associationInfoArrayList = new ArrayList<FastVector[]>();
Apriori apriori = new Apriori();
apriori.setNumRules(15);
BufferedReader datafile = readDataFile("/media/jingi_ingi/IR1_CPRA_X6/Documents/ss.arff");
Instances data = new Instances(datafile);
// Instances instances = new Instances(datafile);
apriori.buildAssociations(data);
log.debug("Testing Apriori Algo Results Started ....");
log.debug("-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-");
log.debug("Number of Associations : " + apriori.getNumRules());
log.debug("Adding Association Information to ArrayList ..");

Object objectArrayOfAssociations[] = new Object[apriori.getNumRules()];
log.debug(apriori.getAllTheRules().toString());

for(int i=0; i<apriori.getNumRules(); i++) {
objectArrayOfAssociations[i] = apriori.getAllTheRules();
log.debug("Associations Discovered : " + objectArrayOfAssociations[i].toString());
}
}
}

应用程序的输出:

2015-04-05 20:16:42 DEBUG App:48 - Associations Discovered : [Lweka.core.FastVector;@19a96bae

2015-04-05 20:16:42 DEBUG App:48 - Associations Discovered : [Lweka.core.FastVector;@19a96bae

2015-04-05 20:16:42 DEBUG App:48 - Associations Discovered : [Lweka.core.FastVector;@19a96bae

2015-04-05 20:16:42 DEBUG App:48 - Associations Discovered : [Lweka.core.FastVector;@19a96bae

最佳答案

apriori.getAllTheRules() 

返回一个 FastVectors 数组,但 FastVector 没有 toString() 方法来按照您的意图转储其内容。您可以扩展 FastVector 并添加您自己的 toString() 或编写一些辅助方法来根据需要转储内容。 Here's an example

类似于:

for(FastVector fastVector : apriori.getAllTheRules())  
log.debug(fastVector.getRevision());
// or whichever attribute you want to show

关于java - Apriori 算法给出内存位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29458909/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com