Skip to main content

SciKit learn wrapper for XCS algorithm implementation.

Project description


skxcs is a SciKit learn wrapper for implementation of XCS algorithm xcs.


Use the package manager pip to install skxcs.

pip install skxcs


Numeric Values

from skxcs.classifiers import XcsClassifier
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split

# Numeric values
iris = load_iris()
X, y =,
X_train, X_test, y_train, y_test = train_test_split(X, 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., y_train)

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

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

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

Categorical values

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

# Categorical values
categorical_frame = pd.read_csv(
    header=None, na_values="?").dropna()
y = categorical_frame[0]
X = categorical_frame.select_dtypes(include=[object])
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33)
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), 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)





Project details

Release history Release notifications | RSS feed

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

skxcs-0.1.tar.gz (6.6 kB view hashes)

Uploaded source

Built Distribution

skxcs-0.1-py3-none-any.whl (7.9 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page