sklx


Namesklx JSON
Version 0.0.1 PyPI version JSON
download
home_pageNone
SummaryA scikit-learn compatible neural network library that wraps MLX.
upload_time2024-10-27 03:18:14
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseBSD 3-Clause License
keywords sklx
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SKLX

A scikit-learn compatible neural network library that wraps MLX.
Highly inspired by [skorch](https://github.com/skorch-dev/skorch).

> [!WARNING]
> This is still under development and non of the following examples actually work.

## Examples

```python
import numpy as np
from sklearn.datasets import make_classification
from mlx import nn
from sklx import NeuralNetClassifier

X, y = make_classification(1000, 20, n_informative=10, random_state=0)
X = X.astype(np.float32)
y = y.astype(np.int64)

class MyModule(nn.Module):
    def __init__(self, num_units=10, nonlin=nn.ReLU()):
        super().__init__()

        self.dense0 = nn.Linear(20, num_units)
        self.nonlin = nonlin
        self.dropout = nn.Dropout(0.5)
        self.dense1 = nn.Linear(num_units, num_units)
        self.output = nn.Linear(num_units, 2)
        self.softmax = nn.Softmax(dim=-1)

    def forward(self, X, **kwargs):
        X = self.nonlin(self.dense0(X))
        X = self.dropout(X)
        X = self.nonlin(self.dense1(X))
        X = self.softmax(self.output(X))
        return X

net = NeuralNetClassifier(
    MyModule,
    max_epochs=10,
    lr=0.1,
)

net.fit(X, y)
y_proba = net.predict_proba(X)
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "sklx",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "sklx",
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/31/32/a9d53f5ff78863207cf0e7a6e7896a99ab867a30ead02c6666720b4feb7c/sklx-0.0.1.tar.gz",
    "platform": null,
    "description": "# SKLX\n\nA scikit-learn compatible neural network library that wraps MLX.\nHighly inspired by [skorch](https://github.com/skorch-dev/skorch).\n\n> [!WARNING]\n> This is still under development and non of the following examples actually work.\n\n## Examples\n\n```python\nimport numpy as np\nfrom sklearn.datasets import make_classification\nfrom mlx import nn\nfrom sklx import NeuralNetClassifier\n\nX, y = make_classification(1000, 20, n_informative=10, random_state=0)\nX = X.astype(np.float32)\ny = y.astype(np.int64)\n\nclass MyModule(nn.Module):\n    def __init__(self, num_units=10, nonlin=nn.ReLU()):\n        super().__init__()\n\n        self.dense0 = nn.Linear(20, num_units)\n        self.nonlin = nonlin\n        self.dropout = nn.Dropout(0.5)\n        self.dense1 = nn.Linear(num_units, num_units)\n        self.output = nn.Linear(num_units, 2)\n        self.softmax = nn.Softmax(dim=-1)\n\n    def forward(self, X, **kwargs):\n        X = self.nonlin(self.dense0(X))\n        X = self.dropout(X)\n        X = self.nonlin(self.dense1(X))\n        X = self.softmax(self.output(X))\n        return X\n\nnet = NeuralNetClassifier(\n    MyModule,\n    max_epochs=10,\n    lr=0.1,\n)\n\nnet.fit(X, y)\ny_proba = net.predict_proba(X)\n```\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause License",
    "summary": "A scikit-learn compatible neural network library that wraps MLX.",
    "version": "0.0.1",
    "project_urls": null,
    "split_keywords": [
        "sklx"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "556f818c54089f3dc0a835bee13227ef4fb8f564d00729c8ebb6495db20110c1",
                "md5": "7280712613491c7b3d674cfbb9714e94",
                "sha256": "374902458898ad7de61882dbe95a9aff9c894086026f618ae34db1df83d6468d"
            },
            "downloads": -1,
            "filename": "sklx-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7280712613491c7b3d674cfbb9714e94",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 5210,
            "upload_time": "2024-10-27T03:18:13",
            "upload_time_iso_8601": "2024-10-27T03:18:13.444077Z",
            "url": "https://files.pythonhosted.org/packages/55/6f/818c54089f3dc0a835bee13227ef4fb8f564d00729c8ebb6495db20110c1/sklx-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3132a9d53f5ff78863207cf0e7a6e7896a99ab867a30ead02c6666720b4feb7c",
                "md5": "0d05ef17e6dbe86ac12a960097be788d",
                "sha256": "d4cd06bf44e0e86645c39a80ce55356b364eedbd347393903313ee94447b8175"
            },
            "downloads": -1,
            "filename": "sklx-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "0d05ef17e6dbe86ac12a960097be788d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 51394,
            "upload_time": "2024-10-27T03:18:14",
            "upload_time_iso_8601": "2024-10-27T03:18:14.952321Z",
            "url": "https://files.pythonhosted.org/packages/31/32/a9d53f5ff78863207cf0e7a6e7896a99ab867a30ead02c6666720b4feb7c/sklx-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-27 03:18:14",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "sklx"
}
        
Elapsed time: 0.47719s