Skip to content

Commit

Permalink
added python special methods
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierzach authored Oct 3, 2020
1 parent 102d1ad commit 9972072
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion rnc/random_neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
from sklearn.metrics import silhouette_score
import random

# TODO: implement this as a true python object
# TODO: tests
# TODO: figure out best way to handle routing in build_sample_index instead of if blocks


class RandomNeighbors:

Expand All @@ -27,6 +31,19 @@ def __init__(
self.normalize_data = normalize_data
self.scale_data = scale_data

def __repr__(self):
name_ = f'''RandomNeighbors({self.use_custom_axis_samples},{self.sample_iter}, {self.select_columns},
{self.select_rows}, {self.custom_feature_sample_list}, {self.random_axis_max_pct}
{self.normalize_data}, {self.scale_data})
'''
return name_

def __str__(self):
return str(tuple(self))

def __eq__(self, other):
return tuple(self) == tuple(other)

@staticmethod
def sample_axis(axis_n, sample_iter, num_samples):
"""
Expand Down Expand Up @@ -74,7 +91,6 @@ def build_sample_index(self, axis_n, max_axis_selector='log2'):
assert isinstance(max_axis_selector, str)
assert isinstance(self.random_axis_max_pct, float)

# TODO: find a better way to route than if blocks...
# route for a custom list of axis sample sizes
if self.use_custom_axis_samples:

Expand Down

0 comments on commit 9972072

Please sign in to comment.