.coef attribute

With reference to the code:
coefs = logistic_regression[-1].coef_[0]
I notice that the logistic_regression object has a [-1] and I do not understand why?

Please can you explain.

Thanks,
Daniel

I assume that the model is defined as:

logistic_regression = make_pipeline(
    StandardScaler(), LogisticRegression()
)

logistic_regression is therefore a pipeline and we want to access the coef_ attribute that is only accessible in the instance of LogisticRegression. Therefore, we get it by picking up the last step of the pipeline that is the meaning of [-1].

2 Likes