sklite 0.0.1
SkLite-dart #
- Porting Scikit-Learn models to Flutter *
Getting Started #
The library uses pre-trained models using scikit-learn and sklite for python. Once built and exported, the models can be used in Flutter with ease. You need to load them inside your application and use them accordingly to your case:
You need to setup a local static directory where you can store the generated JSON file using sklite.
Put sklite in your pubspec.yaml file, import whichever model it is you intend to use and use the predict
method as you would in scikit-learn. Use the
loadModel
in utils/dart.io for your application, the other functions are for development and testing only.
Supported models #
IMPLEMENTATION | STATUS |
---|---|
KNeighborsClassifier | ✓ |
SVC | ✓ |
GaussianProcessClassifier | |
DecisionTreeClassifier | ✓ |
RandomForestClassifier | ✓ |
MLPClassifier | ✓ |
AdaBoostClassifier | |
GaussianNB | ✓ |
QuadraticDiscriminantAnalysis | |
BernoulliNB | ✓ |
LinearSVC | ✓ |
Usage #
You first need to add the library to your project's pubspec.yaml. For the time being the library hasn't been published to pub.dev (should be soon enough though).
dependencies:
sklite:
git:
url: https://github.com/axegon/SkLite-dart.git
Add a static assets directory inside your Flutter project:
flutter:
uses-material-design: true
assets:
- assets/
Put the generated model using sklite for python in the specified directory
Import the library in your application and load the model:
import 'package:flutter/material.dart';
import 'package:sklite/SVM/SVM.dart';
import 'package:sklite/utils/io.dart';
import 'dart:convert';
void main() => runApp(new MaterialApp(
home: new HomePage(),
debugShowCheckedModeBanner: false)
);
class HomePage extends StatefulWidget {
@override
_HomePageState createState() {
return new _HomePageState();
}
}
class _HomePageState extends State<HomePage> {
SVC svc;
_HomePageState() {
loadModel("assets/svcmnist.json").then((x) {
this.svc = SVC.fromMap(json.decode(x));
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
// add any widget with svc.predict() callback
);
}
[0.0.1] - TODO: Add release date.
- TODO: Describe initial release.
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies:
sklite: ^0.0.1
2. Install it
You can install packages from the command line:
with Flutter:
$ flutter pub get
Alternatively, your editor might support flutter pub get
.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
import 'package:sklite/SVM/SVM.dart';
import 'package:sklite/base.dart';
import 'package:sklite/ensemble/forest.dart';
import 'package:sklite/naivebayes/naive_bayes.dart';
import 'package:sklite/neighbors/neighbors.dart';
import 'package:sklite/neural_network/neural_network.dart';
import 'package:sklite/pipeline/pipeline.dart';
import 'package:sklite/tree/tree.dart';
import 'package:sklite/utils/exceptions.dart';
import 'package:sklite/utils/io.dart';
import 'package:sklite/utils/mathutils.dart';
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
36
|
Health:
Code health derived from static analysis.
[more]
|
100
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
70
|
Overall:
Weighted score of the above.
[more]
|
62
|
We analyzed this package on Dec 9, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.6.1
- pana: 0.12.21
- Flutter: 1.9.1+hotfix.6
Health suggestions
Fix lib/SVM/SVM.dart
. (-0.50 points)
Analysis of lib/SVM/SVM.dart
reported 1 hint:
line 74 col 14: The value of the local variable 'decision' isn't used.
Format lib/base.dart
.
Run flutter format
to format lib/base.dart
.
Format lib/ensemble/forest.dart
.
Run flutter format
to format lib/ensemble/forest.dart
.
Format lib/pipeline/pipeline.dart
.
Run flutter format
to format lib/pipeline/pipeline.dart
.
Format lib/utils/io.dart
.
Run flutter format
to format lib/utils/io.dart
.
Maintenance suggestions
The package description is too short. (-20 points)
Add more detail to the description
field of pubspec.yaml
. Use 60 to 180 characters to describe the package, what it does, and its target use case.
Package is pre-v0.1 release. (-10 points)
While nothing is inherently wrong with versions of 0.0.*
, it might mean that the author is still experimenting with the general direction of the API.
Maintain an example.
None of the files in the package's example/
directory matches known example patterns.
Common filename patterns include main.dart
, example.dart
, and sklite.dart
. Packages with multiple examples should provide example/README.md
.
For more information see the pub package layout conventions.
Dependencies
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=2.1.0 <3.0.0 | ||
flutter | 0.0.0 | ||
Transitive dependencies | |||
collection | 1.14.11 | 1.14.12 | |
meta | 1.1.7 | 1.1.8 | |
sky_engine | 0.0.99 | ||
typed_data | 1.1.6 | ||
vector_math | 2.0.8 | ||
Dev dependencies | |||
flutter_test |