Currently, it is not possible to use DensityBasedSampling in this package. The code below, taken from the README, would be expected to successfully create a sampled dataset.
from sampling.Sampler import *
from sampling.SamplingMethods import *
import numpy as np
data = np.array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]])
labels = np.array([0, 1, 0, 1, 0])
sampler = Sampler() # Initialize the Sampler object
sampler.set_data(data, labels)
# data: an (n*2) numpy array indicating the point coordinates
# labels: an (n*1) numpy array indicating the class labels with integers 0, 1, 2, ...
# or None if you use single-class sampling methods
sampler.set_sampling_method(DensityBiasedSampling, sampling_rate=0.5)
indices = sampler.sample()
# indices: an (m*1) numpy array indicating the indices of the sampling result
sampled_data, sampled_labels = sampler.get_samples()
# sampled_data: an (m*2) numpy array indicating the sampled point coordinates
# sampled_labels: an (m*2) numpy array indicating the class labels of the sampled points
However, it throws the following error:
, line 14, in <module>
indices = sampler.sample()
AttributeError: 'Sampler' object has no attribute 'sample'
This error does not occur when sampling method RandomSampling is used.
Currently, it is not possible to use DensityBasedSampling in this package. The code below, taken from the README, would be expected to successfully create a sampled dataset.
However, it throws the following error:
This error does not occur when sampling method RandomSampling is used.