PyCon JP 2020での発表スライドです。 --------------------------- (2020/08/30) 誤字を修正しました。 場所: p15 誤: assert_array_close() 正: assert_allclose() ---------------…
1. 初めに Google Colabratoryの利用に有用なTipsを纏めます。 2. Google Drive マウント Google Colabでは、仮想環境の/content/にファイルが生成・保存されます。 例えば、自前の写真データセットを使いたい時を考えましょう。 /content/にデータセットを直接にアップロードする代わりに、そのデータセットを事前にGoogle Driveのどこかに入れてから、Google Driveをマウントします。そして、Google Driveの写真データセットのフォルダーを指定したほうが使いやすいです。 下記にサンプルコードを掲載します。 from google.colab import drive drive.mount('/content/drive') #Datasets Dir (例) base_dir = '/content/drive
待望のJupyter本, 改訂版来ました! Pythonでデータサイエンスとエンジニアリングするマンとしてかなり待望していた「PythonユーザのためのJupyter[実践]入門 改訂版」がついに来ました.*1 改訂版 Pythonユーザのための Jupyter[実践]入門 作者:池内 孝啓,片柳 薫子,@driller発売日: 2020/08/24メディア: 単行本(ソフトカバー) ひと足先に読ませていただいたので, 「PythonユーザのためのJupyter[実践]入門 改訂版」はPythonでデータサイエンスする人にとっての入り口でおすすめの本である Pythonでデータサイエンスをやるなら, 「Pythonと慣れ親しむ」「機械学習に慣れる」「実践する」の目的に合わせて学習・実践したり本を読んだほうがいいよ という話をこのエントリーではまとめていこうと思います. なおこのエントリーは
概要 絶賛フロントエンド勉強中の井上です。今回は自然言語処理界隈で有名なBERTを用いた文書分類(カテゴリー分類)について学習(ファインチューニング)から予測までを紹介したいと思います。本記事では実装ベースでお話しするので、「そもそもBERTって何?」という方は検索するか、参考URLを載せておくのでそこから飛んでいただけると助かります。 目次 事前準備 学習 評価 予測 参考文献 事前準備 Google Colaboratory 学習は膨大な計算量が必要なので、Google Colaboratoryを使用します https://colab.research.google.com/notebooks/welcome.ipynb?hl=ja 無料でTPU(Tensor Processing Unit)が使えるのでお得! googleさんありがとうございます TPUはIntelのHaswellと
pandas はデータ解析やデータ加工に非常に便利なPythonライブラリですが、並列化されている処理とされていない処理があり、注意が必要です。例えば pd.Sereis.__add__ のようなAPI(つまり df['a'] + df['b'] のような処理です)は処理が numpy に移譲されているためPythonのGILの影響を受けずに並列化されますが、 padas.DataFrame.apply などのメソッドはPythonのみで実装されているので並列化されません。 処理によってはそこがボトルネックになるケースもあります。今回は「ほぼimportするだけ」で pandas の並列化されていない処理を並列化し高速化できる2つのライブラリを紹介します。同時に2つのライブラリのベンチマークをしてみて性能を確かめました。 pandarallel pandaralell はPythonの m
はじめに 最近、異常検知に関する案件に関わって、結構苦労しました。 その理由の一つとして、異常検知の手法については一部本がでているもののそこまで多くはなく、また、異常検知プロジェクトの進め方という意味では情報があまり見つけられなかったというのがあります。 そこで、プロジェクト実施前に、こんな情報があればよかったなという内容についてまとめました。 自分が関わった案件は、設備のセンサーデータを用いた異常検知だったため、その内容に偏っていますが、全体の流れや考え方としてはあまりドメインや異常検知によらないものと思います。 なお、個別の異常検知のアルゴリズムについては話しません。 また、読者の対象しては、異常検知に興味がある人、機械学習プロジェクトに興味がある人を想定しています。 異常検知を取り巻くコミュニケーション 前提として、「異常検知」という言葉でイメージするものは人によって違います。関係者
こんにちは。LIFULLでデータアナリストをしている宮野です。 普段はサービス周りのデータ分析を行っているのですが、TVCMの効果検証を行う機会があり、その際CausalImpactという時系列因果推論フレームワークを使用したのでご紹介いたします。 【目次】 はじめに Pythonを用いたCausalImpact データの準備 効果検証 共変量の確認と選定 / 周期性(シーズナリティ)の付与 ①共変量 ②周期性(シーズナリティ) RのCausalImpactとの結果比較 RでのCausalImpact実装 PythonとRの検証結果比較 おわりに はじめに CausalImpactとは? →Googleがリリースした時系列因果推論の"R"パッケージです。 そう。Rのパッケージです。当然Rを使って効果検証を行うのが通常だと思います。 なのですが、私自身Pythonを使用することが多く、どうせ
1. はじめに テーマ「"やってはいけない” アンチパターンを共有しよう!」…色々とネタが思い当たります! 最近再び出会った、とある問題についてご紹介しようと思います。 2. それは画像の異常検知を解いていたときのこと… 画像の異常検知とは、正常な画像に対して異常な画像を検出して、例えば不良品の選別などに使う技術です。 図: MVTec ADウェブサイトより、緑 の正常サンプルに対する 赤 の異常サンプル例。 普通あまり「異常の画像」が発生しないので、「距離学習」という手法を使って「正常品じゃない度合い」を数値化して、この数値が大きいと「異常だ!」とみなす方法などがあります。 その一つ、記事「幾何変換を使った効果的な深層異常検知 (CNN画像分類モデル/教師なし/MVTec異常検知データセット)」で紹介した「DADGT」という略称の手法を試していたときのことです。 3. 学習〜やったね、A
はじめに 評価関数(評価指標)についてあやふやな理解だったので、代表的な評価関数をまとめてみました。 評価関数とはそもそもどんなものなのか、それぞれの評価関数はどんな意味を持つのか、実際に使う時のサンプルコードを簡単にまとめています。 評価関数の追加や内容の修正は下記でしています。 評価関数とは 評価関数とは学習させたモデルの良さを測る指標を指します。 目的関数との違い 機械学習を勉強していると、目的関数や損失関数、コスト関数などいろいろな名前を目にします。 まずは、目的関数との違いについて確認します。 目的関数 モデルの学習で最適化される関数 微分できる必要がある つまり、学習中に最適化されるのが目的関数、学習後に良さを確認するための指標が評価関数ということになります。 損失関数、コスト関数、誤差関数は目的関数の一部になるそうです。 (いくつか議論がありそうなのですが、ほとんど同じものと
一般社団法人データサイエンティスト協会(所在地:東京都港区、代表理事:草野 隆史、以下データサイエンティスト協会)は、構造化データの加工について実践的に学ぶことができる無料の学習環境「データサイエンス100本ノック(構造化データ加工編)」をGitHubに公開しました。 「データサイエンス100本ノック(構造化データ加工編)」は、データサイエンス初学者を対象に、データの加工・集計、統計学や機械学習を駆使したモデリングの前処理等を学べるよう、データと実行環境構築スクリプト、演習問題をワンセットにしています。 近年、データ活用の重要性についての認知が広がる中で、書籍やWebサイトなど、データ分析のスキル向上に役立つ情報源も多く提供されています。一方で、実践するための「データ」や「プログラミング実行環境」を持ち合わせていないことも多く、「実践力」を身につける機会が限られていました。特に、「構造化デ
機械学習・ディープラーニング関係の本を整理してみた 以下のような事情もあり、初心者向けに良い本って何だろうなと家にある機械学習・ディープラーニング関係の書籍を引っ張り出してきました。 新入社員としてAI人材が来るという話を聞いていたので「色々教えてもらおう!」と楽しみにしていたのですが、配属直前になって「ソフトウェアの経験は無いらしい、AI人材に育ててほしい」と言われたときの顔してます。そんなことある?— からあげ (@karaage0703) June 5, 2020 紙の書籍 電子書籍 正確には、紙の本も電子書籍もここに無いもの(noteやboothで買ったもの)が数冊あるので、全部入れて40冊程度でした。なんとなく100冊くらいは読んでるかと思っていたのですが全然でした。人間の感覚って当てにならないものですね。ただ、良く考えると、何か1つのジャンルで10冊も書籍持っているかというと、
近年盛んにおこなわれている機械学習の手法を用いた因果推論についていつ利用するかの大まかな理解とメモ(備忘録) 基本的には現在の因果推論手法のフローチャート的まとめ はじめに 因果推論とは、結果に対する原因を答えることを目的とした一連の統計的手法である。一般に回帰分析などの統計的アプローチでは、Xの変化がYの変化とどのように関連しているかを定量化することに重きをおいている。一方で統計的因果推論は、Xの変化がYの変化を引き起こすかどうかを判断し、この因果関係を定量化することに重きをおいている。近年盛んである機械学習と因果推論の融合分野は、このうち特定の条件下における因果効果の推定に用いられる。今回は既存の因果推論の手法と機械学習を用いた手法の使い分けを大まかに整理した。 当然だが有するデータに対して「何を、なぜ知りたいか?」を明確にしてから分析していく。 でないと、取るべき戦術が見えてこない。
本記事では、データサイエンティスト、AIエンジニアの方がPythonでプログラムを実装する際に気をつけたいポイント、コツ、ノウハウを私なりにまとめています。 AIエンジニア向け記事シリーズの一覧 その1. AIエンジニアが気をつけたいPython実装のノウハウ・コツまとめ(本記事) その2. AIエンジニアが知っておきたいAI新ビジネス立案のノウハウ・コツまとめ 2020年4月に書籍を、出版しました。 【書籍】 AIエンジニアを目指す人のための機械学習入門 実装しながらアルゴリズムの流れを学ぶ(電通国際情報サービス 清水琢也、小川雄太郎 、技術評論社) https://www.amazon.co.jp/dp/4297112094/ 本投稿は、上記の書籍に書ききれなかった 「AIエンジニアが、Pythonでプログラムを実装する際に気をつけたいことのまとめ」 です。 本記事の内容は、あくまで筆
初の機械学習プロジェクトを仕事でおこなった。その際に、各プロセスでこういう部分をみたり考えたりした方が良さそうだと思ったことをまとめる。 なお、機械学習プロジェクトの話は「仕事ではじめる機械学習」をはじめとして既に色々なところで議論されている*1。しかし、いくつか読んだがマクロな話が中心だったので、どちらかというとミクロ部分の機械学習モデルを構築する という部分を中心に書く。 なお、経験者から指摘されたり教えられた点を1度機械学習プロジェクトをやっていったんまとめただけなので、今後追加・修正される暫定版なことに注意。 ワークフロー 機械学習プロジェクトのワークフローはざっくりと以下のようになる。 1. 要件を定める やることとしては、 目的 スケジュール 期待値 どの程度の精度ならよいか どのようなアプローチを取るか を決める。 このあたりの話は、前述のように「仕事ではじめる機械学習」など
適宜修正や追記を行いながら、勉強した内容を共有していきたいと思います。 ※現状、主に回帰タスクにフォーカスして書いています。 他のタスクにおいては、仕様が異なる箇所があるかもしれませんので留意ください。 (ざっと確認している範囲では、タスク間で概ね仕様は共通な様です。) 本ドキュメントについて PyCaretの前処理にフォーカスしています。 基本的に、モデリングやチューニングなどの部分には触れておりません。 実際に動かしつつ、本家ソースコードを読んだりもしながら記述しております。 https://github.com/pycaret/pycaret ※誤ってる箇所もあるかもしれませんが、あらかじめご了承ください。 実装上の前提 次のように各種ライブラリはimportしているものとします。
独特のお作法があって初心者が引っかかりがちなmatplotlibの入門記事です 試行環境 windows10 jupyter notebook 使うデータ なんでも良いですが、iris使っときます import pandas as pd from sklearn.datasets import load_iris iris = load_iris() data = pd.DataFrame(iris.data, columns=iris.feature_names) data.head() 1. グラフいろいろ 基本的に全部matplotlib.pyplotを使います。また、jupyter notebookで表示する為に%matplotlib inlineとしておきます。(最近は%matplotlib inlineしなくても2回目以降表示されるようになったようですが一応やっときます)
本日は PythonでGISデータを扱う際に便利なライブラリについてまとめてみようと思います。ほとんどが過去のエントリーで紹介しているものですが、これからGISデータを扱おうと思っている方やたくさんライブラリがある中でどういったものを選択していいのか迷っている方はぜひ参考にしてみてください。 メジャーなライブラリ まずはこれを使っておけば間違いないというライブラリを紹介します。 GDAL PythonのGIS系ライブラリと言えばまずGDALを思い浮かべるくらいメジャーなライブラリです。ベクターからラスター、また、データの読み込みから書き込みまで基本的なことは何でもできると考えて大丈夫です。過去のエントリーでもGDALに関していくつかの機能を紹介しています。 www.gis-py.com www.gis-py.com www.gis-py.com www.gis-py.com GeoPand
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く