skxcs


Nameskxcs JSON
Version 1.0 PyPI version JSON
download
home_page
SummarySciKit learn wrapper for XCS algorithm implementation.
upload_time2023-11-12 13:56:08
maintainer
docs_urlNone
authorJaroslav Michalovcik
requires_python>=3.7
licenseMIT
keywords xcs xcs scikit learn
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # skxcs

skxcs is a SciKit learn wrapper for implementation of XCS algorithm [xcs](https://github.com/hosford42/xcs). 

## Installation

Use the package manager [pip](https://pip.pypa.io/en/stable/) to install skxcs. You need to have [Cython](https://pypi.org/project/Cython/) installed.

```bash
pip install skxcs
```

## Usage

Numeric Values

```python
from skxcs.classifiers import XcsClassifier
import pandas as pd
from sklearn.model_selection import train_test_split

# Numeric values
numerical_frame = pd.read_csv('https://raw.githubusercontent.com/kliegr/arcBench/master/data/datasets/iris.csv')
numerical_frame.dropna(inplace=True)
y = numerical_frame['class']
numerical_frame.drop('class', axis=1, inplace=True)
X_train, X_test, y_train, y_test = train_test_split(numerical_frame, y, test_size=0.33)

classifier = XcsClassifier()

# If data input is non binary, classifier automatically uses MLDP discretizer for numeric values
# and one hot encoding for categorical values to transform data in both fit and predict methods.

classifier.fit(X_train, y_train)

# Get prediction array
y_pred = classifier.predict(X_test)

# Get pretty rules
for rule in classifier.get_pretty_rules():
    print(rule)

# To use get_pretty_rules or pretty_print_prediction methods,
# classifier has to transform train and test data first.

```

Categorical values

```python
import pandas as pd
from skxcs.classifiers import XcsClassifier
from sklearn.model_selection import train_test_split

# Categorical values
categorical_frame = pd.read_csv('https://raw.githubusercontent.com/kliegr/arcBench/master/data/datasets/autos.csv')
categorical_frame.dropna(inplace=True)
y = categorical_frame['XClass']
categorical_frame = categorical_frame.select_dtypes(include=[object])
categorical_frame.drop('XClass', axis=1, inplace=True)
X_train, X_test, y_train, y_test = train_test_split(categorical_frame, y, test_size=0.25)
classifier = XcsClassifier()

# You can transform data yourself. You should either transform both training
# and testing data, or none of them. It is necessary to ensure correct values are passed to classifier.
X_train_bin = classifier.transform_df(X_train, y=y_train)
classifier.fit(X_train_bin, y_train)

# Note that we don't pass 'y' to transform method when we transform test data
X_test_bin = classifier.transform_df(X_test)

# pretty print prediction
result = classifier.pretty_print_prediction(X_test_bin)
print(result)
```

## Contributing
...

## License
[MIT](https://choosealicense.com/licenses/mit/)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "skxcs",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "XCS,xcs,SciKit,learn",
    "author": "Jaroslav Michalovcik",
    "author_email": "yee06.zones@icloud.com",
    "download_url": "https://files.pythonhosted.org/packages/8d/ff/1872abd7c9448d785cfbc401cc520972b46d02bf24187c74fff3e843f9be/skxcs-1.0.tar.gz",
    "platform": null,
    "description": "# skxcs\n\nskxcs is a SciKit learn wrapper for implementation of XCS algorithm [xcs](https://github.com/hosford42/xcs). \n\n## Installation\n\nUse the package manager [pip](https://pip.pypa.io/en/stable/) to install skxcs. You need to have [Cython](https://pypi.org/project/Cython/) installed.\n\n```bash\npip install skxcs\n```\n\n## Usage\n\nNumeric Values\n\n```python\nfrom skxcs.classifiers import XcsClassifier\nimport pandas as pd\nfrom sklearn.model_selection import train_test_split\n\n# Numeric values\nnumerical_frame = pd.read_csv('https://raw.githubusercontent.com/kliegr/arcBench/master/data/datasets/iris.csv')\nnumerical_frame.dropna(inplace=True)\ny = numerical_frame['class']\nnumerical_frame.drop('class', axis=1, inplace=True)\nX_train, X_test, y_train, y_test = train_test_split(numerical_frame, y, test_size=0.33)\n\nclassifier = XcsClassifier()\n\n# If data input is non binary, classifier automatically uses MLDP discretizer for numeric values\n# and one hot encoding for categorical values to transform data in both fit and predict methods.\n\nclassifier.fit(X_train, y_train)\n\n# Get prediction array\ny_pred = classifier.predict(X_test)\n\n# Get pretty rules\nfor rule in classifier.get_pretty_rules():\n    print(rule)\n\n# To use get_pretty_rules or pretty_print_prediction methods,\n# classifier has to transform train and test data first.\n\n```\n\nCategorical values\n\n```python\nimport pandas as pd\nfrom skxcs.classifiers import XcsClassifier\nfrom sklearn.model_selection import train_test_split\n\n# Categorical values\ncategorical_frame = pd.read_csv('https://raw.githubusercontent.com/kliegr/arcBench/master/data/datasets/autos.csv')\ncategorical_frame.dropna(inplace=True)\ny = categorical_frame['XClass']\ncategorical_frame = categorical_frame.select_dtypes(include=[object])\ncategorical_frame.drop('XClass', axis=1, inplace=True)\nX_train, X_test, y_train, y_test = train_test_split(categorical_frame, y, test_size=0.25)\nclassifier = XcsClassifier()\n\n# You can transform data yourself. You should either transform both training\n# and testing data, or none of them. It is necessary to ensure correct values are passed to classifier.\nX_train_bin = classifier.transform_df(X_train, y=y_train)\nclassifier.fit(X_train_bin, y_train)\n\n# Note that we don't pass 'y' to transform method when we transform test data\nX_test_bin = classifier.transform_df(X_test)\n\n# pretty print prediction\nresult = classifier.pretty_print_prediction(X_test_bin)\nprint(result)\n```\n\n## Contributing\n...\n\n## License\n[MIT](https://choosealicense.com/licenses/mit/)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "SciKit learn wrapper for XCS algorithm implementation.",
    "version": "1.0",
    "project_urls": null,
    "split_keywords": [
        "xcs",
        "xcs",
        "scikit",
        "learn"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8dff1872abd7c9448d785cfbc401cc520972b46d02bf24187c74fff3e843f9be",
                "md5": "1756fbdbb562c73f1308a78b9cfec286",
                "sha256": "ad2d3755cf668e714395f62c28dea3e3ebd6c1c1c42596120fb8b1428fb62d3c"
            },
            "downloads": -1,
            "filename": "skxcs-1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "1756fbdbb562c73f1308a78b9cfec286",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 8265,
            "upload_time": "2023-11-12T13:56:08",
            "upload_time_iso_8601": "2023-11-12T13:56:08.723214Z",
            "url": "https://files.pythonhosted.org/packages/8d/ff/1872abd7c9448d785cfbc401cc520972b46d02bf24187c74fff3e843f9be/skxcs-1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-12 13:56:08",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "skxcs"
}
        
Elapsed time: 2.24840s