Skip to content

distance based wighting to calculate weights of training records, considering the distance from test set

License

Notifications You must be signed in to change notification settings

WeightedBasedAI/db_weights

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Weight Calculation for Semi-Supervised Learning

This package provides tools for calculating weights for test data based on training data using nearest neighbors and various distance measures. The implementation leverages scikit-learn, scipy, and joblib for efficient computation.

https://pypi.org/project/db-weights/

Features

  • Calculate weights using Nearest Neighbors
  • Calculate weights using different distance measures
  • Supports various distance metrics including Euclidean, Mahalanobis, Cosine, etc.
  • Parallel processing for faster computation

Installation

You can install the package using pip:

pip install db-weights

Usage

Importing the package

import numpy as np
from db_weights import WeightCalculator

Creating a WeightCalculator instance

weight_calculator = WeightCalculator(n_neighbors=3, algorithm='auto', n_jobs=-1)

Calculating weights using Nearest Neighbors

x_train = np.random.rand(100, 5)  # Training data
x_test = np.random.rand(20, 5)    # Test data

weights_nn = weight_calculator.calculate_weights_nn(x_train, x_test, weight=1)
print(weights_nn)

Calculating weights using distance measures

weights_dist = weight_calculator.calculate_weights_dist(x_train, x_test, weight=1, measure_type='euclidean')
print(weights_dist)

Getting available distance measures

measurements = weight_calculator.get_measurements()
print(measurements)

Make WHL

pip install setuptools wheel
python setup.py sdist bdist_wheel

Dependencies

  • numpy
  • scikit-learn
  • scipy
  • joblib

Contributing

Contributions are welcome. Please fork the repository and submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

distance based wighting to calculate weights of training records, considering the distance from test set

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages