RandomBinaryProjectionSearcher.fromJson constructor

RandomBinaryProjectionSearcher.fromJson(
  1. String jsonSource
)

Creates a RandomBinaryProjectionSearcher instance from a JSON-serializable object. The constructor works in conjunction with saveAsJson method. The latter serializes the instance and save the output to a JSON-file.

Example:

import 'dart:io';
import 'package:ml_algo/ml_algo.dart';
import 'package:ml_dataframe/ml_dataframe.dart';

void main() async {
  final data = DataFrame([
    ['feature_1', 'feature_2', 'feature_3']
    [10, 20, 30],
    [11, 19, 31],
    [19, 43, 20],
    [89, 97, 11],
    [12, 32, 10],
  ]);
  final digitCapacity = 3;

  final searcher = RandomBinaryProjectionSearcher(data, digitCapacity, seed: 4);

  await searcher.saveAsJson('path/to/json/file');

  // ...

  final file = File('path/to/json/file');
  final jsonSource = await file.readAsString();

  final restoredSearcher = RandomBinaryProjectionSearcher.fromJson(jsonSource);

  print(searcher.columns);
  // (feature_1, feature_2, feature_3)

  print(searcher.points);
  // Matrix 5 x 3:
  // (10.0, 20.0, 30.0)
  // (11.0, 19.0, 31.0)
  // (19.0, 43.0, 20.0)
  // (89.0, 97.0, 11.0)
  // (12.0, 32.0, 10.0)

  print(searcher.seed);
  // 4

  print(searcher.digitCapacity);
  // 3
}

Implementation

factory RandomBinaryProjectionSearcher.fromJson(String jsonSource) =
    RandomBinaryProjectionSearcherImpl.fromJson;