Skip to content

Commit

Permalink
🔥 Remove class replaced
Browse files Browse the repository at this point in the history
  • Loading branch information
NTGNguyen committed Dec 5, 2024
1 parent c409b77 commit f1e2b9e
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions src/LDA/LDA_Classifications/LDA_Classifications_Datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,41 +111,4 @@ def forward_and_predict(self) -> float:
return accuracy


class LDAClassificationsSKLearns(LDA):
"""
LDAClassificationsSKLearns class for demonstrating LDA on a dataset from sklearn.
Inherits from LDA.
Attributes:
dataset (Tuple[NDArray[Float64], NDArray[Any]]): The dataset to be used.
"""

def __init__(self, k: int, dataset: Tuple[NDArray[Float64], NDArray[Any]]):
"""
Initializes the LDAClassificationsSKLearns class with the specified number of components and dataset.
Args:
k (int): Number of components to keep.
dataset (Tuple[NDArray[Float64], NDArray[Any]]): The dataset to be used.
"""
super().__init__(k)
self.dataset: Tuple[NDArray[Float64], NDArray[Any]] = dataset

def forward_and_predict(self) -> float:
"""
Splits the data, fits the LDA model, and makes predictions.
Returns:
float: The accuracy of the model.
"""
X_train: NDArray[Float64]
X_test: NDArray[Float64]
y_train: NDArray[Any]
y_test: NDArray[Any]

X_train, X_test, y_train, y_test = train_test_split(
self.dataset[0], self.dataset[1], test_size=0.3, random_state=42)
self.fit(X_train, y_train)
y_pred: NDArray[Any] = self.predict(X_test)
accuracy: float = accuracy_score(y_test, y_pred)
return accuracy

0 comments on commit f1e2b9e

Please sign in to comment.