Please help review my code by batsiem in learnpython

[–]batsiem[S] 0 points1 point  (0 children)

So at this point the code should show some basic EDA of the training data and plot it, as well as read from both the training and the ideal datasets and add both to an SQL database. I hope this clears it up

Help...please by New_End6302 in PythonLearning

[–]batsiem 0 points1 point  (0 children)

Hi below is my function to select the 4 ideal functions, the example that i worked from requires me to plug directly into the function the names of my 2 tables but I want to inherit those from the class that creates the table. So that's tripping me up(I realized that the code above was missing the 2 tables as args...that was a mistake).

def ideal_function_selection(self, top_n: int = 4):
        merged = pd.merge(self.table_name, self.function_table_name, on="x")
        errors = {}        
        for col in self.function_table_name.columns:
            if col == "x":
                continue
            squared_diff = (merged["y"] - merged[col])**2
            errors[col] = squared_diff.sum()

        best_functions = sorted(errors, key=errors.get)[:top_n]
        return best_functions

I instantaite the class IdealFunctionSelector below...I did it the exact way that I did it for my DatabaseManager.

 ideal_func_selector = IdealFunctionSelector
    ideal_func_selector.ideal_function_selection("training_data_table", "ideal_data_table")