Closed amroca79 closed 1 year ago
Hi @amroca79, the error you encountered indicates that there is an issue accessing the named_steps
attribute for a member of type BaseEstimator
. The named_steps
attribute is specific to sklearn's Pipeline
class, to resolve the issue, please make sure you are using the named_steps
attribute on a valid Pipeline
object. Please reopen the issue if you have any further questions, thanks!
This does not fix the problem. When I enter pipeline.named_steps I retrieve all the scallers and models in the pipeline object without any calculations performed. If my logic is correct, I'm trying to figure it out which is the best scaller and hyperparameters to be used for an specific type of data. Below is my logic, feel free to correct me if I'm wrong:
and finally using,
input:
grid_s.best_estimator_.named_steps['scaler']
output:
MaxAbsScaler()
I believe It executes the right code, but I still get a warning.
If you would like additional assistance, please post a self-contained, minimal code sample that demonstrates your problem. The sample you provided at the top of this issue has a number of syntax errors, and it references symbols that are not supplied in the code sample. For example, GridSearchCV
is not defined anywhere, so it's unclear where this symbol comes from or how it is defined.
I just updated the code above. I hope is correct. Your help is much appreciated
I guess I found a solution for my own problem with chatGPT. If anyone needs help...
Go to Users setting.json
and add:
"python.analysis.diagnosticSeverityOverrides": {
"reportGeneralTypeIssues": "none",
},
Thanks for nothing
We think we can fix this by making GridSearchCV
generic in our sklearn
stubs.
Disabling reportGeneralTypeIssues
is a big hammer. It's going to disable a lot of diagnostics unrelated to this particular issue.
In the meantime you can suppress the diagnostic on a particular line using the techniques described here.
thank you for the clarification. Very helpful
This issue has been fixed in prerelease version 2023.6.11, which we've just released. You can find the changelog here: CHANGELOG.md
I updated pylance to version v2023.6.10 but I still have the same issue
It was fixed in 2023.6.11, not 2023.6.10. The prerelease version. See Heejae's comment above.
It should end up in 2023.6.20 today.
thank you. It looks good now
Environment data
Code Snippet
Input:
Output:
Expected behavior
.named_steps execute without warning.
Actual behavior
.named_steps executes with warning.
Cannot access member "named_steps" for type "BaseEstimator" Member "named_steps" is unknownPylancereportGeneralTypeIssues (function) named_steps: Unknown
Logs