ensemblem package

Submodules

ensemblem.metrics module

ensemblem.metrics.cosine_v(x, y)[source]

Vector Cosine distance is 1 - cosine similarity

ensemblem.metrics.euclidean(point, data)[source]

Euclidean distance is the square root of the sum of the squared differences of their coordinates

ensemblem.metrics.euclidean_v(x, y)[source]

Vector Euclidean distance is the square root of the sum of the squared differences of their coordinates

ensemblem.metrics.manhattan_v(x, y)[source]

Vector Manhattan distance is the sum of the absolute differences of their coordinates

ensemblem.metrics.mean_absolute_error(actual, predicted)[source]

Mean Absolute Error (MAE)

ensemblem.metrics.mean_absolute_percentage_error(actual, predicted)[source]

Local Mean Absolute Percentage Error (LMAPE)

ensemblem.metrics.mean_squared_error(actual, predicted)[source]

Mean Squared Error (MSE)

ensemblem.metrics.metrics_table(actual, predicted, model_name)[source]

Create a table with pivot with results of multiple models and metrics

ensemblem.metrics.root_mean_squared_error(actual, predicted)[source]

Local Root Mean Squared Error (LRMSE)

ensemblem.metrics.root_mean_squared_log_error(actual, predicted)[source]

Local Root Mean Squared Log Error (LRMSLE)

ensemblem.model module

class ensemblem.model.KWEnsembler(k=5, bias='False', dist_metric=<function euclidean>)[source]

Bases: object

KWEnsembler class

This class implements the K-Weighted Ensembler model. It is an ensemble model that uses the k-nearest neighbors of a sample to predict its target value. The weights of the neighbors are calculated using a weight function. The bias of the neighbors can be added to the prediction.

Parameters

[ParamName] (int, bool, function) – k (default: 5), bias (default: ‘False’), dist_metric (default: euclidean)

Returns

Predictions of the target values for the test set

Return type

bytearray

find_similar_neighbors(x, similar_space)[source]

Finds the k nearest neighbors of x in the similar_space

fit(X_val, y_val)[source]

Fits the ensemble by creating the search space

predict(X_test, features, pred_columns, weight_function=<function w_inverse_LMAE>, range_min=0, range_max=1)[source]

Predicts the target values for the test set using the ensemble method

ensemblem.utils module

ensemblem.utils.divide_sets(df, train_size, val_size, test_size)[source]

Divide the data into train, validation and test sets

ensemblem.utils.split_sets(df, train_size, val_size, test_size, target)[source]

Split the data into train, validation and test sets with target and features

ensemblem.weights_functions module

ensemblem.weights_functions.error_bias(data, k, metric)[source]

Calculate the bias of the error

ensemblem.weights_functions.get_k_nearest_neighbors(point, data, k, metric)[source]

Get the k nearest neighbors of a point in a dataset

ensemblem.weights_functions.get_k_nearest_neighbors_weights(point, data, k, metric, weights)[source]

Get the k nearest neighbors of a point in a dataset weighing the neighbors

ensemblem.weights_functions.predict_inverse_LMAE(point, data, k, metric)[source]

Predict the target value of a point using the inverse LMAE

ensemblem.weights_functions.w_inverse_LMAE(actual, predicted)[source]

Inverse Local MAE

ensemblem.weights_functions.w_inverse_log_LMAE(actual, predicted)[source]

Inverse Log Local MAE

Module contents