Skip to Content
Hands-On Automated Machine Learning
book

Hands-On Automated Machine Learning

by Sibanjan Das, Umit Mert Cakmak
April 2018
Beginner to intermediate content levelBeginner to intermediate
282 pages
6h 52m
English
Packt Publishing
Content preview from Hands-On Automated Machine Learning

Profiling your Python script line by line

Go to your Terminal and run the following command:

$ pip install line_profiler

Once installation is finished, you can save the preceding snippet to a filename knn_prediction.py.

As you have noticed, nearest_neighbors_prediction is decorated as follows:

@profiledef nearest_neighbors_prediction(x, data, labels, k):

It allows line_profiler to know which function to profile. Run the following command to save the profile results:

$ kernprof -l knn_prediction.py

The output will be as follows:

StartWrote profile results to knn_prediction.py.lprof

You can view the profiler results as follows:

$ python -m line_profiler knn_prediction.py.lprofTimer unit: 1e-06 sTotal time: 0.001079 sFile: knn_prediction.py ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Automated Machine Learning

Automated Machine Learning

Adnan Masood
R: Unleash Machine Learning Techniques

R: Unleash Machine Learning Techniques

Raghav Bali, Dipanjan Sarkar, Brett Lantz, Cory Lesmeister

Publisher Resources

ISBN: 9781788629898Supplemental Content