KAO_OAK
    • 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
    # 專題:Model Ball [![hackmd-github-sync-badge](https://hackmd.io/GkDflnk9QcqAzlNA31NfuQ/badge)](https://hackmd.io/GkDflnk9QcqAzlNA31NfuQ) ## 目的 選擇前五局的大小分來做分析研究,利用機器學習讓模型判斷出在該比賽條件下,前五局最後的總分會是大於或小於基準。 ## 事前規劃 ![](https://i.imgur.com/Xi4v14X.png) 事前所須的準備資料,主要從兩大方向去進行,一方面是可以量化的數字型態資料,另一方面是無法量化的文字型態資料。 * 量化資料方面,除了主要的***歷史球賽紀錄***外,還收集了***天氣***資料,因為濕度會影響投手投出的球的運行軌跡和轉速;***大小分及賠率***當做比較基準,最後是***球場***資料,因為每個球場大小距離都不一樣,這也會影響到我們的判斷結果。 * 非量化資料方面,選擇了美國最普及的社群媒體 - twitter 來做分析。目的是想要從各大意見領袖的發文中,藉由情感分析去獲取大家對比賽的意見及看法,進而成為不同來源的參考依據。 ## 架構示意圖 ![](https://i.imgur.com/zDmegXd.jpg) * 量化資料的部份,我們利用python從網路上的數據庫中爬取到原始資料後,先儲放在hadoop叢集上,清洗過後再送入模型中訓練,最後將結果存放至mysql。 * 非量化資料的部份,一樣是透過python的爬蟲套件從twitter上爬取相關帳號的文章,儲放至ES,當中也有利用到kafka做為溝通媒介分配工作,最後再將分析的結果透過kibana來做視覺化的呈現。 * 與使用者互動的部份,選擇了最方便普及的linebot,在我們的chatbot上使用者輸入了查詢之後,我們利用了kafka來確保使用者資料不丟失,也利用了redis來增加查詢效率,減少使用者等待的時間。以上除了hadoop我們是選擇在本地端架設之外,其餘的服務我們也都將其包進docker容器化並架設在GCP雲端平台上。 ## [分工部分]-情感分析 1. 首先將Elasticsearch的服務包進docker並架設在GCP雲端平台 2. 情感分析流程首先為收集推特文章內容,使用到的套件有Tweepy與Twint接著,針對推文的部分做資料處理,處理完之後,利用TextBlob library做情感分析,最後將結果視覺化呈現,使用的是Elasticsearch的Kibana ![](https://i.imgur.com/1WOheXt.jpg) > python code 目錄 - crawling > * get_id_from_wiki.py - 取得用戶twitter帳號id > * hello_tweepy_learning.py - tweepy操作方法 > * hello_tweepy_get_user_information.py - 利用tweepy取得用戶twitter information > * csv_to_json.py - csv轉換成json的資料格式 > * twint_nltk.py - 利用twint取得用戶twitter information 3. 利用下關鍵字的方式去爬取推文,所下的關鍵字包含了MLB 與各球隊隊名,然後利用Tweepy跟Twint來爬取我們感興趣的推文內容 ![](https://i.imgur.com/n7PVLJC.jpg) 以李奧納多的推文為範例,This is great progress. 我們可以設定This和is為stop word. 然後移除標點符號 剩下的great被判定為positive,progress 被判定為neutral 我們即可認爲這篇推文為一篇正向的推文 ![](https://i.imgur.com/48v3oOZ.jpg) > python code 目錄 - sentiment analysis > * NLTK_test_01.py - how to use NLTK packages > * NLTK_test_02.py - how to use NLTK packages > * NTLK_twitter.py - twitter's sentiment analysis > * NLTK to ELK.py - send data to ELK > * Map_to_ES.py - make fan's map ![](https://i.imgur.com/TkuMd9G.jpg) 4. 資料分析方面,在清理推文的部分,我們將對情感分析並無影響的部分移除,其中包含像是標點符號,Hashtags, Mentions,(網址) URLs並且還原縮寫的部分,像是 I can't會還原成 I can not另外表情符號在推文中是十分常出現的,所以我們也針對了表情符號的部分做文字的轉換 ![](https://i.imgur.com/bxvF4hU.jpg) 以 "Hello MLB !! 😁 :-) “為例 透過python還原成Hello MLB !! happy face Happy face smiley ![](https://i.imgur.com/KKk8DTY.jpg) 我們可以發現,原本的neutral推文約有33萬,經由把表情符號轉換成文字,我們可以多判定了5萬則推文為positive或是negative ![](https://i.imgur.com/g4ufKIo.jpg) 在判定推文情緒方面,仍然還是有很多因素造成推文會被判定為neutral,像是推文長度太短,或是推文含有縮寫 ![](https://i.imgur.com/HHIvwED.jpg) 還有諷刺性的推文跟看不出明顯情緒的推文 5. 最後視覺化呈現的部分我們呈現了不同語系國家的情感分析,我們可以發現英語在推特的使用還是佔了主要的部分,其次之為日文,然後才是西班牙文,另外也可以觀察到三種情緒分別在不同國家佔的比例 ![](https://i.imgur.com/iz8yGZ8.jpg) ![](https://i.imgur.com/w0pnrHU.png) 我們也呈現了不同球隊聲量圖與情感分析關係圖,我們可以發現關於芝加哥小熊的推文數量最多,我們也能分別觀察每個球隊三種情緒推文的數量各佔多少 ![](https://i.imgur.com/v35tqd3.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