Make Multiplexer Dataset

Function that creates a dataset generated by a n-bit Boolean multiplexer for evaluating supervised learning algorithms.

from mlxtend.data import make_multiplexer_dataset

Overview

The make_multiplexer_dataset function creates a dataset generated by an n-bit Boolean multiplexer. Such dataset represents a dataset generated by a simple rule, based on the behavior of a electric multiplexer, yet presents a relatively challenging classification problem for supervised learning algorithm with interactions between features (epistasis) as it may be encountered in many real-world scenarios [1].

The following illustration depicts a 6-bit multiplexer that consists of 2 address bits and 4 register bits. The address bits converted to decimal representation point to a position in the register bit. For example, if the address bits are "00" (0 in decimal), the address bits point to the register bit at position 0. The value of the register position pointed to determines the class label. For example, if the register bit at position is 0, the class label is 0. Vice versa, if the register bit at position 0 is 1, the class label is 1.

In the example above, the address bits "10" (2 in decimal) point to the 3rd register position (as we start counting from index 0), which has a bit value of 1. Hence, the class label is 1.

Below are a few more examples:

  1. Address bits: [0, 1], register bits: [1, 0, 1, 1], class label: 0
  2. Address bits: [0, 1], register bits: [1, 1, 1, 0], class label: 1
  3. Address bits: [1, 0], register bits: [1, 0, 0, 1], class label: 0
  4. Address bits: [1, 1], register bits: [1, 1, 1, 0], class label: 0
  5. Address bits: [0, 1], register bits: [0, 1, 1, 0], class label: 1
  6. Address bits: [0, 1], register bits: [1, 0, 0, 1], class label: 0
  7. Address bits: [0, 1], register bits: [0, 1, 1, 1], class label: 1
  8. Address bits: [0, 1], register bits: [0, 0, 0, 0], class label: 0
  9. Address bits: [1, 0], register bits: [1, 0, 1, 1], class label: 1
  10. Address bits: [0, 1], register bits: [1, 1, 1, 1], class label: 1

Note that in the implementation of the multiplexer function, if the number of address bits is set to 2, this results in a 6 bit multiplexer as two bit can have 2^2=4 different register positions (2 bit + 4 bit = 6 bit). However, if we choose 3 address bits instead, 2^3=8 positions would be covered, resulting in a 11 bit (3 bit + 8 bit = 11 bit) multiplexer, and so forth.

References

Example 1 -- 6-bit multiplexer

This simple example illustrates how to create dataset from a 6-bit multiplexer

import numpy as np
from mlxtend.data import make_multiplexer_dataset


X, y = make_multiplexer_dataset(address_bits=2, 
                                sample_size=10,
                                positive_class_ratio=0.5, 
                                shuffle=False,
                                random_seed=123)

print('Features:\n', X)
print('\nClass labels:\n', y)
Features:
 [[0 1 0 1 0 1]
 [1 0 0 0 1 1]
 [0 1 1 1 0 0]
 [0 1 1 1 0 0]
 [0 0 1 1 0 0]
 [0 1 0 0 0 0]
 [0 1 1 0 1 1]
 [1 0 1 0 0 0]
 [1 0 0 1 0 1]
 [1 0 1 0 0 1]]

Class labels:
 [1 1 1 1 1 0 0 0 0 0]

API

make_multiplexer_dataset(address_bits=2, sample_size=100, positive_class_ratio=0.5, shuffle=False, random_seed=None)

Function to create a binary n-bit multiplexer dataset.

New in mlxtend v0.9

Parameters

Returns

Examples

For usage examples, please see http://rasbt.github.io/mlxtend/user_guide/data/make_multiplexer_dataset