diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index f47a804..0f90bdd 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -43,6 +43,6 @@ jobs: run: python -c "from river import datasets; datasets.CreditCard().download(); datasets.Elec2().download(); datasets.Keystroke().download()" - name: pytest - run: pytest --cov=river_torch -m "not datasets" + run: pytest --cov=deep_river -m "not datasets" - name: Upload coverage reports to Codecov with GitHub Action uses: codecov/codecov-action@v2 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9bb897b..f575d46 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,4 @@ -files: river_torch +files: deep_river repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.2.0 diff --git a/README.md b/README.md index 71ad6db..c8f8197 100644 --- a/README.md +++ b/README.md @@ -1,46 +1,46 @@
- +
- river-torch is a Python library for online deep learning. - River-torch's ambition is to enable online machine learning for neural networks. + deep-river is a Python library for online deep learning. + deep-river's ambition is to enable online machine learning for neural networks. It combines the river API with the capabilities of designing neural networks based on PyTorch.
## π Installation ```shell -pip install river-torch +pip install deep-river ``` or ```shell -pip install "river[torch]" +pip install "river[deep]" ``` You can install the latest development version from GitHub as so: ```shell -pip install https://github.com/online-ml/river-torch/archive/refs/heads/master.zip +pip install https://github.com/online-ml/deep-river/archive/refs/heads/master.zip ``` ## π« Quickstart We build the development of neural networks on top of the river API and refer to the rivers design principles. The following example creates a simple MLP architecture based on PyTorch and incrementally predicts and trains on the website phishing dataset. -For further examples check out the Documentation. +For further examples check out the Documentation. ### Classification ```python >>> from river import metrics, datasets, preprocessing, compose ->>> from river_torch import classification +>>> from deep_river import classification >>> from torch import nn >>> from torch import optim >>> from torch import manual_seed @@ -72,7 +72,7 @@ For further examples check out the >> from river_torch.anomaly import Autoencoder +>>> from deep_river.anomaly import Autoencoder >>> from river import metrics >>> from river.datasets import CreditCard >>> from torch import nn @@ -111,9 +111,9 @@ Accuracy: 0.6728 >>> model = Pipeline(scaler, ae) >>> for x, y in dataset: -... score = model.score_one(x) -... model = model.learn_one(x=x) -... metric = metric.update(y, score) +... score = model.score_one(x) +... model = model.learn_one(x=x) +... metric = metric.update(y, score) ... >>> print(f"ROCAUC: {metric.get():.4f}") ROCAUC: 0.7447 diff --git a/check.ipynb b/check.ipynb deleted file mode 100644 index 9770eb6..0000000 --- a/check.ipynb +++ /dev/null @@ -1,128 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Accuracy: 0.6512\n" - ] - } - ], - "source": [ - "from river import metrics, preprocessing, compose, datasets\n", - "from river_torch import classification\n", - "from torch import nn\n", - "from torch import manual_seed\n", - "\n", - "_ = manual_seed(42)\n", - "\n", - "class MyModule(nn.Module):\n", - " def __init__(self, n_features):\n", - " super(MyModule, self).__init__()\n", - " self.dense0 = nn.Linear(n_features,5)\n", - " self.nonlin = nn.ReLU()\n", - " self.dense1 = nn.Linear(5, 2)\n", - " self.softmax = nn.Softmax(dim=-1)\n", - " def forward(self, X, **kwargs):\n", - " X = self.nonlin(self.dense0(X))\n", - " X = self.nonlin(self.dense1(X))\n", - " X = self.softmax(X)\n", - " return X\n", - "\n", - "model_pipeline = classification.Classifier(module=MyModule,\n", - " loss_fn=\"binary_cross_entropy\",\n", - " optimizer_fn='adam')\n", - "\n", - "\n", - "\n", - "dataset = datasets.Phishing()\n", - "metric = metrics.Accuracy()\n", - "\n", - "for x, y in dataset:\n", - " y_pred = model_pipeline.predict_one(x) # make a prediction\n", - " metric = metric.update(y, y_pred) # update the metric\n", - " model_pipeline = model_pipeline.learn_one(x,y)\n", - "\n", - "print(f'Accuracy: {metric.get()}')" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "outputs": [ - { - "data": { - "image/svg+xml": "\n\n\n\n\n", - "text/plain": "MinMaxScaler
()\n\n
Autoencoder
(\n module=None\n loss_fn=\"mse_loss\"\n optimizer_fn=<class 'torch.optim.sgd.SGD'>\n lr=0.005\n device=\"cpu\"\n seed=42\n)\n\n
MinMaxScaler
()\n\n
ProbabilityWeightedAutoencoder
(\n module=None\n loss_fn=\"mse_loss\"\n optimizer_fn=<class 'torch.optim.sgd.SGD'>\n lr=0.01\n device=\"cpu\"\n seed=42\n skip_threshold=0.9\n window_size=250\n)\n\n