GitXplorerGitXplorer
c

ArffTools

public
4 stars
1 forks
1 issues

Commits

List of commits on branch master.
Unverified
2a510d851ae508145daf4bebd3738671661c1678

Bump version to 1.1.3

cchausner committed 3 years ago
Unverified
26c23b0a4758d224df40d87f44801bccf300dd0a

Change target framework to .NET 5.0, update projects

cchausner committed 3 years ago
Unverified
35e03c33e9866fde42cf81b626cad5ebf201520b

Bump version to 1.1.2.

cchausner committed 8 years ago
Unverified
e81f1e865454109fb62cbd762efbd2da95f1b3d7

Update MSTest NuGet dependencies

cchausner committed 8 years ago
Unverified
ac9d792db23e54a830ce9d43898b1c37ba4d8bb1

Allow enums (with underlying type int) to represent nominal values in instances

cchausner committed 8 years ago
Unverified
f5408274477976f860330e895a179fae5fdac9ae

Implement ToString() method for ArffAttribute, ArffAttributeType and ArffHeader

cchausner committed 8 years ago

README

The README file for this repository.

ArffTools

.NET library for reading and writing Weka attribute-relation file format (ARFF) files

NuGet license

Features

  • Read and write ARFF files
  • Supports relational attributes
  • Supports sparse instances
  • Supports instance weights
  • Proper quoting and escaping of special characters

Usage

Reading ARFF files:

using (ArffReader arffReader = new ArffReader("glass.arff"))
{
    ArffHeader header = arffReader.ReadHeader();    
    object[] instance;    
    while ((instance = arffReader.ReadInstance()) != null)
    {
        // process instance
    }    
}

Reading all instances at a time:

object[][] instances = arffReader.ReadAllInstances();

Writing ARFF files:

using (ArffWriter arffWriter = new ArffWriter("iris.arff"))
{
    arffWriter.WriteRelationName("iris");
    arffWriter.WriteAttribute(new ArffAttribute("sepallength", ArffAttributeType.Numeric));
    arffWriter.WriteAttribute(new ArffAttribute("sepalwidth", ArffAttributeType.Numeric));
    arffWriter.WriteAttribute(new ArffAttribute("petallength", ArffAttributeType.Numeric));
    arffWriter.WriteAttribute(new ArffAttribute("petalwidth", ArffAttributeType.Numeric));
    arffWriter.WriteAttribute(new ArffAttribute("class", ArffAttributeType.Nominal("Iris-setosa", "Iris-versicolor", "Iris-virginica")));
    arffWriter.WriteInstance(new object[] { 5.1, 3.5, 1.4, 0.2, 0 });
}

Instances are represented as object[] whose elements correspond to the attribute values. ARFF attribute types are mapped to .NET types as follows:

ARFF attribute type .NET type
numeric, integer, real double
nominal int
string string
date DateTime
relational object[][]

Missing values are represented as null. Sparse instances are represented as normal instances in memory.