Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atender impresión de nombre de acuerdo su tipo (String o Callable) #6

Open
jerryperezperez opened this issue Oct 9, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@jerryperezperez
Copy link
Collaborator

 def _compute_statistics(self, num_cases: int, predictionTargetWindow: np.ndarray, correlation_per_window: np.ndarray, target):

        self.bestDic = {index: correlation_per_window[index] for index in self.best_windows_index}

        self.worstDic = {index: correlation_per_window[index] for index in self.worst_windows_index}

        self.bestSorted = sorted(self.bestDic.items(), reverse=True, key=lambda x: x[1])

        self.worstSorted = sorted(self.worstDic.items(), key=lambda x: x[1])
        # TODO Probablemente solamente guardar bestSorted y tratarlo con el nombre de bestDic o best_windows, además de solo contemplar hasta num_cases
        self.bestSorted = self.bestSorted[0:num_cases]
        self.worstSorted = self.worstSorted[0:num_cases]

        print("Calculando MAE para cada ventana")
        for tupla in self.bestSorted:
            self.bestMAE.append(
                mean_absolute_error(target[tupla[0]], predictionTargetWindow.reshape(-1, 1)))

        for tupla in self.worstSorted:
            self.worstMAE.append(
                mean_absolute_error(target[tupla[0]], predictionTargetWindow.reshape(-1, 1)))

        print("Generando reporte de análisis")
        # Version with method name as column name
        # d = {'Index': dict(self.bestSorted).keys(), self.method: dict(self.bestSorted).values(), "Best MAE": self.bestMAE,
        #      'Index': dict(self.worstSorted).keys(), self.method: dict(self.worstSorted).values(),
        #      "Worst MAE": self.worstMAE}
        # Version 1.0 when CCI was the only one method defined
        # TODO Atender impresión de nombre de acuerdo su tipo (String o Callable)
        # TODO Verificar correcto funcionamiento de creación del objeto Dataframe
        d = {'index': dict(self.bestSorted).keys(), self.method: dict(self.bestSorted).values(), "MAE": self.bestMAE}
        # The worst indices were disabled in order to remove the duplicated keys such as index.1 and so forth
        # 'index.1': dict(self.worstSorted).keys(), 'other': dict(self.worstSorted).values(),
        # "MAE.1": self.worstMAE
        self.analysisReport = pd.DataFrame(data=d)
@jerryperezperez jerryperezperez added the bug Something isn't working label Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants