FCNN4R (version 0.6.2)

read-write-fcnndataset: Reading and writing datasets in the FCNN format

Description

These functions can be used to read and write datasets from/to a text file in the FCNN format. Datasets in the similar FANN format (comments are not supported by FANN) can also be read by read.fcnndataset.

Usage

read.fcnndataset(fname)
write.fcnndataset(fname, input, output)

Arguments

fname
character string with the filename
input
numeric matrix, each row corresponds to one input vector
output
numeric matrix with rows corresponding to expected outputs, the number of rows must be equal to the number of input rows

Value

read.fcnndataset returns a dataframe.write.fcnndataset does not return.

Details

Files are organised as follows:
  • The first comment (beginning with #) is the dataset information (ignored on read),
  • three numbers determine: number of records, no. of inputs and no. of outputs,
  • each data record has two or three lines:
    • (optional) record information in a comment (beginning with #),
    • line with input values,
    • line with output values.

Examples

Run this code

# set up the XOR problem inputs and outputs
inp <- c(0, 0, 1, 1, 0, 1, 0, 1)
dim(inp) <- c(4, 2)
outp <- c(0, 1, 1, 0)
dim(outp) <- c(4, 1)
# write dataset
write.fcnndataset("xor.dat", inp, outp)
# show the output file
file.show("xor.dat")
# read dataset
xordf <- read.fcnndataset("xor.dat")
# show the imported dataset
show(xordf)

Run the code above in your browser using DataLab