From f66668d4160cb14a7d76cade8593d6290318218e Mon Sep 17 00:00:00 2001 From: Dan Crescimanno Date: Wed, 18 May 2022 22:37:40 -0700 Subject: [PATCH] updated readme --- README.md | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 3af37d66..d755753a 100644 --- a/README.md +++ b/README.md @@ -21,34 +21,33 @@ Documentation site: [www.scikitjs.org](https://www.scikitjs.org) For use with modern bundlers in a frontend application, simply ```bash +npm i @tensorflow/tfjs npm i scikitjs ``` -Usage is similar to other js libraries. +We depend on the tensorflow library in order to make our calculations fast, but we don't ship it in our bundle. +We use it as a peer dependency. General usage is as follows. ```js -import { LinearRegression } from 'scikitjs' +import * as tf from '@tensorflow/tfjs' +import * as sk from 'scikitjs' +sk.setBackend(tf) ``` +This allows us to build a library that can be used in Deno, Node, and the browser with the same configuration. ### Backend Users -For Node.js users who wish to bind to the Tensorflow C++ library, simply +For Node.js users who wish to bind to the Tensorflow C++ library, simply import the tensorflow C++ version, and use that as the tf library ```bash +npm i @tensorflow/tfjs-node npm i scikitjs ``` -But then import the node bindings - -```js -import { LinearRegression } from 'scikitjs/node' -``` - -The `scikitjs/node` path uses the new "exports" feature of node (which is available in node v13.3+). -If you are using an older version of node, simply pass in the path to the cjs build - ```js -import { LinearRegression } from 'scikitjs/dist/cjs/index.js' +import * as tf from '@tensorflow/tfjs-node' +import * as sk from 'scikitjs' +sk.setBackend(tf) ``` ### Script src @@ -57,16 +56,21 @@ For those that wish to use script src tags, simply ```html ``` ## Simple Example ```js -import { LinearRegression } from 'scikitjs' +import * as tf from '@tensorflow/tfjs-node' +import { setBackend, LinearRegression } from 'scikitjs' +setBackend(tf) const lr = new LinearRegression({ fitIntercept: false }) const X = [[1], [2]] // 2D Matrix with a single column vector @@ -124,7 +128,9 @@ Turns into #### JavaScript ```js -import { LinearRegression } from 'scikitjs' +import * as tf from '@tensorflow/tfjs-node' +import { setBackend, LinearRegression } from 'scikitjs' +setBackend(tf) let X = [[1], [2]] let y = [10, 20] @@ -154,7 +160,9 @@ Turns into #### JavaScript ```js -import { LinearRegression } from 'scikitjs' +import * as tf from '@tensorflow/tfjs-node' +import { setBackend, LinearRegression } from 'scikitjs' +setBackend(tf) let X = [[1], [2]] let y = [10, 20] @@ -189,7 +197,9 @@ Turns into #### JavaScript ```js -import { LogisticRegression } from 'scikitjs' +import * as tf from '@tensorflow/tfjs-node' +import { setBackend, LogisticRegression } from 'scikitjs' +setBackend(tf) let X = [[1], [-1]] let y = [1, 0] pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy