简体   繁体   中英

How forecast using python-weka wrapper?

I'm trying to use forecast using python-weka-wrapper to automatize (loop) results. However, I couldn't make it wrong. This is a sample of my data:

@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

This is my current code:

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)

Following the steps I've used in Weka with a screenshota and works:

enter image description here

In order to reduce imatges, I'll explain the previous steps in text: 1-Open Weka 2-Go to Explorer->Preprocess->Open File (selected data_new3.arff) 3-Go to Forecast tab and select the two attributes to forecast 4-Click Start

I guess there are some errors in my code which I don't know how to solve. How to choose attributes to forecast "target selection". So, I want to forecast pos_x and pos_y, I know that I'm using class_is_last(), however, whether I choose no_class or remove this option, the code fails.

Any clue?

Forecasting is different from making predictions with a classifier.

See my answer to the following post: Why I get wrong forecast values python-weka wrapper

BTW The other person pretty much asked the same question. Was that you using a different account?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM