[scikit-learn] question regarding 'RANSACRegressor' object has no attribute 'inlier_mask_'

Shang-Rou Hsieh srhsieh at yahoo.com
Fri Jul 29 18:41:37 EDT 2022


 Thanks. I will give it a try.

    On Friday, July 29, 2022 at 03:06:19 PM PDT, Guillaume Lemaître <g.lemaitre58 at gmail.com> wrote:  
 
 You need to fit the estimator to access the fitted attribute:
In [1]: from sklearn.linear_model import RANSACRegressor   ...: from sklearn.datasets import make_regression   ...: X, y = make_regression(   ...:     n_samples=200, n_features=2, noise=4.0, random_state=0)   ...: reg = RANSACRegressor(random_state=0).fit(X, y)

In [2]: 
In [2]: reg.inlier_mask_Out[2]: array([ True,  True,  True,  True,  True,  True,  True,  True,  True,        True,  True,  True,  True,  True,  True,  True,  True,  True,        True,  True,  True,  True,  True,  True,  True,  True,  True,        True,  True,  True,  True,  True,  True,  True,  True,  True,        True,  True,  True,  True,  True,  True,  True,  True,  True,        True,  True,  True,  True,  True,  True,  True,  True,  True,        True,  True,  True,  True,  True,  True,  True,  True,  True,        True,  True,  True,  True,  True,  True,  True,  True,  True,        True,  True,  True,  True,  True,  True,  True,  True,  True,        True,  True,  True,  True,  True,  True,  True,  True,  True,        True,  True,  True,  True,  True,  True,  True,  True,  True,        True,  True,  True,  True,  True,  True,  True,  True,  True,        True,  True,  True,  True,  True,  True,  True,  True,  True,        True,  True,  True,  True,  True,  True,  True,  True,  True,        True,  True,  True,  True,  True,  True,  True,  True,  True,        True,  True,  True,  True,  True,  True,  True,  True,  True,        True,  True,  True,  True,  True,  True,  True,  True,  True,        True,  True,  True,  True,  True,  True,  True,  True,  True,        True,  True,  True,  True,  True,  True,  True,  True,  True,        True,  True,  True,  True,  True,  True,  True,  True,  True,        True,  True,  True,  True,  True,  True,  True,  True,  True,        True,  True,  True,  True,  True,  True,  True,  True,  True,        True,  True])
Cheers,--Guillaume Lemaitre
Scikit-learn @ Inria Foundation
https://glemaitre.github.io/

On 29 Jul 2022, at 23:27, Shang-Rou Hsieh via scikit-learn <scikit-learn at python.org> wrote:
To whom it may concern,
Belows are the codes:
-  - - - - 
from sklearn.linear_model import RANSACRegressor

ransac = RANSACRegressor(LinearRegression(), 
                         max_trials=100, # default
                         min_samples=0.95, 
                         loss='absolute_error', # default
                         residual_threshold=None, # default 
                         random_state=123)
inlier_mask = ransac.inlier_mask_



- - - - 
Here is the error message: 

AttributeError: 'RANSACRegressor' object has no attribute 'inlier_mask_'

SO I checked the attributes of RANSACRegressor using dir (RANSACRegressor) and I do not find 'inlier_mask_'
 

Any advise?Henry 


_______________________________________________
scikit-learn mailing list
scikit-learn at python.org
https://mail.python.org/mailman/listinfo/scikit-learn


  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/scikit-learn/attachments/20220729/bce9ac05/attachment-0001.html>


More information about the scikit-learn mailing list