如何使用python-weka-wrapper实现pos_x与pos_y的预测?
问题描述
- 计划基于
python-weka-wrapper实现预测功能,通过循环逻辑完成自动化批量结果输出,目前程序始终无法正常运行 - 对照Weka图形界面的可正常复现操作流程:
- 启动Weka
- 进入Explorer功能页的Preprocess标签,导入目标arff格式数据文件
- 切换到Forecast标签页,选中需要预测的两个属性
- 点击Start按钮即可得到正常运行的输出结果
- 暂未定位到代码错误根源:不清楚如何在代码中实现目标属性选择逻辑,即指定待预测的字段
数据集样本
@relation data_new3 @attribute pos_x numeric @attribute pos_y numeric @attribute angle numeric @attribute vel numeric @attribute vel_x numeric @attribute vel_y numeric @data 414049364,21773560,75.06043,16.775027,15.827037,-5.559355 414049656,21773926,43.232657,4.452031,3.258594,-3.033504 414049938,21774287,43.836066,4.347145,4.300749,-0.633426 414050204,21774638,44.704315,4.157368,3.119995,2.747606
当前调试代码
import weka.core.jvm as jvm import weka.core.converters as conv from weka.classifiers import Evaluation, Classifier from weka.core.classes import Random import weka.plot.classifiers as plcls df = conv.load_any_file("data_new3.arff") df.class_is_last() cls = Classifier(classname="weka.classifiers.functions.LinearRegression", options=["-C","-S","1"]) evl = Evaluation(df) evl.crossvalidate_model(cls, df, 10, Random(1)) plcls.plot_classifier_errors(evl.predictions, absolute=False, wait=True)
现存代码适配问题
- 需求为预测
pos_x和pos_y两个属性,目前代码仅通过df.class_is_last()方法将数据集最后一个属性设为预测目标,无法匹配多目标预测的要求 - 如果移除类标签配置、将数据集设置为无类标签状态,代码会直接运行报错
- 无法复刻Weka图形界面中Forecast模块的多属性预测逻辑,找不到对应的代码实现入口
内容的提问来源于stack exchange,提问作者jonny5
相关产品推荐
相关产品推荐

