Jason JIANG
    • 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
    # 國道車流資料整理 ## 主題 國道五號的 南港-頭城 預測未來10~30分鐘是否會塞車 會塞多久 進一步去預估行車時間 ## 待討論事項 1. 氣象資料是否需使用(氣象會影響數據結果,但現階段資料不好處理) 2. 查找文獻資料,討論使用哪些模型 3. 討論機器學習流程 ## 已完成事項 1. M05A、幾何資料的資料前處理(處理後的完整資料已上傳雲端) ## 使用資料 [雲端硬碟](https://drive.google.com/drive/folders/19Ntd-GlvBV9qI-oz9BwCJCgrmPICsuos?usp=sharing) https://tisvcloud.freeway.gov.tw/documents/TDCS%E4%BD%BF%E7%94%A8%E6%89%8B%E5%86%8Av41b.pdf --- [點擊下載:原始幾何資料](https://freeway2025.tw/2025_Route_Geometry.zip) ❌[各類車種通行量統計各類車種 (M03A)](https://tisvcloud.freeway.gov.tw/history/TDCS/M03A/) 依車輛種類通過單一偵測站統計之交通量 ––欄位: ––TimeInterval: 報表產製時間(每5分鐘統計) ––GantryID: 測站編號,例如01F0005N即為[基隆-基隆端] ––Direction: 車行方向,S南、N北 ––VehicleType: 車種,31小客車、32小貨車、41大客車、42大貨車、5聯結車 ––Traffic: 交通量:計算單一偵測站於此時階範圍內所經過之車流總量 ---------------------------- 國道五號(南港-頭城) [偵測站代碼](https://www.freeway.gov.tw/UserFiles/TDCS%20operaion%20manual.pdf): GantryID: 05F0000S (南港系統-石碇) 0.0----1 05F0001N (石碇-南港系統) 150.0----5 05F0055N (坪林行控專用道-石碇) 5550.0----6 05F0055S (石碇-坪林行控專用道) 5500.0----2 05F0287N (頭城-坪林行控專用道) 28750.0----7 05F0287S(坪林行控專用道-頭城) 28790.0----3 05F0309N 宜蘭(四城、大福)-頭城 30000----8 05F0309S 頭城-宜蘭(四城、大福) 30000----4 速限: 坪林(15K)以北 80 坪林(15K)以南 90 門架緯度 門架經度 最近里程 最近里程緯度 最近里程經度 距離(km) 0 25.035089 121.622931 0.0 25.035497 121.623476 0.071254 1 25.034972 121.624861 150.0 25.035071 121.624872 0.010990 2 24.996156 121.652097 5550.0 24.996037 121.652245 0.019928 3 24.996467 121.652058 5500.0 24.996499 121.652162 0.011083 4 24.842639 121.789286 28750.0 24.842743 121.789355 0.013447 5 24.842569 121.788967 28790.0 24.842387 121.789298 0.039127 6 24.823706 121.786214 30000.0 24.831312 121.790912 0.969572 [站間各車種中位數行駛車速 (M05A)](https://tisvcloud.freeway.gov.tw/history/TDCS/M05A/) ––TimeInterval: 報表產製時間(每5分鐘統計) ––GantryFrom: 上游測站編號,例如01F0017N即為[八堵-基隆] ––GantryTo: 下游測站編號,例如01F0005N即為[基隆-基隆端] ––VehicleType: 車種,31小客車、32小貨車、41大客車、42大貨車、5聯結車 ––SpaceMeanSpeed: -單一車輛計算車速:相鄰上下游偵測站之門架距離/旅行時間(km/hr) ––中位數車速:該時階各車種所有車輛車速之中位數 ––Traffic: 交通量:計算單一偵測站於此時階範圍內所經過之車流總量 ❌[路段即時路況動態資訊(v2.0)(Section)](https://tisvcloud.freeway.gov.tw/history/motc20/Section/) ––UpdateTime:本平台資料更新時間(ISO8601格式:yyyy-MM-ddTHH:mm:sszzzz) ––UpdateInterval:本平台資料更新週期(秒) ––AuthorityCode:業管機關簡碼 ––LinkVersion:路段編號版本 ––SectionID:機關發布路段代碼 ––TravelTime:路段平均旅行時間, 單位:秒 ––TravelSpeed:路段平均旅行速度, 單位:KM/Hr, 另數值250表示為道路封閉 ––CongestionLevelID:壅塞水準組別代碼 ––CongestionLevel:壅塞級別 = ['-99:路段即時資料異常', '-1:道路封閉'] 壅塞級別 = ['0: 未知/資料不足', '1: 順暢', '2: 車多', '3: 車多', '4: 壅塞', '5: 壅塞'] 壅塞級別 = ['0: 未知/資料不足', '80km/hr以上: 順暢', '60~79km/hr: 車較多', '40~59km/hr: 車多', '20~39km/hr: 較壅塞', '0~19km/hr: 壅塞'] ––HasHistorical:是否包含歷史資料 = ['0: 不包含', '1: 包含'] ––HasVD:是否包含VD資料(車輛偵測器) = ['0: 不包含', '1: 包含'] ––HasAVI:是否包含AVI資料(自動車輛辨識) = ['0: 不包含', '1: 包含'] ––HasETAG:是否包含ETag資料(eTag電子辨識) = ['0: 不包含', '1: 包含'] ––HasGVP:是否包含GVP資料(GPS Vehicle Probe) = ['0: 不包含', '1: 包含'] ––HasCVP:是否包含CVP資料(Cellular Vehicle Probe) = ['0: 不包含', '1: 包含'] ––HasOthers:是否包含其他多元路況資料 = ['0: 不包含', '1: 包含'] ––DataCollectTime:資料蒐集時間(ISO8601格式:yyyy-MM-ddTHH:mm:sszzzz) ❌氣象 <station> <StationID>466881</StationID> <StationName>新北</StationName> <StationNameEN>New Taipei</StationNameEN> <StationAltitude>24.1</StationAltitude> <StationLongitude>121.520000</StationLongitude> <StationLatitude>24.959300</StationLatitude> <CountyName>新北市</CountyName> <Location>新店區莒光路29號</Location> <StationStartDate>2023-01-01</StationStartDate> <StationEndDate/> <status>現存測站</status> <Notes>為臺北氣象站板橋站區(站碼466880)遷移之新站,於2023/01/03上午11時取代舊站開始提供觀測資料。</Notes> <OriginalStationID>466880</OriginalStationID> <NewStationID/> </station> 找出Location包含"南港"、"石碇"、"坪林"、"頭城"的資料,並且status="現存測站" ❌一年觀測資料測站地點:"宜蘭" ## 研究流程 第一階段:找壅塞的時段與路段,並找出哪些特徵影響壅塞 第二階段:預測未來速度、流量 ### 分類任務 #### 實驗步驟: 1.定義問題:二分類 or 多分類 2.資料前處理 >將M05A中包含目標門架的代碼選出(參考上方GantryID),並把volume(車流量)=0的資料整筆刪除, 做特徵工程 時間窗口 > 時間序列中,一個時間點的狀態往往與之前幾分鐘/幾小時有關,因此可以對 Speed / Volume 做滑動窗口計算,然後篩選重要的時間窗口特徵。 滯後特徵 > 把「過去的數值」當成新的欄位給模型用,讓它知道歷史狀態 變化率特徵 >新增欄位:量化「變快還是變慢,以及變多少」 3.特徵選取策略 頻域特徵FTT > 全部特徵 > 基於統計相關性(例如皮爾森/卡方) > 基於模型重要度(RF / XGB feature_importances_) > 遞迴特徵消除(RFE) > 僅時間特徵 vs 僅交通特徵 vs 全部混合 4.模型組合 >機器學習:DT、RF、XGB >深度學習:RNN、LSTM、GRU >找最佳超參數:Optuna 5.模型訓練與交叉驗證 > 訓練時間 > 預測時間 > 模型大小 > 分類指標(Accuracy, F1, Precision, Recall) > 混淆矩陣(看不同壅塞等級的辨識情況) 6.分析結果 產出報告 / 可視化 ### 回歸任務 ### 資料前處理 將M05A中包含目標門架的代碼選出(參考上方GantryID),並把volume(車流量)=0的資料整筆刪除, 做特徵工程 #### 程式碼說明 1.merge_MA.py(把一天的24個檔案合并為一個) 2.download_data.py (下載路段即時路況動態資訊(v2.0)) 3.MA_download.py(下載M03A、M05A) 4.pre_mainroad.py(主道資料處理) 5.pre_ramp.py(匝道資料處理) --- #### M03A 原本下載的資料為一天一個多個檔案(以小時劃分)(2024/01/06~2025/06/15),我們將全部的檔案合并成一個csv,並根據GantryID篩選所需資料。 #### M05A 同 M03A #### 路段即時路況 先下載,然後解壓縮,每分鐘會有一個xml檔案,透過SectionID:365~370篩選資料,匯入至一天一個的csv 最後再把每天合并成一個 #### 00道路幾何特性資料 手動刪除部分序列(非南港-頭城路段之資料) 使用雲端硬碟的程式碼(pre_mainroad.py, pre_ramp.py)刪除部分欄位(匝道.csv) ### 模型訓練 ### h3 📅 處理日期:20250315 ❌ 當日無符合條件 Section 資料:20250315 📅 處理日期:20250316 ❌ 當日無符合條件 Section 資料:20250316 📅 處理日期:20250322 https://chatgpt.com/share/688a287a-5050-800b-8f70-8606e81772d0 https://data.zhupiter.com/oddt/7739175/03F0698N/ https://data.nat.gov.tw/dataset/21165 https://chatgpt.com/share/689243cd-f83c-8000-852e-14411b111c56 典: https://chatgpt.com/share/689df29d-dab4-800d-b3e5-812cf63fa8e1 AML:https://chatgpt.com/share/689b6974-ae5c-800b-9a94-8ee6168d506c GRU:https://chatgpt.com/share/689e131f-5750-800b-8161-a42b96611b43 生成GRU code:https://chatgpt.com/share/689f517e-9f20-800b-b74f-f63acd44e4ff XGB:https://chatgpt.com/share/68a1cfaf-f834-800b-8a61-bc3fd8813052 RF、DT:https://chatgpt.com/share/68a342c0-e770-800b-b107-d8c9a301e171 ❌氣象資料:宜蘭 ### [RF.py](https://drive.google.com/file/d/1w-9x0k4rQlQ4TkfMwcT73NJnBNkXkNZe/view?usp=drive_link) ### [GRU.py](https://drive.google.com/file/d/1USoUp_lf7q9CBP-3m-8dL-p1NMHMJcp1/view?usp=drive_link) 1.是否賽車(塞車1/順暢0)可以換分級(順暢1/車略多2/車多3/壅塞4/大壅塞5) 多步預測 ### 分類任務 ### import pandas as pd # 讀取你的 optuna 結果 df = pd.read_csv("results.csv") # 依 test_rmse 排序,選前 10 個 top_candidates = df.sort_values("test_rmse").head(10) # 計算 cv 和 test 差距 top_candidates["gap"] = top_candidates["test_rmse"] - top_candidates["cv_rmse"] # 按照 test_rmse + gap 排序 best = top_candidates.sort_values(["test_rmse", "gap"]).iloc[0] print("最佳模型:") print(best) Word:https://1drv.ms/w/c/095c45f0b6059a6b/EcSDKeNPL0NEumLCY90mrlwB1D9EKwABpxBU7AUhI0XsVg

    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