https://github.com/chausner/arfftools
Library for reading and writing Weka attribute-relation file format (ARFF) files
https://github.com/chausner/arfftools
arff data-mining machine-learning weka
Last synced: 8 months ago
JSON representation
Library for reading and writing Weka attribute-relation file format (ARFF) files
- Host: GitHub
- URL: https://github.com/chausner/arfftools
- Owner: chausner
- License: mit
- Created: 2016-08-03T23:13:42.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2022-02-06T11:41:25.000Z (over 4 years ago)
- Last Synced: 2025-08-01T04:34:16.592Z (11 months ago)
- Topics: arff, data-mining, machine-learning, weka
- Language: C#
- Size: 43 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ArffTools
.NET library for reading and writing Weka attribute-relation file format (ARFF) files
[](https://www.nuget.org/packages/ArffTools/)
[](https://github.com/chausner/ArffTools/blob/master/LICENSE.md)
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:
```csharp
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:
```csharp
object[][] instances = arffReader.ReadAllInstances();
```
Writing ARFF files:
```csharp
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.