skmultiflow.data.
RandomTreeGenerator
Random Tree stream generator.
This generator is built based on its description in Domingo and Hulten’s ‘Knowledge Discovery and Data Mining’. The generator is based on a random tree that splits features at random and sets labels to its leafs.
The tree structure is composed on Node objects, which can be either inner nodes or leaf nodes. The choice comes as a function fo the parameters passed to its initializer.
Since the concepts are generated and classified according to a tree structure, in theory, it should favour decision tree learners.
Seed for random generation of tree.
Seed for random generation of instances.
The number of classes to generate.
The number of categorical features to generate. Categorical features are binary encoded, the actual number of categorical features is n_cat_features`x`n_categories_per_cat_feature
The number of numerical features to generate.
The number of values to generate per categorical feature.
The maximum depth of the tree concept.
The first level of the tree above MaxTreeDepth that can have leaves.
The fraction of leaves per level from min_leaf_depth onwards.
Examples
>>> # Imports >>> from skmultiflow.data.random_tree_generator import RandomTreeGenerator >>> # Setting up the stream >>> stream = RandomTreeGenerator(tree_random_state=8873, sample_random_seed=69, n_classes=2, ... n_cat_features=2, n_num_features=5, n_categories_per_cat_feature=5, max_tree_depth=6, ... min_leaf_depth=3, fraction_leaves_per_level=0.15) >>> # Retrieving one sample >>> stream.next_sample() (array([[ 0.16268102, 0.1105941 , 0.7172657 , 0.13021257, 0.61664241, 1. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 1. , 0. ]]), array([ 0.])) >>> # Retrieving 10 samples >>> stream.next_sample(10) (array([[ 0.23752865, 0.58739728, 0.33649431, 0.62104964, 0.85182531, 0. , 0. , 0. , 0. , 1. , 0. , 0. , 0. , 0. , 1. ], [ 0.80996022, 0.71970756, 0.49121675, 0.18175096, 0.41738968, 0. , 0. , 0. , 1. , 0. , 0. , 0. , 0. , 0. , 1. ], [ 0.3450778 , 0.27301117, 0.52986614, 0.68253015, 0.79836113, 0. , 0. , 1. , 0. , 0. , 1. , 0. , 0. , 0. , 0. ], [ 0.28974746, 0.64385678, 0.11726876, 0.14956833, 0.90919843, 0. , 1. , 0. , 0. , 0. , 0. , 0. , 0. , 1. , 0. ], [ 0.85404693, 0.77693923, 0.25851095, 0.13574941, 0.01739845, 0. , 0. , 0. , 0. , 1. , 0. , 0. , 0. , 0. , 1. ], [ 0.23404205, 0.67644455, 0.65199858, 0.22742471, 0.01895565, 1. , 0. , 0. , 0. , 0. , 0. , 0. , 1. , 0. , 0. ], [ 0.12843591, 0.56112384, 0.08013747, 0.46674409, 0.48333615, 0. , 0. , 1. , 0. , 0. , 1. , 0. , 0. , 0. , 0. ], [ 0.52058342, 0.51999097, 0.28294293, 0.11435212, 0.83731519, 0. , 1. , 0. , 0. , 0. , 1. , 0. , 0. , 0. , 0. ], [ 0.82455551, 0.3758063 , 0.02672009, 0.87081727, 0.3165448 , 1. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 1. , 0. ], [ 0.03012729, 0.30479727, 0.65407304, 0.14532937, 0.47670874, 0. , 1. , 0. , 0. , 0. , 0. , 0. , 1. , 0. , 0. ]]), array([ 1., 1., 1., 1., 0., 1., 1., 0., 0., 0.])) >>> # 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)
get_data_info
Retrieves minimum information from the stream
get_info(self)
get_info
Collects and returns the information about the configuration of the estimator
get_params(self[, deep])
get_params
Get parameters for this estimator.
has_more_samples(self)
has_more_samples
Checks if stream has more samples.
is_restartable(self)
is_restartable
Determine if the stream is restartable.
last_sample(self)
last_sample
Retrieves last batch_size samples in the stream.
n_remaining_samples(self)
n_remaining_samples
Returns the estimated number of remaining samples.
next_sample(self[, batch_size])
next_sample
Returns next sample from the stream.
prepare_for_use()
prepare_for_use
Prepare the stream for use.
reset(self)
reset
Resets the estimator to its initial state.
restart(self)
restart
Restart the stream.
set_params(self, **params)
set_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.
names of the features
Used by evaluator methods to id the stream.
The default format is: ‘Stream name - n_targets, n_classes, n_features’.
Stream data information
Configuration of the estimator.
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
True if stream has more samples.
True if stream is restartable.
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.
The number of integer features in the stream.
The total number of features.
The number of numerical features in the stream.
Remaining number of samples. -1 if infinite (e.g. generator)
the number of targets in the stream.
Randomly generates attributes values, and then classify each instance generated.
The number of samples to return.
Return a tuple with the features matrix and the labels matrix for the batch_size samples that were requested.
Deprecated in v0.5.0 and will be removed in v0.7.0
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.
<component>__<parameter>
the names of the targets in the stream.
list of lists of all target_values for each target