skmultiflow.data.ConceptDriftStream¶

class skmultiflow.data.ConceptDriftStream(stream=AGRAWALGenerator(balance_classes=False, classification_function=0, perturbation=0.0, random_state=112), drift_stream=AGRAWALGenerator(balance_classes=False, classification_function=2, perturbation=0.0, random_state=112), position=5000, width=1000, random_state=None, alpha=0.0)[source]

Generates a stream with concept drift.

A stream generator that adds concept drift or change by joining several streams. This is done by building a weighted combination of two pure distributions that characterizes the target concepts before and after the change.

The sigmoid function is an elegant and practical solution to define the probability that each new instance of the stream belongs to the new concept after the drift. The sigmoid function introduces a gradual, smooth transition whose duration is controlled with two parameters:

• $$p$$, the position of the change.

• $$w$$, the width of the transition.

The sigmoid function at sample t is $$f(t) = 1/(1+e^{-4(t-p)/w})$$.

Parameters
stream: Stream (default= AGRAWALGenerator(random_state=112))

Original stream concept

drift_stream: Stream (default= AGRAWALGenerator(random_state=112, classification_function=2))

Drift stream concept

random_state: int, RandomState instance or None, optional (default=None)

If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.

alpha: float (optional, default: 0.0)

Angle of change to estimate the width of concept drift change. If set will override the width parameter. Valid values are in the range (0.0, 90.0].

position: int (default: 5000)

Central position of concept drift change.

width: int (Default: 1000)

Width of concept drift change.

Notes

An optional way to estimate the width of the transition $$w$$ is based on the angle $$\alpha$$: $$w = 1/ tan(\alpha)$$. Since width corresponds to the number of samples for the transition, the width is round-down to the nearest smaller integer. Notice that larger values of $$\alpha$$ result in smaller widths. For $$\alpha>45.0$$, the width is smaller than 1 so values are round-up to 1 to avoid division by zero errors.

Methods

 get_data_info(self) Retrieves minimum information from the stream get_info(self) Collects and returns the information about the configuration of the estimator get_params(self[, deep]) Get parameters for this estimator. has_more_samples(self) Checks if stream has more samples. is_restartable(self) Determine if the stream is restartable. last_sample(self) Retrieves last batch_size samples in the stream. n_remaining_samples(self) Returns the estimated number of remaining samples. next_sample(self[, batch_size]) Returns next sample from the stream. Prepare the stream for use. reset(self) Resets the estimator to its initial state. restart(self) Restart the stream. set_params(self, **params) Set the parameters of this estimator.

Attributes

 feature_names Retrieve the names of the features. n_cat_features Retrieve the number of integer features. n_features Retrieve the number of features. n_num_features Retrieve the number of numerical features. n_targets Retrieve the number of targets target_names Retrieve the names of the targets target_values Retrieve all target_values in the stream for each target.
property feature_names

Retrieve the names of the features.

Returns
list

names of the features

get_data_info(self)[source]

Retrieves minimum information from the stream

Used by evaluator methods to id the stream.

The default format is: ‘Stream name - n_targets, n_classes, n_features’.

Returns
string

Stream data information

get_info(self)[source]

Collects and returns the information about the configuration of the estimator

Returns
string

Configuration of the estimator.

get_params(self, deep=True)[source]

Get parameters for this estimator.

Parameters
deepboolean, optional

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns
paramsmapping of string to any

Parameter names mapped to their values.

has_more_samples(self)[source]

Checks if stream has more samples.

Returns
Boolean

True if stream has more samples.

is_restartable(self)[source]

Determine if the stream is restartable.

Returns
Boolean

True if stream is restartable.

last_sample(self)[source]

Retrieves last batch_size samples in the stream.

Returns
tuple or tuple list

A numpy.ndarray of shape (batch_size, n_features) and an array-like of shape (batch_size, n_targets), representing the next batch_size samples.

property n_cat_features

Retrieve the number of integer features.

Returns
int

The number of integer features in the stream.

property n_features

Retrieve the number of features.

Returns
int

The total number of features.

property n_num_features

Retrieve the number of numerical features.

Returns
int

The number of numerical features in the stream.

n_remaining_samples(self)[source]

Returns the estimated number of remaining samples.

Returns
int

Remaining number of samples. -1 if infinite (e.g. generator)

property n_targets

Retrieve the number of targets

Returns
int

the number of targets in the stream.

next_sample(self, batch_size=1)[source]

Returns next sample from the stream.

Parameters
batch_size: int (optional, default=1)

The number of samples to return.

Returns
tuple or tuple list

Return a tuple with the features matrix for the batch_size samples that were requested.

static prepare_for_use()[source]

Prepare the stream for use.

Deprecated in v0.5.0 and will be removed in v0.7.0

reset(self)[source]

Resets the estimator to its initial state.

Returns
self
restart(self)[source]

Restart the stream.

set_params(self, **params)[source]

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Returns
self
property target_names

Retrieve the names of the targets

Returns
list

the names of the targets in the stream.

property target_values

Retrieve all target_values in the stream for each target.

Returns
list

list of lists of all target_values for each target