.. _example_applications_plot_prediction_latency.py:


==================
Prediction Latency
==================

This is an example showing the prediction latency of various scikit-learn
estimators.

The goal is to measure the latency one can expect when doing predictions
either in bulk or atomic (i.e. one by one) mode.

The plots represent the distribution of the prediction latency as a boxplot.




.. rst-class:: horizontal


    *

      .. image:: images/plot_prediction_latency_001.png
            :scale: 47

    *

      .. image:: images/plot_prediction_latency_002.png
            :scale: 47

    *

      .. image:: images/plot_prediction_latency_003.png
            :scale: 47

    *

      .. image:: images/plot_prediction_latency_004.png
            :scale: 47


**Script output**::

  Benchmarking SGDRegressor(alpha=0.01, average=False, epsilon=0.1, eta0=0.01,
         fit_intercept=True, l1_ratio=0.25, learning_rate='invscaling',
         loss='squared_loss', n_iter=5, penalty='elasticnet', power_t=0.25,
         random_state=None, shuffle=True, verbose=0, warm_start=False)
  Benchmarking RandomForestRegressor(bootstrap=True, criterion='mse', max_depth=None,
             max_features='auto', max_leaf_nodes=None, min_samples_leaf=1,
             min_samples_split=2, min_weight_fraction_leaf=0.0,
             n_estimators=10, n_jobs=1, oob_score=False, random_state=None,
             verbose=0, warm_start=False)
  Benchmarking SVR(C=1.0, cache_size=200, coef0=0.0, degree=3, epsilon=0.1, gamma=0.0,
    kernel='rbf', max_iter=-1, shrinking=True, tol=0.001, verbose=False)
  benchmarking with 100 features
  benchmarking with 250 features
  benchmarking with 500 features
  example run in 5.16s



**Python source code:** :download:`plot_prediction_latency.py <plot_prediction_latency.py>`

.. literalinclude:: plot_prediction_latency.py
    :lines: 15-

**Total running time of the example:**  5.22 seconds
( 0 minutes  5.22 seconds)