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__":
|
if __name__ == "__main__":
|
||||||
learn_dataset(auto_mpg)
|
learn_dataset(automobile)
|
||||||
|
|||||||
@@ -77,18 +77,24 @@ class MLAlgorithm(ABC):
|
|||||||
@abstractmethod
|
@abstractmethod
|
||||||
def predict_loss(self, dataset:np.ndarray) -> float: pass
|
def predict_loss(self, dataset:np.ndarray) -> float: pass
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def plot(self, skip:int=1000) -> None: pass
|
|
||||||
@abstractmethod
|
|
||||||
def get_parameters(self): pass
|
def get_parameters(self): pass
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def set_parameters(self, parameters): pass
|
def set_parameters(self, parameters): pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
|
||||||
class MLRegression(MLAlgorithm):
|
|
||||||
def plot(self, skip:int=1000) -> None:
|
def plot(self, skip:int=1000) -> None:
|
||||||
skip = skip if len(self._train_loss) > skip else 0
|
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("training", "blue", data=self._train_loss[skip:])
|
||||||
plot.line("validation", "red", data=self._valid_loss[skip:])
|
plot.line("validation", "red", data=self._valid_loss[skip:])
|
||||||
plot.wait()
|
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 math as math
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from learning.ml import MLRegression
|
from learning.ml import MLRegression, MLClassification
|
||||||
from learning.data import Dataset
|
from learning.data import Dataset
|
||||||
|
|
||||||
class LinearRegression(MLRegression):
|
class LinearRegression(MLRegression):
|
||||||
@@ -36,3 +36,7 @@ class LinearRegression(MLRegression):
|
|||||||
|
|
||||||
def set_parameters(self, parameters):
|
def set_parameters(self, parameters):
|
||||||
self.theta = parameters
|
self.theta = parameters
|
||||||
|
|
||||||
|
|
||||||
|
class LogisticRegression(MLClassification):
|
||||||
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user