Machine learning 使用weka对word2vec进行分类

Machine learning 使用weka对word2vec进行分类,machine-learning,classification,weka,word2vec,multilabel-classification,Machine Learning,Classification,Weka,Word2vec,Multilabel Classification,我已经在大约70k个句子的语料库上训练了word2vec模型。每个句子都包含一个独特的关键字,如“abc-2011-100”,后面是描述它的某些特征。现在,我必须为每个abc id分类。像abc-2011-100属于abc_类别_1。abc-2999-0000属于abc_类_20等。一个类别可以分配多个abc id。我有大约70000个独特的abc Id。在这70000人中,5000人已被适当分类。现在我想检查我对已经分类的5000个id的分类准确性。为此,我将80%作为培训数据,20%用于检查

我已经在大约70k个句子的语料库上训练了word2vec模型。每个句子都包含一个独特的关键字,如“abc-2011-100”,后面是描述它的某些特征。现在,我必须为每个abc id分类。像abc-2011-100属于abc_类别_1。abc-2999-0000属于abc_类_20等。一个类别可以分配多个abc id。我有大约70000个独特的abc Id。在这70000人中,5000人已被适当分类。现在我想检查我对已经分类的5000个id的分类准确性。为此,我将80%作为培训数据,20%用于检查准确性。我可以把每个abc id描述为一个d维向量。使用这些信息,我如何使用weka来运行此分类任务。?如果您有任何意见,我们将不胜感激

首先,阅读您的csv/arff:

import weka.core.Instances;
import java.io.BufferedReader;
import java.io.FileReader;
...
BufferedReader reader = new BufferedReader(new FileReader("yourData.arff"));
Instances data = new Instances(reader);
reader.close();
// setting class attribute
data.setClassIndex(data.numAttributes() - 1); // This is category for you
然后实例化并训练分类器

 import weka.classifiers.trees.J48;
 ...
 String[] options = new String[1];
 options[0] = "-U";            // unpruned tree
 J48 tree = new J48();         // new instance of tree
 tree.setOptions(options);     // set the options
 tree.buildClassifier(data);   // build classifier
运行交叉验证以评估学员

import weka.classifiers.Evaluation;
import java.util.Random;
...
Evaluation eval = new Evaluation(data);
eval.crossValidateModel(tree, data, 10, new Random(1));
或者单独进行培训和测试

import weka.core.Instances;
import weka.classifiers.Evaluation;
import weka.classifiers.trees.J48;
...
/* train and test are of type Instances (see above) */
// train classifier
Classifier cls = new J48();
cls.buildClassifier(train);
// evaluate classifier and print some statistics
Evaluation eval = new Evaluation(train);
eval.evaluateModel(cls, test);
System.out.println(eval.toSummaryString("\nResults\n======\n", false));

首先,阅读您的csv/arff:

import weka.core.Instances;
import java.io.BufferedReader;
import java.io.FileReader;
...
BufferedReader reader = new BufferedReader(new FileReader("yourData.arff"));
Instances data = new Instances(reader);
reader.close();
// setting class attribute
data.setClassIndex(data.numAttributes() - 1); // This is category for you
然后实例化并训练分类器

 import weka.classifiers.trees.J48;
 ...
 String[] options = new String[1];
 options[0] = "-U";            // unpruned tree
 J48 tree = new J48();         // new instance of tree
 tree.setOptions(options);     // set the options
 tree.buildClassifier(data);   // build classifier
运行交叉验证以评估学员

import weka.classifiers.Evaluation;
import java.util.Random;
...
Evaluation eval = new Evaluation(data);
eval.crossValidateModel(tree, data, 10, new Random(1));
或者单独进行培训和测试

import weka.core.Instances;
import weka.classifiers.Evaluation;
import weka.classifiers.trees.J48;
...
/* train and test are of type Instances (see above) */
// train classifier
Classifier cls = new J48();
cls.buildClassifier(train);
// evaluate classifier and print some statistics
Evaluation eval = new Evaluation(train);
eval.evaluateModel(cls, test);
System.out.println(eval.toSummaryString("\nResults\n======\n", false));

也许最好是在家里问这个问题。无论如何,这是一个标准的分类任务。您可以使用不同的分类技术,如支持向量机、贝叶斯分类器、逻辑回归等。也许最好在中问这个问题。无论如何,这是一个标准的分类任务。您可以使用不同的分类技术,如支持向量机、贝叶斯分类器、逻辑回归等@KshitijG Yes。请参阅或。@KshitijG是。看到或看到。