ml_algo 9.2.1 copy "ml_algo: ^9.2.1" to clipboard
ml_algo: ^9.2.1 copied to clipboard

outdated

Machine learning algorithms written in native dart (without bindings to any popular ML libraries, just pure Dart implementation)

example/main.dart

import 'dart:async';

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

/// A simple usage example using synthetic data. To see more complex examples,
/// please, visit other directories in this folder
Future main() async {
  // Let's create a feature matrix (a set of independent variables)
  final features = Matrix.from([
    [2.0, 3.0, 4.0, 5.0],
    [12.0, 32.0, 1.0, 3.0],
    [27.0, 3.0, 0.0, 59.0],
  ]);

  // Let's create dependent variables vector. It will be used as `true` values
  // to adjust regression coefficients
  final labels = Matrix.from([
    [4.3],
    [3.5],
    [2.1]
  ]);

  // Let's create a regressor itself. With its help we can train some linear
  // model to predict label values for new features
  final regressor = LinearRegressor.gradient(
      iterationsLimit: 100,
      initialLearningRate: 0.0005,
      learningRateType: LearningRateType.constant);

  // Let's train our model (training or fitting is a coefficients
  // adjusting process)
  regressor.fit(features, labels);

  // Let's see adjusted coefficients
  print('Regression coefficients: ${regressor.weights}');
}
103
likes
0
pub points
82%
popularity

Publisher

verified publisherml-algo.com

Machine learning algorithms written in native dart (without bindings to any popular ML libraries, just pure Dart implementation)

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

csv, logging, ml_linalg, tuple

More

Packages that depend on ml_algo