DataFrame.fromMatrix constructor

DataFrame.fromMatrix(
  1. Matrix matrix,
  2. {Iterable<String> header = const [],
  3. String autoHeaderPrefix = defaultHeaderPrefix,
  4. Iterable<int> columns = const [],
  5. Iterable<int> discreteColumns = const [],
  6. Iterable<String> discreteColumnNames = const []}
)

Create a DataFrame instance from a instance of Matrix

header A header row for the DataFrame instance. If no header provided, the row will be autogenerated

autoHeaderPrefix A string that will be used as a prefix of a column name in case of autogenerated header row. Default value is col_

columns Column indices to pick from the matrix

discreteColumns Column indices with discrete values. The information about discrete columns will be used for Series - to understand what is discrete data, please refer to Series documentation

A usage example:

import 'package:ml_dataframe/ml_dataframe.dart';
import 'package:ml_linalg/matrix.dart';

void main() {
  final matrix = Matrix.fromList(
    [10, 20, 30],
    [30, 30, 90],
    [60, 40, 70],
    [90, 50, 80],
  );
  final dataframe = DataFrame.fromMatrix(matrix,
    header: ['column', 'super_column', 'awesome_column']);

  print(dataframe);

  // DataFrame (4 x 3)
  // column super_column awesome_column
  //     10           20             30
  //     30           30             90
  //     60           40             70
  //     90           50             80
}

Implementation

factory DataFrame.fromMatrix(
  Matrix matrix, {
  Iterable<String> header = const [],
  String autoHeaderPrefix = defaultHeaderPrefix,
  Iterable<int> columns = const [],
  Iterable<int> discreteColumns = const [],
  Iterable<String> discreteColumnNames = const [],
}) =>
    fromMatrix(
      matrix,
      predefinedHeader: header,
      autoHeaderPrefix: autoHeaderPrefix,
      columns: columns,
      discreteColumns: discreteColumns,
      discreteColumnNames: discreteColumnNames,
    );