weka

How to merge two sets of weka Instances together

安稳与你 提交于 2019-12-06 05:44:12
Currently, I'm copying one instance at a time from one dataset to the other. Is there a way to do this so that string mappings remain intact? The mergeInstances works horizontally, is there an equivalent vertical merge? This is one step of a loop I use to read datasets of the same structure from multiple arff files into one large dataset. There has got to be a simpler way. Instances iNew = new ConverterUtils.DataSource(name).getDataSet(); for (int i = 0; i < iNew.numInstances(); i++) { Instance nInst = iNew.instance(i); inst.add(nInst); } Why not make a new ARFF file which has the data from

Principal Component Analysis on Weka

笑着哭i 提交于 2019-12-06 04:55:36
问题 I have just computed PCA on a training set and Weka returned me the new attributes with the way in which they were selected and computed. Now, I want to build a model using these data and then use the model on a test set. Do you know if there is a way to automatically modify the test set according to the new type of attributes? 回答1: Do you need the principal components for analysis or just to feed into the classifier? If not just use the Meta->FilteredClassifier classifier. Set the filter to

How to apply classifier in Weka's Explorer?

你说的曾经没有我的故事 提交于 2019-12-06 03:13:58
问题 Let's say, I've build a model (e.g. J4.8 tree) and evaluated it with cross-validation. How can I use this model to classify new dataset ? I know, I can set a file with the data to classify with "Supplied test set" option, mark "Output predictions" in "More options" window and run classification again. It will produce nearly what I need, but it seems to be a very strange workflow. Also, it re-creates all the model, which can take unnecessary time. Is there more straightforward way to do

How to use date type in weka in java code?

六月ゝ 毕业季﹏ 提交于 2019-12-06 03:06:41
I am trying to create training instances with one date attribute and one numeric attribute. I get error because of my date value. The error is: java.lang.IllegalArgumentException: Attribute neither nominal nor string! I guess I do not understand how to deal with this format. I have searched for it a lot but all of the examples are about using it in arff file and I couldn't find any example for java code. I will be so thankful if you could tell where I am going wrong or send me some links which could guide me through this problem. Here is the code: Attribute dateTimeAttribute = new Attribute(

weka: how to get class name from testing single instance

风格不统一 提交于 2019-12-06 02:03:41
i want to make a single test for single instance i use j48 in FilteredClassifier like this: Remove rm = new Remove(); rm.setAttributeIndices("1"); // remove 1st attribute // classifier J48 j48 = new J48(); j48.setUnpruned(true); // using an unpruned J48 // meta-classifier FilteredClassifier fc_J48 = new FilteredClassifier(); fc_J48.setFilter(rm); fc_J48.setClassifier(j48); tdta.dataSet.setClassIndex(tdta.dataSet.numAttributes() - 1); fc_J48.buildClassifier(tdta.dataSet); now, i try those options: j48.classifyInstance(dataSet.instance(1)) or eval.evaluateModelOnce(j48, dataSet.instance(1)) i

java weka stringtowordvector is not counting word occurences properly

▼魔方 西西 提交于 2019-12-05 21:00:22
so I'm using Weka Machine Learning Library's JAVA API and I have the following code: String html = "repeat repeat repeat"; Attribute input = new Attribute("html",(FastVector) null); FastVector inputVec = new FastVector(); inputVec.addElement(input); Instances htmlInst = new Instances("html",inputVec,1); htmlInst.add(new Instance(1)); htmlInst.instance(0).setValue(0, html); StringToWordVector filter = new StringToWordVector(); filter.setUseStoplist(true); filter.setInputFormat(htmlInst); Instances dataFiltered = Filter.useFilter(htmlInst, filter); Instance last = dataFiltered.lastInstance();

Using StringToWordVector in Weka with internal data structures

我的未来我决定 提交于 2019-12-05 20:58:45
I am trying to obtain document clustering using Weka. The process is a part of a larger pipeline, and I really can't afford to write out arff files. I have all the documents and the bag of words in each document as a Map<String, Multiset<String>> structure, where the keys are document names, and the Multiset<String> values are the bags of words in the documents. I have two questions, really: (1) Current approach ends up clustering terms, not documents: public final Instances buildDocumentInstances(TreeMap<String, Multiset<String>> docToTermsMap, String encoding) throws IOException { int

Weka only changing numeric to nominal

末鹿安然 提交于 2019-12-05 20:18:23
问题 I have a CSV file that I am importing into Weka. All variables are importing as numeric. I need to change 3 of them to nominal. However when I place numerictonominal filter on it- all variables change. I only want to change 3. 1) Is there a way to just change a few via the filter 2) Or can you set it during the import. If so, I can't figure that out either. 回答1: I assume you are using the Weka Explorer (GUI). To apply the filter to specific attributes do the following. Step 1: Select your

Which Weka and LibSVM .jar files to use in Java code for SVM classification

青春壹個敷衍的年華 提交于 2019-12-05 20:12:49
If I use Weka Explorer to run some training data against testing data using SVM with a linear kernel, everything is fine. But I need to do this programmatically in my own Java and my current code looks like this: Instances train = new Instances (...); train.setClassIndex(train.numAttributes() - 1); Instances test = new Instances (...) + ClassificationType classificationType = ClassificationTypeDAO.get(6); LibSVM libsvm = new LibSVM(); String options = (classificationType.getParameters()); String[] optionsArray = options.split(" "); libsvm.setOptions(optionsArray); String[] pars = libsvm

how to connect mysql databases in weka?

China☆狼群 提交于 2019-12-05 18:21:10
i want to use my mysql databases in weka in order to analysis data. i download the mysql-connector-java-5.0.8-bin.jar and put that in weka folder in my program Files folder, and add this path to system variable path, but when i open the weka explorer and click the openDB, i don't know what should i write in the url textbox, i don't know completely what should i do? the error that i saw is: problem connecting to database: no suitable driver found for! please give me a total guidance, thanks in advance. houssam add mysql-connector-java-5.1.12-bin.jar to CLASSPATH . or put it in weka folder,