Skip to Content
Pythonデータサイエンスハンドブック ―Jupyter、NumPy、pandas、Matplotlib、scikit-learnを使ったデータ分析、機械学習
book

Pythonデータサイエンスハンドブック ―Jupyter、NumPy、pandas、Matplotlib、scikit-learnを使ったデータ分析、機械学習

by Jake VanderPlas, 菊池 彰
May 2018
Intermediate to advanced
556 pages
13h 21m
Japanese
O'Reilly Japan, Inc.
Content preview from Pythonデータサイエンスハンドブック ―Jupyter、NumPy、pandas、Matplotlib、scikit-learnを使ったデータ分析、機械学習
1.9
 コードのプロファイリングと実行時間計測
27
かの巧妙なことを行っているという事実の結果です。例えば、実行時間に影響を与えるかもしれな
い使用していない
Python
オブジェクトのクリーンアップ(ガベージコレクション)を抑止します。
このため、
%timeit
の結果は通常、
%time
の結果よりも著しく高速です。
%time
%timeit
は、
%%
を付けたセル
Magic
構文を使うと、複数行のコードの実行時間計測が可
能となります。
In[6]: %%time
total = 0
for i in range(1000):
for j in range(1000):
total += i * (-1) ** j
CPU times: user 504 ms, sys: 979
μ
s, total: 505 ms
Wall time: 50
5 ms
%time
%timeit
の詳細、および使用可能なオプションについては、
IPython
ヘルプ機能を使用し
てください(
IPython
プロンプトで
%time?
と入力します)。
1.9.2
 コード全体のプロファイリング:
%prun
プログラムは多くの文から構成されており、時にはそれぞれの文を単独で時間計測するよりも、
文脈の中で実行時間計測することが重要な場合があります。
Python
には組み込みのコードプロファ
イラ(
Python
のドキュメント
1
が提供されています)が含まれていますが、
IPython
はこのプロファ
イラを
%prun
Magic
コマンドとして実行できる便利な機能を提供しています。 ...
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

Pythonデータサイエンスハンドブック 第2版 ―Jupyter、NumPy、pandas、Matplotlib、scikit-learnを使ったデータ分析、機械学習

Pythonデータサイエンスハンドブック 第2版 ―Jupyter、NumPy、pandas、Matplotlib、scikit-learnを使ったデータ分析、機械学習

Jake VanderPlas, 菊池 彰
初めてのGraphQL ―Webサービスを作って学ぶ新世代API

初めてのGraphQL ―Webサービスを作って学ぶ新世代API

Eve Porcello, Alex Banks, 尾崎 沙耶, あんどうやすし

Publisher Resources

ISBN: 9784873118413Other