DataSet
public class DataSet
The DataSet class. This class represents a data set as a
“matrix” with cases as rows and variables as columns.
-
Constructs a new empty
DataSet.Declaration
Swift
public init() throws -
Constructs a
DataSetfrom a CSV-style file. Instead of a comma, a different separator character may be used.Declaration
Swift
public init (csvName: String, separator: Character) throwsParameters
csvNamethe name of the CSV file
separatorthe separator character (must not be a double-quote character)
-
Constructs a
DataSetfrom a CSV specification provided as a string. Instead of a comma, a different separator character may be used.See also
DataSet.toCSVString(Character)Declaration
Swift
public init (csvString: String, separator: Character) throwsParameters
csvStringthe CSV specification
separatorthe separator character (must not be a double-quote character)
-
Creates a new column in this DataSet.
Declaration
Swift
public func newColumn(name: String) throws -> IntParameters
namethe name of the new column
Return Value
the index of the new column
-
Creates a new row in this DataSet.
Declaration
Swift
public func newRow() throws -> IntReturn Value
the index of the new row
-
Deletes the specified column from this DataSet. Columns to the right of the deleted column will be shifted one position to the left.
Declaration
Swift
public func delete(column: Int) throwsParameters
columnthe index of the column to be deleted
-
Deletes the specified row from this DataSet. Rows below the deleted row will be shifted one position up.
Declaration
Swift
public func delete(row: Int) throwsParameters
rowthe index of the row to be deleted
-
Sets the name of the specified column of this DataSet.
Declaration
Swift
public func setColumnName(column: Int, name: String) throwsParameters
columnthe index of the column
namethe new name of the column
-
Returns the name of the specified column of this DataSet.
Declaration
Swift
public func getColumnName(column: Int) throws -> StringParameters
columnthe index of the column
-
Returns the number of columns in this DataSet.
Declaration
Swift
public func getNumberOfColumns() throws -> Int -
Returns the number of rows in this DataSet.
Declaration
Swift
public func getNumberOfRows() throws -> Int -
Moves the specified column to a new position. The columns between the old and the new column positions will be shifted one position to the left or to the right depending on the direction of the move.
Declaration
Swift
public func move(column: Int, to: Int) throwsParameters
columnthe index of the column to be moved
tothe index of the destination column
-
Moves the specified row to a new position. The rows between the old and the new row positions will be shifted one position up or down depending on the direction of the move.
Declaration
Swift
public func move(row: Int, to: Int) throwsParameters
rowthe index of the row to be moved
tothe index of the destination row
-
Sets (or deletes) the data item at the specified location of this DataSet.
Declaration
Swift
public func setDataItem(row: Int, column: Int, data: String?) throwsParameters
rowthe index of the row
columnthe index of the column
datathe new data item (a
nilvalue causes the item at the specified location to be deleted). -
Returns the data item at the specified location of this DataSet.
Declaration
Swift
public func getDataItem(row: Int, column: Int) throws -> String?Parameters
rowthe index of the row
columnthe index of the column
Return Value
The data item at the specified location (
nilif there is no data) -
Saves this
DataSetin the format of a comma-separated-values (CSV) file. However, a different character than a comma can be used to separate the values.Declaration
Swift
public func save(csvName: String, separator: Character) throwsParameters
csvNamethe name of the file in which to store the data
separatorthe delimiter character (must not be a double-quote character).
-
Creates a CSV representation (as a string) of this
DataSet.Declaration
Swift
public func toCSVString(separator: Character) throws -> StringParameters
separatorthe delimiter character (must not be a double-quote character).
Return Value
A string containing the CSV representation.
-
Creates a discretization of the numeric data in the specified column. The supervised discretization algorithm by Fayyad and Irani is used to create intervals for the numeric data in the column with index
valueColumn. The class data used to guide the discretization is contained in the column with indexclassColumn.Declaration
Swift
public func computeIEMIntervals (valueColumn: Int, classColumn: Int) throws -> [Double]Parameters
valueColumnthe index of the column to discretize
classColumnthe index of the column containing the class (or target) data.
Return Value
a list of real numbers (suitable for use as state values for an interval node).
DataSet Class Reference