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.
Asked
Active
Viewed 1.6k times
6
-
Take a look at the [example gallery](http://scikit-learn.org/stable/auto_examples/index.html). Many of the examples show how to use standard Python functions for timing. – Fred Foo Mar 06 '14 at 09:58
1 Answers
9
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

stefanbschneider
- 5,460
- 8
- 50
- 88