model[-1].n_iter_[0]
please what does this mean ‘model[-1]’ and n_iter[0]
I looked up to check what model[-1]
mean and i got an error. Please can you explain?
Hi,
if you just print model using print(model), you will see the following output:
Pipeline(steps=[('standardscaler', StandardScaler()),
('logisticregression', LogisticRegression())])
Using square brackets you have an access to the steps in the model. In this case -1
is used to receive the last item in the list. You can find more information about accessing items in a list here:
By printing print(model[-1])
you get the name of the model used in your pipeline: LogisticRegression()
Using a point you can have an access to all attributes which the model has. You can find them via this link:
n_iter_
means how many iterations have been made to have the model trained by fitting data. It returns a list and that’s why we use here square brackets to take a value out of the list.
1 Like