8

I have a JSON file and want to open the data in weka, but when I do, I get the following error: weka failed to load JSON file due to NullPointerException

Looking around on the mailing list, there are a few questions about JSON, but TL;DR except that I noticed talk of JSON in the "format weka expects". Of course, there was no mention of what that format is. About to take a dive in the source, but I hope SO users can help before I spend too much time on this.

1 Answer 1

9

To gain an understanding about the format of the JSON object and its relationship to ARFF. The steps were surprisingly simple. Use the GUI tool to do the following:

  1. Select the Explorer Option
  2. Select open file on the preprocess tab
  3. Load any of the default supplied ARFF files
  4. The select save which you can then choose the JSON extension

basically every JSON file must have: {header:{ relation: , attributes:[{},{}],data:[{},{}]}}}

Hope this helps

{"houses":{
"relation":"house",
"attributes":{
    "houseSize":["NUMERIC"],
    "lotSize":
    "bedrooms":
    "granite":
    "bathroom":
    "sellingPrice":
},
"data":[
    [3529,9191,6,0,0,205000 ],
    [3247,10061,5,1,1,224900],
    [4032,10150,5,0,1,197900 ],
    [2397,14156,4,1,0,189900 ],
    [2200,9600,4,0,1,195000],
    [3536,19994,6,1,1,325000 ],
    [2983,9365,5,0,1,230000]
]}}

The attributes can have more information specified to them as follows:

{"contact_lenses":{
"relation": "contact-lenses",
"attributes" : {
    "age":["young", "pre-presbyopic", "presbyopic"],
    "spectacle-prescrip":["myope", "hypermetrope"],
    "astigmatism":["no", "yes"],
    "tear-prod-rate":["reduced", "normal"],
    "contact-lenses":["soft", "hard", "none"]
    },
"data":[]
}

}

2
  • So you're saying that the best bet is to load data from an ARFF, save as JSON, and see if I can understand what weka thinks is valid JSON? That's not a bad idea. Would be nice if someone did that and posted the result here.
    – Pat
    Commented May 21, 2012 at 15:47
  • I include a generic representation of the JSON file... in the last sentence. If that is not enough help I can post it up after.
    – kyleED
    Commented May 22, 2012 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.