Skip to content

updated readme #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ 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.
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 * as tf from '@tensorflow/tfjs'
import { LinearRegression, setBackend } from 'scikitjs'
setBackend(tf)
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.
Expand All @@ -38,15 +40,14 @@ This allows us to build a library that can be used in Deno, Node, and the browse
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 * as tf from '@tensorflow/tfjs-node'
import { LinearRegression, setBackend } from 'scikitjs'
setBackend(tf)
import * as sk from 'scikitjs'
sk.setBackend(tf)
```

### Script src
Expand All @@ -57,16 +58,18 @@ For those that wish to use script src tags, simply
<script type="module">
import * as tf from 'https://cdn.skypack.dev/@tensorflow/tfjs'
import * as sk from 'https://cdn.skypack.dev/scikitjs'
// or alternatively you can pull the bundle from unpkg >>> import * as sk from "https://unpkg.com/scikitjs/dist/web index.min.js"
sk.setBackend(tf)

// or alternatively you can pull the bundle from unpkg
// import * as sk from "https://unpkg.com/scikitjs/dist/web index.min.js"
</script>
```

## Simple Example

```js
import * as tf from '@tensorflow/tfjs-node'
import { LinearRegression, setBackend } from 'scikitjs'
import { setBackend, LinearRegression } from 'scikitjs'
setBackend(tf)

const lr = new LinearRegression({ fitIntercept: false })
Expand Down Expand Up @@ -126,7 +129,7 @@ Turns into

```js
import * as tf from '@tensorflow/tfjs-node'
import { LinearRegression, setBackend } from 'scikitjs'
import { setBackend, LinearRegression } from 'scikitjs'
setBackend(tf)

let X = [[1], [2]]
Expand Down Expand Up @@ -158,7 +161,7 @@ Turns into

```js
import * as tf from '@tensorflow/tfjs-node'
import { LinearRegression, setBackend } from 'scikitjs'
import { setBackend, LinearRegression } from 'scikitjs'
setBackend(tf)

let X = [[1], [2]]
Expand Down Expand Up @@ -195,7 +198,7 @@ Turns into

```js
import * as tf from '@tensorflow/tfjs-node'
import { LogisticRegression, setBackend } from 'scikitjs'
import { setBackend, LogisticRegression } from 'scikitjs'
setBackend(tf)

let X = [[1], [-1]]
Expand Down