0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

IPython NotebookとPythonスクリプトのハイブリッド開発で機械学習プロジェクトを高速イテレーションしよう

Posted at

IPython Notebookはたしかに便利だ。
実行結果をすぐに確認できるし、初心者が雰囲気を知るのには丁度いいのかもしれない。
しかし、IPython Notebookしか触ったことない人が実務のPython開発に耐えられるだろうか?
Pythonの用途的にWebサーバーアプリケーションが多いと思うが、データ処理の経験だけではPython実行環境の理解からキャッチアップしなくてはならない。
そこで、アプリケーションとしてスムーズに組み込むためにハイブリッドなアプローチを紹介する。

IPython Notebookの弱点

  • モジュールとしてシステムに組み込めない
  • 実行時のパスがファイルの位置になる
  • インタラクティブ故に自動化に向かない
  • 保守性が悪い

これらの弱点はPythonプロジェクトの作法を取り入れることでマシになる

とりあえずuv1択

uvしか勝たん!
condaをやめろ pip3をやめろ 依存関係地獄を抜けろ!
今すぐ薄暗い部屋で

curl -LsSf https://astral.sh/uv/install.sh | sh

を浴びせろ!

uvプロジェクトを作る

お好きな名前で

uv init project-name
cd project-name

image.png

uvのvenvを有効にする

uv sync

編集可能モードでプロジェクトをインストール

 uv pip install -e .

適当なオブジェクトを追加するなどする

image.png

ipykernelをインストールする

uv add ipykernel

uvの速さに驚くがいい

スクリプトのコードからimportする

image.png

うれしいね

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?