Reputation: 6372
I am using scikit for training classifiers. I was wondering if there is an option to get how much time a classifier/estimator took for the training task.
Upvotes: 6
Views: 18550
Reputation: 6086
Just use Python's time
module. For example:
import time
from sklearn.neural_network import MLPClassifier
from sklearn.datasets import load_iris
model = MLPClassifier()
X, y = load_iris(return_X_y=True)
start = time.time()
model.fit(X, y)
stop = time.time()
print(f"Training time: {stop - start}s")
# prints: Training time: 0.20307230949401855s
Upvotes: 10