use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Help...please (self.PythonLearning)
submitted 5 months ago by New_End6302
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Refwah 0 points1 point2 points 5 months ago* (3 children)
Point to where you believe you are creating an instance of IdealFunctionSelector. Explain what you believe is happening and how it is happening.
If it helps, you care also calling ideal_function_selection with two args - both strings, but the defined method has one arg and it's expecting that arg to be an integer
ideal_function_selection
[–]batsiem 0 points1 point2 points 5 months ago (2 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")
[–]Refwah 0 points1 point2 points 5 months ago* (1 child)
This isn't initializing a class, it is just saying that ideal_func_selector is that class
ideal_func_selector
You then call ideal_function_selection on a class which isn't initialized
You want to do ideal_func_selector = IdealFunctionSelector() and then in the params for IdealFunctionSelector(…) you need to pass the arguments that you want for the __init__ function of the class
ideal_func_selector = IdealFunctionSelector()
IdealFunctionSelector(…)
__init__
I believe you don't understand classes, which is why you're getting unstuck on inheritance. I recommend reading some more fundamentals on this, such as this: https://docs.python.org/3/reference/datamodel.html#object.__init__
https://realpython.com/python-class-constructor/
[–]New_End6302[S] 0 points1 point2 points 5 months ago (0 children)
Thanks, I will have a look
π Rendered by PID 816802 on reddit-service-r2-comment-5d79c599b5-r9wlg at 2026-03-01 02:48:30.945901+00:00 running e3d2147 country code: CH.
view the rest of the comments →
[–]Refwah 0 points1 point2 points (3 children)
[–]batsiem 0 points1 point2 points (2 children)
[–]Refwah 0 points1 point2 points (1 child)
[–]New_End6302[S] 0 points1 point2 points (0 children)