A library for read and write ARFF files in Python
Project description
The liac-arff module implements functions to read and write ARFF files in Python.
Attribute Relationship File Format (ARFF ) is the text format file used by Weka to store data in a database. This module is an ARFF file handler based on other python parser modules (such json and yaml).
Features
Read and Write ARFF files using python built-in structures;
Supports NUMERIC, REAL, INTEGER, STRING and NOMINAL attribute types;
Supports names with space;
Read and Write the description of the file;
MIT license;
Install
Via easy_install:
$ easy_install liac-arff
Manually:
$ python setup.py install
Usage
You can read an ARFF file as follows:
>>> import arff
>>> data = arff.load(open('wheater.arff', 'rb'))
Which results in:
>>> data
{
'attributes': [
('outlook', ['sunny', 'overcast', 'rainy']),
('temperature', 'REAL'),
('humidity', 'REAL'),
('windy', ['TRUE', 'FALSE']),
('play', ['yes', 'no'])],
'data': [
['sunny', 85.0, 85.0, 'FALSE', 'no'],
['sunny', 80.0, 90.0, 'TRUE', 'no'],
['overcast', 83.0, 86.0, 'FALSE', 'yes'],
['rainy', 70.0, 96.0, 'FALSE', 'yes'],
['rainy', 68.0, 80.0, 'FALSE', 'yes'],
['rainy', 65.0, 70.0, 'TRUE', 'no'],
['overcast', 64.0, 65.0, 'TRUE', 'yes'],
['sunny', 72.0, 95.0, 'FALSE', 'no'],
['sunny', 69.0, 70.0, 'FALSE', 'yes'],
['rainy', 75.0, 80.0, 'FALSE', 'yes'],
['sunny', 75.0, 70.0, 'TRUE', 'yes'],
['overcast', 72.0, 90.0, 'TRUE', 'yes'],
['overcast', 81.0, 75.0, 'FALSE', 'yes'],
['rainy', 71.0, 91.0, 'TRUE', 'no']],
'description': u'',
'relation': 'weather'
}
You can write an ARFF file with this structure:
>>> print arff.dumps(data)
@RELATION weather
@ATTRIBUTE outlook {sunny, overcast, rainy}
@ATTRIBUTE temperature REAL
@ATTRIBUTE humidity REAL
@ATTRIBUTE windy {TRUE, FALSE}
@ATTRIBUTE play {yes, no}
@DATA
sunny,85.0,85.0,FALSE,no
sunny,80.0,90.0,TRUE,no
overcast,83.0,86.0,FALSE,yes
rainy,70.0,96.0,FALSE,yes
rainy,68.0,80.0,FALSE,yes
rainy,65.0,70.0,TRUE,no
overcast,64.0,65.0,TRUE,yes
sunny,72.0,95.0,FALSE,no
sunny,69.0,70.0,FALSE,yes
rainy,75.0,80.0,FALSE,yes
sunny,75.0,70.0,TRUE,yes
overcast,72.0,90.0,TRUE,yes
overcast,81.0,75.0,FALSE,yes
rainy,71.0,91.0,TRUE,no
%
%
%
Contributors
Project Page
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file liac-arff-1.1.zip.
File metadata
- Download URL: liac-arff-1.1.zip
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3cd79873c628352b3c931de528ca2355d9f1cca84f5fa6740e8830a8d200d01
|
|
| MD5 |
a1072cb6616ddc6b1a07beb16ea9eace
|
|
| BLAKE2b-256 |
682f19aacc2b36cfe21b5cd8b89c5d270564733bd6b3a2df808fec64f343480d
|