Sammy Chiu
    • 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
      • Invitee
    • 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
    • Engagement control
    • 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 Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control 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
Invitee
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
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Python 體驗教學 --- ### Why Python IEEE Spectrum 2018 排名 ![IEEE Spectrum 2018](https://i.imgur.com/Zm4jQZh.png) 資料來源 IEEE Spectrum ---- #### What is Python Guido van Rossum 1991 年開發完成是一種直譯程式語言 開源 , 免費的程式語言 設計哲學是「優雅」、「明確」、「簡單」 可讀性和簡潔的語法,開發容易, 豐富的模組,減低開發時間 被業界廣泛使用(Google, Banks ...) ---- #### Python Environment Anaconda 是最廣泛使用的開發環境 已經包含Python 直譯器與常用的Libraries Anacoda 下載 https://www.anaconda.com/download/#macos --- ### Python 基礎知識 Python 使用縮排(Indentation)來管理程式區塊 所以不能任意縮排, 需要對齊 使用 #來做註解 ---- ### Python 開發的好習慣 正確縮排 所有的變數命名都要有意義 做註解 --- ## Python 基礎知識 ---- 整數 int a=10 浮點數 float b=3.14 負數 complex c=1+2j 字串 str d='python' ---- ### A. 數字處理 #### 基本 + - * / #### 位移 #### 布林運算 ---- #### 1. 基本運算 ```python= x=99 print(x) print(x + 1) # 加法 print(x - 1) # 減法: print(x * 2) # 乘法: print(x / 2) # 除法: print(x // 2) # 整數除法 print(x % 2) # 餘數: print(x ** 2) # 指數: ``` ---- #### 2. 位移 ```python= y=5 print (bin(y)) # y 的二進制 print(y<<1) print(bin(y<<1)) ``` ---- #### 3. 布林運算 ```python= print( x == y) print( x!= y) print(x > y) ``` ---- ### B. 字串處理 1. 字串相加與列印 2. 常用字串函數 ---- #### 1. 字串相加與列印 ```python= str3 = str1 + ' ' + str2 # 字串連接 print(str3) #列印第二個字元 print(str3[1]) #重 0 開始計算 ``` ---- #### 2. 常用字串函數 upper() # 轉成大寫 rjust() # 右邊填空白字元 ---- ### D. 條件式 1. if 2. if else 3. if elif else ---- ```python= if grade > 80: print("成績{}非常好".format(grade)) elif grade >60: print("成績及格!") else: print("成績不及格!") ``` Python 沒有 switch 與 case --- ### C. 迴圈控制 for Loop while Loop ---- #### For Loop ```python= for i in range(1, 10): s = s + i ``` 文法: 迴圈內要空 4 格 range(start,end,step) i 從 start 執行到 end-1, 每此執行i加step start default=0 ,step default =1 ----- #### while Loop ```python= while n <= m: r = r * n n = n + 1 ``` 文法: 迴圈內要空 4 格 當n 符合條件就繼續執行 ---- ### break and continue break 跳出循環 continue 暂停当前循环执行后面的语句 ---- ## 實作 利用 for loop 與 while 計算1到1000的基數和 --- ### Python 的資料型態 元組 tuple t=(1,2,4,'data') 串列 list l=[1,2,4,'data'] 字典 dict d={'name':'sammy','salary':1000,'index3','data'} 集合 set s=set(['sammy',1000,'data3']) ### E.元組處理 #### 1. 用括弧建立元組 #### 2. For loop 走訪元組 ---- #### 用括弧建立元組 ```python= t = (5, 6, 7, 8) # 建立元組 ``` 元組不能修改 ---- #### 走訪元組 ```python= for ele in t: # 走訪項目 print(ele, end=" ") # 顯示 "5, 6, 7, 8" ``` ---- ### F. List 處理 List 建立 list 切割 List 走訪 List VS Tuple ---- #### List 建立 ```python ls = [6, 4, 5, 'sammy'] # 建立清單 ``` 用中括號 list 可建立多维列表但不是矩阵, 不可做數學運算 ---- #### list 切割 ```python= print(nums[2:4]) # 切割索引2~4(不含4) ``` ---- #### List For Loop 走訪 ``` animals = ['cat', 'dog', 'bat'] for animal in animals: print(animal) for index, animal in enumerate(animals): print(index, animal) ``` enumerate() 將 index 也帶出 ```python= list(enumerate(animals)) # [(0, 'cat'), (1, 'dog'), (2, 'bat')] ``` ---- ### List VS Tuple ---- #### List 可以儲存數值: list1=[1, 2, 3] 可以儲存字串:list2=['a', 'p', 'p', 'l', 'e'] 可以進行操作 list1+list2 與包含方法 list.append()等 ---- #### Tuple 可以儲存數值: tuple1=(1, 2, 3) 可以儲存字串:tuple2=('a', 'p', 'p', 'l', 'e') 可以進行操作 tuple1+tuple2 tuple的元素值不可以修改!不可以刪除! 資料型態的大小比list來得小, 適合使用在,像是月份、星期等不可修改的資料 可以避免不小心更改到元素值, 同時也可以增加執行效能~~ --- ### G. Set 集合 set 建立 set 走訪 Set 運算 ---- set 為無序的, 不重複的集合 set 建立 ```python= animals = {"cat", "dog", "pig"} ``` 大括號建立 Set ---- set 走訪 ```python= portfolios = {"TSMC","UMC","Acer"} for index, stock in enumerate(portfolios): print(f'{index} {stock}') ``` ---- set 運算 交集 & 聯集 | 差集 - --- ### H. 字典處理 用大括號建立字典 字典查詢 For loop 走訪字典 ---- 用大括號建立字典 ```python= d = {"TSMC": 2330, "UMC": 2303, "acer": 2353} ``` ---- 像字典依樣讓人查詢 查詢"TSMC" 得到 2330 ---- For loop 走訪字典 ```python= for company in d: ticker = d[company] print(company, ticker) ``` ---- ### dict VS set #### dict 字典通常是可變的,可以新增刪除、修改鍵值 #### set set 存不重複值 --- #### I.Function 將常用的相似功能寫成函數(Function) 讓code更簡潔 ```python= def my_function(name): print(f'My name is {name}') my_function(sammy) my_function(may) ``` --- #### J.模組 Module 模組讓你站在巨人的肩膀上開發程式 ```python= import sample_module import sample_module as sa from sample_module import sample_func ``` 常用 Python 模組 https://zhuanlan.zhihu.com/p/21563130 --- ### NumPy ---- NumPy是Python語言的一個擴充程式庫。支援高階大量的維度陣列與矩陣運算,此外也針對陣列運算提供大量的數學函式函式庫。 NumPy引入了多維陣列, 讓 Python 運算多維陣列速度跟C 一樣 ---- Numpy 基礎應用 NumPy 的合併與分割 Numpy 運算 ---- ### Numpy 基礎應用 Numpy 建立 : 需要同一個形態 Numpy 資料走訪 Reshape 陣列 ---- Numpy 運算 Numpy 的 + - * / ---- ### NumPy 的合併與分割 垂直/水平堆疊 橫向縱向分割 資料的複製 --- ### Pandas Panel Data = pandas 兩個主要數據結構Series和DataFrame ---- #### Series 一維陣列 像是有 index 的 list或 dict ---- DataFrame 二位陣列 像是 excel sheet, 或 SQL table ---- Pandas 資料處理與I/O ![Pandas IO](https://i.imgur.com/lpLFb5H.png) http://pandas.pydata.org/pandas-docs/version/0.23/io.html/ ---- Pandas 實際資料處理範例 使用政府開放資料 https://data.gov.tw 不動產實價登錄資訊-租賃案件-中和區 https://data.gov.tw/dataset/38441 不動產實價登錄資訊-租賃案件-永和區 https://data.gov.tw/dataset/38439 --- ### Matplotlib ---- 折線圖 直方圖 圓餅圖 --- ## 資料分析/人工智能四階段 1. 準備資料 2. 挑選演算法 3. 調整演算法參數 4. 評估結果 ---- ### 準備資料 收集足夠資料 確保資料品質 ---- ### 挑選資料分析/人工智能演算法 非監督式學習 監督式學習 ---- #### 非監督式學習 K-mean 主成分分析 關聯規則 社群網路分析 ---- #### 監督式學習 回歸 K-near 向量機 決策樹 神經網路 ---- #### 調整演算法參數 ![](https://i.imgur.com/POChw6q.png) ---- #### 評估結果 ---- 手寫辨識資料庫 MNIST http://yann.lecun.com/exdb/mnist/ ---- MNIST 資料集是卷積神經網路之父 Yann LeCun (揚.勒丘恩) 於貝爾實驗室進行圖像識別研究時所蒐集, 他也是在此時發明了卷積神經網路. from Wiki ---- 人工智能快速入門 Python + Tensorflow + Kearas ---- #### Tensorflow 最初由Google 開發, 現在開源 可以用在不同平台上 對Python 支援最好 ---- Keras 開源之高階深度學習程式庫 高階程式碼 運行在Tensorflow 之上 ---- Keras 運作方式 Keras 只處理模型的建立,訓練,預測 再交給Tensorflow 做底層運算 ---- Keras 範例 1. 建立Sequential() 建立模型 2. 加入輸入層與隱藏層 3. 加入輸出層 ---- MLP 介紹 ![](https://i.imgur.com/9b2Ttvu.png) ---- 損失函數(loss function)是用來估量你模型的預測值f(x)與真實值Y的不一致程度, 原文網址:https://kknews.cc/zh-tw/other/pqpjja2.html 评价函数的主要任务就是估计等搜索结点的重要程度,以确定结点的优先级程度

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