yasunori-kajiwara
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 機械学習モジュール :::info :bulb:ここでは、線形回帰分析およびロジスティック回帰分析の機能をGoogleCloudに実装し、モデル作成から予測までを自動で実行するモジュールの導入方法をご紹介します。 この機能を使うことで、線形回帰(回帰)、ロジスティック回帰(分類)での分析において分析方法や評価方法、利用するツールが統一されるため、品質が一定になります。またGoogleCloudでの基盤構築時の機械学習分析部分の実装をラクにできます。 ::: ## 導入手順 **1. 事前準備** 1. 任意のProjectのBigqueryにモデル用データと予測用データをテーブルとして登録する ・BigqueryMLの一部機能は`us-central1`でのみ利用可能なため、`us-central1`にする。 ・テーブルはID、説明変数、目的変数(予測時には不要)の構成で、それ以外は削除しておく 2. 以下のリンクから線形回帰もしくはロジスティック回帰のモジュールのZIP(liner_reg.zip)をダウンロードする [・線形回帰モジュールはこちら](https://drive.google.com/drive/folders/1HBfcmDhrlJ4CwTEf5M5yHLxK878FtxC8) [・ロジスティック回帰モジュールはこちら](https://drive.google.com/drive/folders/1GlMZyHZP4WytRIcNt2Df2Dukm9kEB-JN) **2. Cloudfunctionsの作成と実行** 1. Cloudfunctionsに移動する 2. [+関数の作成]をクリックする 3. 基本設定を行い[保存]ボタンを押下する * 環境:`第二世代`を選択(画像とは異なるので注意) * 関数名:任意の関数名 * リージョン:任意のリージョン(`asia-northeast1`推奨) * トリガーのタイプ:状況に応じて任意だが、`HTTPS`推奨 ![](https://i.imgur.com/oj8rcHv.png) 4. ランタイム、ビルド、接続、セキュリティの設定を行う * タイムアウト:3600 * サービスアカウント:`Functionsの実行権限`を付与したサービスアカウントをセットする 権限を持つサービスアカウントがない場合は作成する * その他の設定値:デフォルト ![](https://i.imgur.com/8HDj9Do.png) 5. ランタイム環境変数を設定し、[次へ]ボタンを押下する * UUID:他と被らない、ユニークなUUIDを設定する モデル評価値が規定値から外れた場合にアラートを出す場合に使用する [UUID生成ツール](https://uuid.doratool.com/) * PROJECT:対象のプロジェクトを入力 * DATASET:対象のデータセットを入力(Bigqueryのデータセット) * IN_MODEL_TABLE:モデル作成用のテーブル名を入力 * IDE:モデル用・予測用データのIDカラム名を入力 * FLAG:モデル作成用データの正解カラム名を入力 * IN_PREDICT_TABLE:予測用のテーブル名を入力 * ALGORITHM:不要 ![](https://i.imgur.com/moYgk2g.png) 6. 2でダウンロードしたZIPをアップロードし、[デプロイ]ボタンを押下 * ZIPファイル:ダウンロードしたZIP * ステージバケット:任意のバケット、ディレクトリを設定 zipファイルがここにアップロードされるが、デプロイ後に削除してよい。 ![](https://i.imgur.com/qhChKEb.png) 7. 動作確認 * デプロイが正常に完了したら、[テスト中]タブを押下 * テストコマンドにある[CLOUD SHELLでテストする]を押下 * CLOUD SHELLが立ち上がりテストコマンドが自動で入力されるため、[Enterキー]を押す テストが実行されCLOUD SHELL上にOKと出力されれば動作確認完了 ![](https://i.imgur.com/po4Q4vb.png) 8. 対象のデータセットに以下のテーブルが出力される ※⑤は存在しない | | テーブル | 概要・目的 | |:-----:| ---------- | ---------------------------------------- | | (A) | 任意の名称 | モデリングに使用するデータ用のテーブル | | (B) | 任意の名称 | スコアリングに使用するデータ用のテーブル | | ① | 01_model_categorize | modelテーブルを用途ごとに色分けしたテーブル(トレーニング用/評価用) | | ② | 02_modeling | モデル(モデリングを実施した結果) | | ③ | 03_model_scoring | モデルを評価用データを利用して検証した結果のテーブル | | ④ | 04_judgment_index | モデルの評価結果から評価用の指標を計測した結果(線形回帰は決定係数、ロジスティック回帰はAUC) | ⑥ | 06_scoring | 予測結果 | | ⑦ | 07_output_data | 予測結果(CSV出力用) | **3. アラートの設定** 1. GoogleCloudの検索窓から「ログ エクスプローラ」で検索し、「ログ エクスプローラ」画面へ遷移する 2. [アラート作成]をクリックする 3. アラート詳細情報を入力し、[次へ]ボタンを押下する * Alert Policy Name:任意のアラート名称を入力 ここに記入した内容がメールの件名に反映される * Choose logs to include in the alert:UUIDを入力 * 通知の間隔、インシデントの自動クローズ期間:最も短い時間を設定 * Who Shoud be notified?:アラートの通知チャネルをセットする 通知チャネルがない場合は[通知チャネルを管理]を押下して作成する ``` 通知チャンネルの設定方法 例:メール通知の場合 1.Emailにて[ADD NEW]を押下する。 2.メールアドレスと表示名を入力して[SAVE]を押下する。 3.元のアラート設定画面に戻り更新アイコンをクリックすると作成した表示名が通知チャンネルとして表示される。 4.チェックボックスに✓を付け、[OK]を押下する。 ``` ![](https://i.imgur.com/018oK3b.png) ![](https://i.imgur.com/ujO1jq4.png) ![](https://i.imgur.com/Y8A3VHR.png) ![](https://i.imgur.com/VDZHvBw.png) 4. アラートのサンプルが通知されているか確認し、問題がなければ完了 例:メール通知の場合 ![](https://i.imgur.com/gYkW8jG.png)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully