Giter VIP home page Giter VIP logo

sklite-dart's Introduction

SkLite-dart

SkLite Demo App

  • 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: ^0.0.1

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
    );
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.