Python Forum

Full Version: Retrieve variable from function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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!
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.
(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!