Skip to content

Commit

Permalink
simplex sampling defaults update
Browse files Browse the repository at this point in the history
  • Loading branch information
gykovacs committed Aug 21, 2022
1 parent 8e7d3ca commit b5165a7
Show file tree
Hide file tree
Showing 59 changed files with 66 additions and 66 deletions.
2 changes: 1 addition & 1 deletion smote_variants/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
@author: gykovacs
"""

__version__= '0.6.8'
__version__= '0.6.9'
2 changes: 1 addition & 1 deletion smote_variants/base/_oversampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ class OverSamplingSimplex(OverSamplingBase, SimplexSamplingMixin):
def __init__(self,
*,
n_dim=2,
simplex_sampling='uniform',
simplex_sampling='random',
within_simplex_sampling='random',
gaussian_component=None,
random_state=None,
Expand Down
10 changes: 5 additions & 5 deletions smote_variants/base/_simplexsampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class SimplexSamplingMixin(RandomStateMixin):
def __init__(self,
*,
n_dim=2,
simplex_sampling='uniform',
simplex_sampling='random',
within_simplex_sampling='deterministic',
gaussian_component=None,
random_state=None):
Expand All @@ -347,7 +347,7 @@ def __init__(self,
n_dim (int): the dimensions of the simplices
(2 for line segments)
simplex_sampling (str): simplex sampling method
('uniform'/'volume'/None)
('random'/'volume'/'deterministic'/None)
within_simplex_sampling (str): within simplex sampling
method ('random'/'deterministic')
"""
Expand Down Expand Up @@ -385,11 +385,11 @@ def determine_simplex_distribution(self, X, simplices):
Returns:
np.array: the distribution for sampling the simplices
"""
if self.simplex_sampling == 'uniform':
if self.simplex_sampling in ['random', 'deterministic']:
return np.repeat(1.0/len(simplices), len(simplices))
if self.simplex_sampling == 'volume':
return simplex_volumes(X[simplices])
raise ValueError(f"simplex sampling with weighting"\
raise ValueError(f"simplex sampling with weighting "\
f"{self.simplex_sampling} not implemented yet")

def all_simplices_node_weights(self, indices, simplex_weights, n_dim):
Expand Down Expand Up @@ -486,7 +486,7 @@ def simplices(self,

choices = np.arange(all_simplices.shape[0])

if self.simplex_sampling == 'random':
if self.simplex_sampling != 'deterministic':
# sample the simplices
selected_indices = self.random_state.choice(choices,
n_to_sample,
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_a_suwo.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(self,
random_state (int/RandomState/None): initializer of random_state,
like in sklearn
"""
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}

Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_adasyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(self,
"""
nn_params = coalesce(nn_params, {})

ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_amsco.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def __init__(self,
random_state (int/RandomState/None): initializer of random_state,
like in sklearn
"""
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_and_smote.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(self,
random_state (int/RandomState/None): initializer of random_state,
like in sklearn
"""
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_ans.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self,
random_state (int/RandomState/None): initializer of random_state,
like in sklearn
"""
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_asmobd.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __init__(self,
like in sklearn
"""
ss_params = coalesce_dict(ss_params, {'n_dim': 2,
'simplex_sampling': 'uniform',
'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None})

Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_assembled_smote.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def __init__(self,
random_state (int/RandomState/None): initializer of random_state,
like in sklearn
"""
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
4 changes: 2 additions & 2 deletions smote_variants/oversampling/_borderline_smote.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def __init__(self,
random_state (int/RandomState/None): initializer of random_state,
like in sklearn
"""
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down Expand Up @@ -301,7 +301,7 @@ def __init__(self,
random_state (int/RandomState/None): initializer of random_state,
like in sklearn
"""
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_cbso.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(self,
random_state (int/RandomState/None): initializer of random_state,
like in sklearn
"""
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_ce_smote.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(self,
random_state (int/RandomState/None): initializer of random_state,
like in sklearn
"""
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_cluster_smote.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __init__(self,
random_state (int/RandomState/None): initializer of random_state,
like in sklearn
"""
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_cure_smote.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(self,
random_state (int/RandomState/None): initializer of random_state,
like in sklearn
"""
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_deago.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def __init__(self,
random_state (int/RandomState/None): initializer of random_state,
like in sklearn
"""
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}

Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_distance_smote.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(self,
random_state (int/RandomState/None): initializer of random_state,
like in sklearn
"""
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_dsrbf.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def __init__(self,
self.n_neighbors = n_neighbors
self.nn_params = coalesce(nn_params, {})
self.ss_params = coalesce_dict(ss_params, {'n_dim': 2,
'simplex_sampling': 'uniform',
'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None})
self.params = {'m_min': hidden_range[0],
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_e_smote.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def __init__(self,
random_state (int/RandomState/None): initializer of random_state,
like in sklearn
"""
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}

Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_edge_det_smote.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(self,
like in sklearn
"""
nn_params = coalesce(nn_params, {})
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_g_smote.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def __init__(self,
"""
nn_params = coalesce(nn_params, {})

ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_gasmote.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __init__(self,
"""
nn_params = coalesce(nn_params, {})

ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_gaussian_smote.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self,
"""
nn_params = coalesce(nn_params, {})

ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': {'sigma': sigma}}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_ismote.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self,
like in sklearn
"""
nn_params = coalesce(nn_params, {})
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_isomap_hybrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __init__(self,
smote_n_neighbors (int): number of neighbors in SMOTE sampling
n_jobs (int): number of parallel jobs
"""
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}

Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_kmeans_smote.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(self,
like in sklearn
"""
nn_params = coalesce(nn_params, {})
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_lee.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(self,
"""
nn_params = coalesce(nn_params, {})

ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}

Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_lle_smote.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def __init__(self,
"""
nn_params = coalesce(nn_params, {})

ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_mct.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self,
random_state (int/RandomState/None): initializer of random_state,
like in sklearn
"""
ss_params_default = {'n_dim': 1, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 1, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_mot2ld.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(self,
"""
nn_params = coalesce(nn_params, {})

ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_msyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(self,
random_state (int/RandomState/None): initializer of random_state,
like in sklearn
"""
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}

Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_mwmote.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def __init__(self,
"""
nn_params = coalesce(nn_params, {})

ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_ndo_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __init__(self,
random_state (int/RandomState/None): initializer of random_state,
like in sklearn
"""
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_neater.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(self,
random_state (int/RandomState/None): initializer of random_state,
like in sklearn
"""
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_nras.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __init__(self,
random_state (int/RandomState/None): initializer of random_state,
like in sklearn
"""
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_nrsboundary_smote.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self,
random_state (int/RandomState/None): initializer of random_state,
like in sklearn
"""
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 2, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
2 changes: 1 addition & 1 deletion smote_variants/oversampling/_nt_smote.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __init__(self,
random_state (int/RandomState/None): initializer of random_state,
like in sklearn
"""
ss_params_default = {'n_dim': 3, 'simplex_sampling': 'uniform',
ss_params_default = {'n_dim': 3, 'simplex_sampling': 'random',
'within_simplex_sampling': 'random',
'gaussian_component': None}
ss_params = coalesce_dict(ss_params, ss_params_default)
Expand Down
Loading

0 comments on commit b5165a7

Please sign in to comment.