Skip to content

Commit

Permalink
fix bugs :: fix names
Browse files Browse the repository at this point in the history
  • Loading branch information
parvvaresh committed Jan 2, 2025
1 parent 0656902 commit 9f9c982
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
Binary file added cluster_ga/__pycache__/cluster.cpython-313.pyc
Binary file not shown.
Binary file added cluster_ga/__pycache__/genetic.cpython-313.pyc
Binary file not shown.
10 changes: 5 additions & 5 deletions cluster_ga/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import matplotlib.pyplot as plt
from sklearn import datasets
import random
from .genetic import genetic
from .genetic import GeneticClustering


class Cluster:
def __init__(self, X: np.array, y: np.array, size_population: int = 200, goal: float = 0.7, iters: int = 200) -> None:
class cluster:
def __init__(self, X: np.array, y: np.array, size_population: int = 200, goal: float = 0.9, iters: int = 200) -> None:
self.X = X
self.y = y
self.size_population = size_population
Expand All @@ -23,7 +23,7 @@ def __init__(self, X: np.array, y: np.array, size_population: int = 200, goal: f
def fit(self) -> None:
for _ in range(self.size_population):
chromosome = self._create_random_chromosome()
self.population.append(genetic(chromosome, self.X, self.genom))
self.population.append(GeneticClustering(chromosome, self.X, self.genom))

self.counter = 1

Expand Down Expand Up @@ -51,7 +51,7 @@ def fit(self) -> None:

# Apply mutation to the new population
for index in range(self.size_population):
self.population[index] = genetic(self.population[index].mutation(), self.X)
self.population[index] = GeneticClustering(self.population[index].mutate(), self.X, self.genom)

# Update fitness scores
self.fitness.append(self.population[0].fitness_scores)
Expand Down
1 change: 1 addition & 0 deletions cluster_ga/genetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def __init__(self, chromosome: dict, points: np.array, list_class: list) -> None
self.chromosome = chromosome
self.points = points
self.list_class = list_class
self.fitness_scores = self.get_fitness()

def get_fitness(self):
labels = np.array(list(self.chromosome.values()))
Expand Down

0 comments on commit 9f9c982

Please sign in to comment.