skmultiflow.data.RandomRBFGenerator

class skmultiflow.data.RandomRBFGenerator(model_random_state=None, sample_random_state=None, n_classes=2, n_features=10, n_centroids=50)[source]

Random Radial Basis Function stream generator.

Produces a radial basis function stream. A number of centroids, having a random central position, a standard deviation, a class label and weight, are generated. A new sample is created by choosing one of the centroids at random, taking into account their weights, and offsetting the attributes at a random direction from the centroid’s center. The offset length is drawn from a Gaussian distribution.

This process will create a normally distributed hypersphere of samples on the surrounds of each centroid.

Parameters
model_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..

sample_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..

n_classes: int (Default: 2)

The number of class labels to generate.

n_features: int (Default: 10)

The number of numerical features to generate.

n_centroids: int (Default: 50)

The number of centroids to generate.

Examples

>>> # Imports
>>> from skmultiflow.data.random_rbf_generator import RandomRBFGenerator
>>> # Setting up the stream
>>> stream = RandomRBFGenerator(model_random_state=99, sample_random_state=50, n_classes=4,
... n_features=10, n_centroids=50)
>>> # Retrieving one sample
>>> stream.next_sample()
(array([[ 0.44952282,  1.09201096,  0.34778443,  0.92181679,  0.19503463,
     0.28834419,  0.8293168 ,  0.26847952,  0.8096243 ,  0.23850379]]), array([[ 3.]]))
>>> # Retrieving 10 samples
>>> stream.next_sample(10)
(array([[ 0.70374896,  0.65752835,  0.20343463,  0.56136917,  0.76659286,
     0.61081231,  0.60453064,  0.88734577, -0.04244631,  0.09146432],
   [ 0.27797196,  0.05640135,  0.80946171,  0.60572837,  0.95080656,
     0.25512099,  0.73992469,  0.33917142,  0.17104577,  0.79283295],
   [ 0.33696167,  0.10923638,  0.85987231,  0.61868598,  0.85755211,
     0.19469184,  0.66750447,  0.27684404,  0.1554274 ,  0.76262286],
   [ 0.71886223,  0.23078927,  0.45013806,  0.03019141,  0.42679505,
     0.03841721,  0.34318517,  0.11769923,  0.9644654 ,  0.01635577],
   [-0.01849262,  0.92570731,  0.87564868,  0.49372553,  0.39717634,
     0.46697609,  0.41329831,  0.27652149,  0.12724455,  0.24658299],
   [ 0.81850217,  0.87228851,  0.18873385, -0.04254749,  0.06942877,
     0.55567756,  0.97660009,  0.0273206 ,  0.67995834,  0.49135807],
   [ 0.69888163,  0.61994977,  0.43074298,  0.27526838,  0.69566798,
     0.91059369,  0.04680901,  0.50453698,  0.61394089,  0.92275292],
   [ 1.01929588,  0.80181051,  0.50547533,  0.14715636,  0.42889167,
     0.61513174,  0.21752655, -0.52958207,  1.35091672,  0.38769673],
   [ 0.37738633,  0.60922205,  0.64216064,  0.90009707,  0.91787083,
     0.36189554,  0.35438165,  0.28510134,  0.55301333,  0.21450072],
   [ 0.62185359,  0.75178244,  1.00436662,  0.24412816,  0.41070861,
     0.52547739,  0.50978735,  0.79445216,  0.77589569,  0.16214271]]), array([[ 3.],
   [ 3.],
   [ 3.],
   [ 2.],
   [ 3.],
   [ 2.],
   [ 0.],
   [ 2.],
   [ 0.],
   [ 2.]]))
>>> # Generators will have infinite remaining instances, so it returns -1
>>> stream.n_remaining_samples()
-1
>>> stream.has_more_samples()
True

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_for_use()

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
Bool

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.

Return batch_size samples generated by choosing a centroid at random and randomly offsetting its attributes so that it is placed inside the hypersphere of that centroid.

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 and the labels 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