Skip to main content

A module for read and write ARFF files in Python.

Project description

https://travis-ci.org/renatopp/liac-arff.svg

The liac-arff module implements functions to read and write ARFF files in Python. It was created in the Connectionist Artificial Intelligence Laboratory (LIAC), which takes place at the Federal University of Rio Grande do Sul (UFRGS), in Brazil.

ARFF (Attribute-Relation File Format) is an file format specially created for describe datasets which are used commonly for machine learning experiments and softwares. This file format was created to be used in Weka, the best representative software for machine learning automated experiments.

You can clone the arff-datasets repository for a large set of ARFF files.

Features

  • Read and write ARFF files using python built-in structures, such dictionaries and lists;

  • Supports scipy.sparse.coo and lists of dictionaries as used by SVMLight

  • Supports the following attribute types: NUMERIC, REAL, INTEGER, STRING, and NOMINAL;

  • Has an interface similar to other built-in modules such as json, or zipfile;

  • Supports read and write the descriptions of files;

  • Supports missing values and names with spaces;

  • Supports unicode values and names;

  • Fully compatible with Python 2.6+ and Python 3.3+;

  • Under MIT License

How To Install

Via pip:

$ pip install liac-arff

Via easy_install:

$ easy_install liac-arff

Manually:

$ python setup.py install

Documentation

For a complete description of the module, consult the official documentation at http://packages.python.org/liac-arff/ with mirror in http://inf.ufrgs.br/~rppereira/docs/liac-arff/index.html

Usage

You can read an ARFF file as follows:

>>> import arff
>>> data = arff.load(open('wheater.arff', 'rb'))

Which results in:

>>> data
{
    u'attributes': [
        (u'outlook', [u'sunny', u'overcast', u'rainy']),
        (u'temperature', u'REAL'),
        (u'humidity', u'REAL'),
        (u'windy', [u'TRUE', u'FALSE']),
        (u'play', [u'yes', u'no'])],
    u'data': [
        [u'sunny', 85.0, 85.0, u'FALSE', u'no'],
        [u'sunny', 80.0, 90.0, u'TRUE', u'no'],
        [u'overcast', 83.0, 86.0, u'FALSE', u'yes'],
        [u'rainy', 70.0, 96.0, u'FALSE', u'yes'],
        [u'rainy', 68.0, 80.0, u'FALSE', u'yes'],
        [u'rainy', 65.0, 70.0, u'TRUE', u'no'],
        [u'overcast', 64.0, 65.0, u'TRUE', u'yes'],
        [u'sunny', 72.0, 95.0, u'FALSE', u'no'],
        [u'sunny', 69.0, 70.0, u'FALSE', u'yes'],
        [u'rainy', 75.0, 80.0, u'FALSE', u'yes'],
        [u'sunny', 75.0, 70.0, u'TRUE', u'yes'],
        [u'overcast', 72.0, 90.0, u'TRUE', u'yes'],
        [u'overcast', 81.0, 75.0, u'FALSE', u'yes'],
        [u'rainy', 71.0, 91.0, u'TRUE', u'no']
    ],
    u'description': u'',
    u'relation': u'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

https://github.com/renatopp/liac-arff

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

liac-arff-2.1.0.zip (16.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

liac-arff-2.1.0.win32.exe (213.0 kB view details)

Uploaded Source

File details

Details for the file liac-arff-2.1.0.zip.

File metadata

  • Download URL: liac-arff-2.1.0.zip
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for liac-arff-2.1.0.zip
Algorithm Hash digest
SHA256 be6b5b76698d5fca1f24d75c98ed9c0ff5e24eb0d985d01cfd26c08a70f9654e
MD5 855148547896b089dbca8f987a229cd0
BLAKE2b-256 0b2eb2f38bbfe62fc87612f38d3ece0a917e0f2812369e0c73c298a3d1e7cc19

See more details on using hashes here.

File details

Details for the file liac-arff-2.1.0.win32.exe.

File metadata

  • Download URL: liac-arff-2.1.0.win32.exe
  • Upload date:
  • Size: 213.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for liac-arff-2.1.0.win32.exe
Algorithm Hash digest
SHA256 c23cd4cc4c127b9239bc387be514eb774901fdd4dad23ff9d312015896256c25
MD5 7f94635fe5bca202a0c18957aaccc342
BLAKE2b-256 1fccb83cbc8bc6c826ab0cc8e04448d8347157460daae789265440d218e0850e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page