日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > java >内容正文

java

java项目中怎么查看用的序列_如何在Java应用程序中使用序列化分类器对...

發(fā)布時間:2025/4/5 java 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java项目中怎么查看用的序列_如何在Java应用程序中使用序列化分类器对... 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

我想使用序列化分類器對新實例進(jìn)行分類.我找到了這堂課,但我聽不懂.

arg [2] =類屬性名稱,arg [3] =基于實例的索引(從原始數(shù)據(jù)集中進(jìn)行預(yù)測)

這是此類的代碼:

import weka.core.*;

import weka.classifiers.*;

import java.io.*;

/**

* A little class for testing deserialization and prediction.

*

* @author FracPete (fracpet at waikat dot ac dot nz)

*/

public class Blah {

/**

* Takes 4 arguments:

*

*

serialized model

*

ARFF file

*

class attribute name

*

1-based index of an instance to predict from original dataset

*

*/

public static void main(String[] args) throws Exception {

// read the arff training file

BufferedReader reader = new BufferedReader(new FileReader(args[1]));

Instances in = new Instances(reader);

in.setClass(in.attribute(args[2]));

// instance to classify

int index = Integer.parseInt(args[3]) - 1;

Instance toClassifyInstance = (Instance) in.instance(index).copy();

toClassifyInstance.setClassValue(Instance.missingValue());

// deserialize model

Classifier cls = null;

ObjectInputStream ois = new ObjectInputStream(new FileInputStream(args[0]));

cls = (Classifier) ois.readObject();

ois.close();

// PREDICTION

double clsLabel = cls.classifyInstance(toClassifyInstance);

String classLabel = in.classAttribute().value((int) clsLabel);

System.out.println(classLabel + " =?= " + in.instance(index).stringValue(in.classIndex()));

}

}

提前致謝.

總結(jié)

以上是生活随笔為你收集整理的java项目中怎么查看用的序列_如何在Java应用程序中使用序列化分类器对...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。