Skip to content

Commit

Permalink
fix(base): third round of inheritance fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
f-aguzzi committed Jun 12, 2024
1 parent 103040c commit c3b1bbb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions chemfusekit/knn.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from chemfusekit.lldf import LLDFDataModel
from chemfusekit.__utils import run_split_test, print_confusion_matrix, print_table, GraphMode
from .__base import BaseClassifierSettings, BaseClassifier
from .__base import BaseClassifierSettings, BaseClassifier, BaseDataModel


class KNNSettings(BaseClassifierSettings):
Expand Down Expand Up @@ -39,7 +39,7 @@ def __init__(self, n_neighbors: int = 15, metric: str | Callable = 'euclidean',

class KNN(BaseClassifier):
'''Class to store the data, methods and artifacts for k-Nearest Neighbors Analysis'''
def __init__(self, settings: KNNSettings, fused_data: LLDFDataModel):
def __init__(self, settings: KNNSettings, fused_data: BaseDataModel):
super().__init__(settings, fused_data)

def knn(self):
Expand Down
6 changes: 3 additions & 3 deletions chemfusekit/pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import scipy.stats

from chemfusekit.__utils import print_table, GraphMode
from .__base import BaseDataModel, BaseReducer
from .__base import BaseDataModel, BaseReducer, BaseSettings


class PCADataModel(BaseDataModel):
Expand All @@ -26,11 +26,12 @@ def __init__(self, x_data: pd.DataFrame, x_train: pd.DataFrame, y: np.ndarray, a
self.components = components


class PCASettings:
class PCASettings(BaseSettings):
'''Holds the settings for the PCA object.'''
def __init__(self, target_variance: float = 0.95,
confidence_level: float = 0.05,
initial_components: int = 10, output: GraphMode = GraphMode.NONE):
super().__init__(output)
if target_variance < 0:
raise ValueError("Target variance should be positive or null.")
if confidence_level < 0 or confidence_level > 1:
Expand All @@ -40,7 +41,6 @@ def __init__(self, target_variance: float = 0.95,
self.target_variance = target_variance
self.confidence_level = confidence_level
self.initial_components = initial_components
self.output = output


class PCA(BaseReducer):
Expand Down

0 comments on commit c3b1bbb

Please sign in to comment.