Methods
accuracy_score(y_true, y_pred)
In multilabel classification, this function computes subset accuracy:
the set of labels predicted for a sample must *exactly* match the
corresponding set of labels in y_true.
Parameters:
Name | Type | Description |
---|---|---|
y_true |
Array | 1d array-like, or label indicator array; Ground truth (correct) labels |
y_pred |
Array | 1d array-like, or label indicator array; Predicted labels, as returned by a classifier. |
- Source:
check_1dy(y, make_tf)
Check if outputs y are of proper format.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
y |
Array | Outputs. | |
make_tf |
Boolean | true | Whether to convert y to tf.tensor |
check_2dX(X, make_tf)
Check if inputs X are of proper format.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
X |
Array | Input samples. | |
make_tf |
Boolean | true | Whether to convert input samples to tf.tensor |
check_2dXy(X, y, make_tf)
Check whether a dataset is consistent, and whether inputs
are a matrix and outputs are a vector.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
X |
Array | Array of input observations. | |
y |
Array | Outputs. | |
make_tf |
Boolean | true | Whether to convert y to tf.tensor |
check_array(array, min_nd, max_nd, min_shape, max_shape, make_tf)
Check dimensions of the array.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
array |
Array | Array to check, and optionally convert to tf tensor. | |
min_nd |
Number | 2 | minimum number of the dimensions in the array. |
max_nd |
Number | 2 | maximum number of dimensions. |
min_shape |
Array | array of maximal sizes for dimensions of the tensor. | |
max_shape |
Array | null | maximal sizes of dimensions in array. |
make_tf |
Boolean | true | whether to convert the input array to tf tensor. |
check_is_fitted(estimator, attributes, all_or_any)
Checks if the estimator is fitted by verifying the presence of
“all_or_any” of the passed attributes and raises an Error
with the given message.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
estimator |
Object | estimator to check to be fitted. | |
attributes |
Array | list of attributes to check presence of. | |
all_or_any |
String | all | Specify whether all or any of the given attributes must exist. |
ClassifierMixin(superclass)
Mixin class for all classifiers.
Parameters:
Name | Type | Description |
---|---|---|
superclass |
class | Class to extend with functionality |
(async) clone(obj, stringify)
Creates a copy of the object by serializing
the object to json, and then deserializing.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
obj |
Any | object to be cloned. | |
stringify |
Boolean | false | whether to stringify obtained blueprint. Should only be used for testing of whether the serialization representation is convertable to string, or in case serialized object might contain pointers to nested objects of the parent object, which erroneously are not cloned properly. |
(async) cross_val_score(estimator, X, y, groups, scoring, cv) → {Array}
Evaluate estimator performance via cross - validation.
Interface similar to `cross_val_score` function of sklearn.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
estimator |
BaseEstimator | Model to be scored. | |
X |
Array | Input values to be used for sorting. | |
y |
Array | null | Output values to be used for scoring |
groups |
Object | null | Ignored. |
scoring |
Object | null | Ignored for the time being. |
cv |
Number | 3 | Number of folds used for cross - validation. |
- Source:
Returns:
Scores on various partitions.
- Type
- Array
(async) dumpjson(obj)
Convert various objects to json format. Is useful for
serialization and deserialization of aitable objects.
Parameters:
Name | Type | Description |
---|---|---|
obj |
Any | Instance of an object to be converted into a serializable json. Can be a json serializable value, a class that can be serialized, or instance of tensorflowjs objects. |
(async) loadjson(json)
Inverse of dumpjson.
Parameters:
Name | Type | Description |
---|---|---|
json |
Any | Blueprint of the object, to be deserialized. |
make_murmaid(root, features, definitions, links)
Converts a decision tree, given by the root of the tree, into
a text format that can be rendered to the user.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
root |
Object | Root node of a decision tree. | |
features |
Array | null | Array of dictionaries, which contain information on names of the features and type of the features. |
definitions |
Array | null | Is only used for recurrent calls inside |
links |
Array | null | Similarily, stores the links between elements in graph. |
r2_score(y_true, y_pred, sample_weight)
R^2 (coefficient of determination) regression score function.
Best possible score is 1.0 and it can be negative (because the
model can be arbitrarily worse). A constant model that always
predicts the expected value of y, disregarding the input features,
would get a R^2 score of 0.0.
Parameters:
Name | Type | Description |
---|---|---|
y_true |
Array | array-like of shape = (n_samples); Ground truth (correct) target values. |
y_pred |
Array | array-like of shape = (n_samples) or (n_samples, n_outputs); Estimated target values. |
sample_weight |
Array | array-like of shape = (n_samples), optional; Sample weights. |
- Source:
random_partitioning(N, weights) → {Array}
Generate index set for partitioning of array of size N into
a number of partitions. The size of partitions can be specified
with `partitions` argument. The function ensures that the minimal
size of every partition is at least one. This is important for
small sized data partitioning, for example, or in case of leave one
out cross - validation.
Parameters:
Name | Type | Description |
---|---|---|
N |
Integer | Size of array to be partitioned |
weights |
Array | Weights that are assigned to partitions. With higher weight, the partition is more likely to receive elements. |
Returns:
Every element in the output array is a set of indicies
of the elements that belong to the i-th partition.
- Type
- Array
RegressorMixin(superclass)
Mixin class for all regressors.
Parameters:
Name | Type | Description |
---|---|---|
superclass |
class | Class to extend with functionality |
(async) score(X, y) → {Number}
Returns the mean accuracy on the given test data and labels.
In multi-label classification, this is the subset accuracy
which is a harsh metric since you require for each sample that
each label set be correctly predicted.
Parameters:
Name | Type | Description |
---|---|---|
X |
Array | Test samples. |
y |
Array | Test labels for X. |
Returns:
Mean accuracy of this.predict(X) wrt. y.
- Type
- Number
(async) score(X, y) → {Number}
Returns the coefficient of determination R^2 of the prediction.
The coefficient R^2 is defined as (1 - u/v), where u is the residual
sum of squares ((y_true - y_pred) ** 2).sum() and v is the total
sum of squares ((y_true - y_true.mean()) ** 2).sum().
The best possible score is 1.0 and it can be negative (because the
model can be arbitrarily worse). A constant model that always
predicts the expected value of y, disregarding the input features,
would get a R^2 score of 0.0.
Parameters:
Name | Type | Description |
---|---|---|
X |
Array | Test samples. |
y |
Array | Test outputs for X. |
Returns:
R^2 of this.predict(X) wrt. y.
- Type
- Number
set_defaults(params, defaults)
Sets default parameter values for the model classes.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
params |
Dictionary | null | Parameters supplied by user |
defaults |
Dictionary | null | Default values of parameters |
shuffle(a)
Shuffles array in place.
Parameters:
Name | Type | Description |
---|---|---|
a |
Array | items An array containing the items. |
t1d(data)
Converts some TypedArray into 1d tfjs array.
Parameters:
Name | Type | Description |
---|---|---|
data |
Array | data to be converted to 1d tfjs array |
t2d(data)
Converts some TypedArray into 2d tfjs array.
Parameters:
Name | Type | Description |
---|---|---|
data |
Array | data to be converted to 2d tfjs array |
train_test_split(arrays, test_split)
Splits the data into training and testing partitions for model
fitting. The split is done at random.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
arrays |
Array | List of arrays to be split into training and testing parts. | |
test_split |
Number | 0.25 | Value in the range of [0; 1]. Specifies how much of the data will be used for test partition. |
- Source: