Python Forum
Retrieve variable from function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Retrieve variable from function
#1
Hi, I'm totally new to python and I'm using a code under the 'Example code' section from this wikipedia article:
https://en.wikipedia.org/wiki/Random_sample_consensus

My question is how I can modify this to retrieve the variable 'inlier_points' from the 'fit' function that starts on line 19.

Many thanks!
Reply
#2
inlier points may not be defined at all. You could do this:
class RANSAC:
    def __init__(self, n=10, k=100, t=0.05, d=10, model=None, loss=None, metric=None):
        self.inlier_points = None
        ....

    def fit(self, X, y):
        inlier_points = None
        ....
        self.inlier_points = inlier_points
        return self
Then you would use "regressor.inlier_points" to get the value.
Reply
#3
(Jul-01-2022, 07:20 PM)deanhystad Wrote: inlier points may not be defined at all. You could do this:
class RANSAC:
    def __init__(self, n=10, k=100, t=0.05, d=10, model=None, loss=None, metric=None):
        self.inlier_points = None
        ....

    def fit(self, X, y):
        inlier_points = None
        ....
        self.inlier_points = inlier_points
        return self
Then you would use "regressor.inlier_points" to get the value.

That works wonderfully, thank you very much!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Variable for the value element in the index function?? Learner1 8 633 Jan-20-2024, 09:20 PM
Last Post: Learner1
  Variable is not defined error when trying to use my custom function code fnafgamer239 4 576 Nov-23-2023, 02:53 PM
Last Post: rob101
  Printing the variable from defined function jws 7 1,283 Sep-03-2023, 03:22 PM
Last Post: deanhystad
  Function parameter not writing to variable Karp 5 936 Aug-07-2023, 05:58 PM
Last Post: Karp
  Cant transfer a variable onto another function KEIKAS 5 1,880 Feb-09-2022, 10:17 PM
Last Post: deanhystad
  Please explain uncommon way of declaring and using variable [function.variable] esphi 4 2,324 Nov-07-2020, 08:59 AM
Last Post: buran
  Spyder Quirk? global variable does not increment when function called in console rrace001 1 2,206 Sep-18-2020, 02:50 PM
Last Post: deanhystad
  passing variable to function Rejoice 4 2,868 Sep-11-2020, 03:27 AM
Last Post: Pleiades
  [split] Creating a variable as a function DPaul 23 6,667 Sep-07-2020, 05:20 PM
Last Post: DPaul
  Creating a variable as a function JarredAwesome 4 2,828 Sep-06-2020, 05:08 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020