Start classiffication
- added datasets - start to creating the classes
This commit is contained in:
10001
datasets/classification/electrical_grid.csv
Normal file
10001
datasets/classification/electrical_grid.csv
Normal file
File diff suppressed because it is too large
Load Diff
7196
datasets/classification/frogs.csv
Normal file
7196
datasets/classification/frogs.csv
Normal file
File diff suppressed because it is too large
Load Diff
@@ -42,4 +42,4 @@ def learn_dataset(function:Callable[..., tuple[int, MLRegression]], epochs:int=1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
learn_dataset(auto_mpg)
|
||||
learn_dataset(automobile)
|
||||
|
||||
@@ -77,18 +77,24 @@ class MLAlgorithm(ABC):
|
||||
@abstractmethod
|
||||
def predict_loss(self, dataset:np.ndarray) -> float: pass
|
||||
@abstractmethod
|
||||
def plot(self, skip:int=1000) -> None: pass
|
||||
@abstractmethod
|
||||
def get_parameters(self): pass
|
||||
@abstractmethod
|
||||
def set_parameters(self, parameters): pass
|
||||
|
||||
|
||||
|
||||
class MLRegression(MLAlgorithm):
|
||||
@abstractmethod
|
||||
def plot(self, skip:int=1000) -> None:
|
||||
skip = skip if len(self._train_loss) > skip else 0
|
||||
plot = Plot("Error", "Time", "Mean Error")
|
||||
plot = Plot("Loss", "Time", "Mean Loss")
|
||||
plot.line("training", "blue", data=self._train_loss[skip:])
|
||||
plot.line("validation", "red", data=self._valid_loss[skip:])
|
||||
plot.wait()
|
||||
|
||||
|
||||
|
||||
class MLRegression(MLAlgorithm):
|
||||
def plot(self, skip: int = 1000) -> None:
|
||||
return super().plot(skip)
|
||||
|
||||
class MLClassification(MLAlgorithm):
|
||||
def plot(self, skip: int = 1000) -> None:
|
||||
return super().plot(skip)
|
||||
@@ -1,7 +1,7 @@
|
||||
import math as math
|
||||
import numpy as np
|
||||
|
||||
from learning.ml import MLRegression
|
||||
from learning.ml import MLRegression, MLClassification
|
||||
from learning.data import Dataset
|
||||
|
||||
class LinearRegression(MLRegression):
|
||||
@@ -36,3 +36,7 @@ class LinearRegression(MLRegression):
|
||||
|
||||
def set_parameters(self, parameters):
|
||||
self.theta = parameters
|
||||
|
||||
|
||||
class LogisticRegression(MLClassification):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user