跳到主要內容

發表文章

文章沒人看? 簡單增添文章可看度的4個重點

現在這個資訊氾濫的時代,在每個視野與專注力所及的地方,都充斥著來自網路世界的種種誘惑。來自信箱、通訊軟體、APP的各種廣告、通知與推薦,根本閃都閃不掉。 以我自己為例,我昨天起床第一眼看手機,就顯示了: 30封的未讀信件(包含公司訊息與行銷電子報) 250條的未讀LINE訊息(分散6個群組) 5條的遊戲APP聊天通知 10條的行銷、金融APP新貨上架通知 5篇的新聞提醒(包含金融、科技、時事) 你算一下...約300項的新內容,不斷用閃爍與跳出掠奪我的眼球,要我趕快去確認與閱讀!而這個還只是早上8點這個 Moment 的份量,更別提進入上班時間後不斷跑出來的未讀數字了... 上班前半小時的我 這導致了我自己在閱讀資訊的時候變得 「非常不耐煩」,也許一整篇文章洋洋灑灑500字不算多,充滿著高度的「含金量」,但是一點進去我卻往往看5秒鐘就跳出了,然後跟這篇文章說掰掰。 對我來說,能夠立刻告訴我重點的文章才有閱讀的價值。 但是當我自己寫文章的時候,卻發現自己卻也是走洋洋灑灑的風格,動輒一定要寫下5、600字才能夠表達我心中澎湃的情感。 這也導致了我嘔心瀝血的文章往往乏人問津,完全對不上自己在寫文章時所用心的程度,讓我非常的失落。 所以為了增加讀完程度,我思考我自己看文章的幾個重點,條列如下: 標題我有沒有興趣 ? 裡面的圖漂亮嗎? 吸引我嗎? 文章的第一行與結論看起來是我要的嗎? 條列與表格的內容是不是我要的重點? 如果把上面的內容,轉換成撰寫文章時執行的方式,我會這麼做: 標題直接明瞭,直達你想解決的問題 文章充滿好的說明圖片 文章使用開門見山法,同時在結論時呼應重點 把重點條列成表格,讓閱讀者看到整理過的資訊 最後在我深自反省後,覺得必須時常提醒自己: 幫助閱讀者快速看到重點,是撰文者的責任。 希望以上內容對你來說是有用的,如果喜歡也請幫我按個掌聲吧 : )

[python] geopandas 安裝報錯-解決流程

# GeoPandas 安裝報錯-解決流程 這個問題主要是發生在部份的 dependency 安裝會報錯,需要個別的安裝 unofficial 版本 # 解決方法: 1. 前往  https://www.lfd.uci.edu/~gohlke/pythonlibs/ 2. Download GDAL 2.4.1.whl 3. Download pyproj 2.2.2 .whl 4. Download Shapely 1.6.4 .whl 5. Download Fiona 1.8.6 .whl then ```python pip install {path_to_whl}.whl #安裝完成後 pip install geopandas ```

[ROS] Nodelet Example

In order to successfully build a node that uses a nodelet for transport, we have to fix a lot of things when using catkin_create_pkg : 1. CMakeList.txt 2. package.xml 3. nodelet_plugin.xml 4. main.cpp Explain in order: 1. CMakeList.txt Pay special attention to adding a nodelet ``` code Cmake_minimum_required(VERSION 2.8.3) Project(lidars_grabber_nodelet) Find_package(catkin REQUIRED COMPONENTS   Nodelet   Roscpp   Rospy   Std_msgs ) # Because the nodelet is referenced as a lib, so add this paragraph Add_library(${PROJECT_NAME}    Src/lidars_grabber_nodelet.cpp  ) #把 nodelet as a dependent library If(catkin_EXPORTED_LIBRARIES)   Add_dependencies(lidars_grabber_nodelet ${catkin_EXPORTED_LIBRARIES}) Endif() # Remember to attach nodelet_plugins.xml # nodelet_plugins.xml is manually added  Install(FILES   # myfile1   # myfile2   Nodelet_plugins.xml   DESTINATION ${CATKIN_PACKAGE_SHARE_DESTIN...

[ROS] Nodelet Introduction

在 ROS 平台中,我們經常需要在各個 node 之中傳輸各種資料。 當這些資料屬於數kb~數MB 的小型檔案時, Ros 可以很順利且快速的進行傳輸,但是當這些檔案大至數百MB甚至GB以上時,在每個節點進行資料打包, 傳輸, 接收, 解包資料將會變得非常浪費時間與資源。 甚至在高頻率的資料傳輸上,將會導致嚴重的延遲或是資料丟失的情形發生。 ROS 平台為了改善這個問題,提供了一種解法 "nodelet" ,其作法近似於C++裏面的 zero copy。  實現的作法是將某一個節點(通常是第一個)所處理完成的資料記憶體位址記下來,後續在進行資料傳輸時,並不實現資料本體,而是改用傳輸記憶體位址的方式進行。 這種作法可以大大改善傳輸效率,將可能造成嚴重延遲的大型檔案轉為僅為幾KB不到的記憶體位置,達到在傳輸資料時近乎零延遲的情形。 In the ROS platform, we often need to transfer various materials among the nodes. When these materials belong to a small file of several kb to several megabytes, Ros can be transmitted smoothly and quickly, but when these files are as large as hundreds of MB or even GB, data is packaged, transmitted, and received at each node. Unpacking data will become a waste of time and resources. Even in the transmission of high-frequency data, serious delays or data loss will occur. To improve this problem, the ROS platform provides a solution "nodelet" that works similar to zero copy in C++. T...

[Tensorflow] How to install Tensorflow for aarch64 CPU (build from source)

Tensorflow is a powerful deep learning suite  that is now widely used in the development and application of various deep learning. Although there are many users, if there are special projects that must install tensorflow on different versions / operating systems / programming languages / platforms, it is often necessary to  find answers in the sea of google , and must continue to test after found. Build form Source  can basically solve most of the problems, but because it takes a lot of time and is difficult, it causes some people to have some difficulties in installation. aarch64 | python/C/C++ | ubuntu (build from source)

[Tensorflow] How to Install Tensorflow for C API

So many options for Tensorflow.... Tensorflow is a powerful deep learning suite   that is now widely used in the development and application of various deep learning. Although there are many users, if there are special projects that must install tensorflow on different versions / operating systems / programming languages / platforms, it is often necessary to  find answers in the sea of google , and must continue to test after found. Build form Source  can basically solve most of the problems, but because it takes a lot of time and is difficult, it causes some people to have some difficulties in installation. Here are a few of the tensorflow installation methods tested by myself.

[python] pip 更新到18.0 後出現 "ImportError: cannot import name 'main'"

剛剛自己測試後, 成功解除 pip upgrade 後出現 ImportError 的暴力的爛解法XD #個人環境 os: ubuntu 16.04 LTS python: 2.7 #先將 pip 移除 python -m pip uninstall pip #按 y 即可 #下載下列檔案並存成 "get_pip.py" https://gist.github.com/mikechan0731/547711ccacca3010d00748d3671c6569 #啟動此檔案 $ cd {TO_FILE_LOCATION} $ sudo python get_pip.py --ignore-installed 這樣就會把 pip 裝回來啦~測試後也沒有再出現 import name 'main' 的問題了~ 想要了解真正解法的可以看這個 issue (看來真的很多人出這個問題啊) https://github.com/pypa/pip/issues/5240

[生活] FB 下載相簿卻沒有反應怎麼辦?

今天為了幫外婆下載FB相簿裡面的相片,真的是耗了我不少腦力... 因為一直按了下載相簿都沒有反應,就 Google 了 "FB照片下載"...找了半天,都還是一直推我去抓一個擴充軟體: 不是我不喜翻你啊~是你不能用啊~~ 然後在因緣際會之下,才發現原來FB跟Chrome的搭配有這個問題, 總之後來順利解決了,那就做個紀錄順便分享一下吧! 成功開始下載了!

[ML] 機器學習參考資料與資料來源連結

最近學習 Hahow 的課程: Python 機器學習與資料科學入門學得太起勁, 累積了參考資料一大堆分頁,記憶體都要不夠啦! 所以列表如下,之後找資料庫比較方便: Kaggle:  https://www.kaggle.com/datasets Scikit-Learn:  http://scikit-learn.org/stable/ 政府開放資料平台:  https://data.gov.tw/

[python] pandas Series 超快速值域轉換!

最近 hahow 通知 Python 資料分析&機械學習入門 開課了! 所以無所事事的無職男決定重拾一下寫 code 的樂趣 前面都順順的講解一下各式大神/關鍵字/資料庫來源/參考來源等等。 說真的光是這些東西就真的很值得。 只要知道關鍵字,就算是神我也肉搜給你看 -by me 在重複看了一次的 jupyter notebook 與 pandas 簡單教學之後, 開始正式處理資料分析: 鳶尾花 Iris 的分析。 意外的簡單地抓取資料來結合,然後其中一行就吸引到我了: y1 = pd.DataFrame(pd.Series(iris['target']).map(dict(enumerate(iris['target_names']))),columns= ["target_names"])

[python] 使用 python 控制 docx 範例

因為同事的需求,無職 a 我就又再度幫忙同事寫一些小程式。 這些小程式雖然簡單,但是聽到如果不幫忙寫程式解決,以手工作業的"大量人天" 的後果真的是讓人吐血。 他們有一份工作,需要產出一份很多很多很多資料圖片的判釋報告,要把數百張圖片剪裁成特定大小,加上圖說之後放入 word 裡面。 聽到的做法是...一張一張插圖!! wooow! That's really shocking me! 所以為了前公司同事的幸福,我還是加減寫一下好了。

[python] 使用 pandas 內插不完全的資料

朋友 pass 一份資料給我,希望可以幫忙處理掉 missing data ,將遺失的時間找出來,同時用內插補足遺失時間的座標。 資料長相: Sec, North, East, Height 94184, 167433.988, 2529517.036, 19.623 94185, 167434.573, 2529516.984, 19.678 94186, 167433.788, 2529516.993, 19.598 94187, 167433.804, 2529516.966, 19.606 94189, 167433.852, 2529516.910, 19.604 94190, 167433.872, 2529516.882, 19.602 94194, 167433.919, 2529516.825, 19.602 ...  你可以看到其中 94188s, 94191s~94193s 的資料是遺失的,就是要補足這些資料。 原本以為是個簡單的問題,結果一弄弄了兩天解不出來,真的是氣死我了, 還去查了 time format, pandas intersect...結果 try 了半天都得不到理想結果, 只好半放棄地去問 stackoverflow( 連結在此 ),結果立馬有大神回覆,而且還是秒解!太神啦!

[python] 一階迴歸線製圖範例

今天朋友問我說怎麼用 Python 做出一階的趨勢線還有公式,解決之後覺得為了提醒自己,順便用網誌來備份一下 code,圖大概長這樣: code 如下: #-*-coding: utf-8-*- import numpy as np import matplotlib.pyplot as plt #from sklearn.metrics import r2_score #計算相關係數用,這裡沒有用到 dataX = np.arange(100) #產出 [0,1,2....99] dataY = np.random.randint(5,100, size=100) #產出 100 個 5~100 的隨機整數 def reg(x,y): coefficients = np.polyfit(x,y,1) # 利用 polyfit 幫我們算出資料 一階擬合的 a, b 參數 p = np.poly1d(coefficients) # 做出公式, print 的結果是 coefficients[0] * X + coefficients[1] #coefficient_of_dermination = r2_score(y, p(x)) // 計算相關係數用,這裡沒有用到 return coefficients, p (arg1, arg2), text1 = reg(dataX,dataY) #arg1, arg2 用來承接 coefficients[0], coefficients[1], text1 承接 p trend_line = dataX *arg1 + arg2 #做出趨勢線矩陣 plt.plot(dataX,dataY) #放上資料圖 plt.plot(trend_line) #放上趨勢線圖 plt.text(50, 10, text1, fontsize=14) #放上趨勢線公式 plt.show() #出圖

[python] python 常用套件

最近跑完 TCN 創客松後深感自己的不足,覺得不要再 Arduino 了,來重回 Python 的懷抱XD,複習了 Django 的書,順便列一下書裡面常見的套件,覺得之後會用到XD 網站框架 Django: 完整強大的 Web 框架 Pyramid: 強大 Web 框架2 web2py: Google app engine 預設框架 flask: 輕量 Web 框架,覺得有興趣。 圖片處理 PIL: 可對圖片進行縮放切割旋轉,圖片操作 Pillow: 因為 PIL 太久沒更新而出的 fork 版本,現在都用這個了 科學計算 Numpy: 神 Matplotlib: 出圖之神 pandas: 有點像 excel 的資料分析神 scikit-learn: 機器學習之神 命令列操作 fabric: 可以直接撰寫 shell 命令,透過 fabric 執行,也支持遠端登入和自定義 Shell  paramiko: 提供遠端登入和部分指定呼叫 測試 django-nose: Django 的測試套件 網路爬蟲 Scrapy: Python 爬蟲框架之一,可以輕易地和 Django 協作 文件叵析 beautifulsoup: 美麗的湯,處理 html, xml 文本分析一定要學的套件 lxml: 不太熟,但是聽說也很好用  自然語言處理 nltk: 理論基礎及功能強大的語言處理套件,但相對低階,上手困難 textblob: 較高階的分詞、分句語言分析工具 jieba: 中文分詞、分句、語言分析工具 網路請求用戶端 requests: 常用的網路請求工具,直觀好用 pycurl: 處理 linux, unix 系統上的命令 背景程序、定時任務 celery: 可以輕易編寫、呼叫非同步及背景程序,或是執行定時任務 資料庫介接 mysql-python: MySQL 的資料庫介接套件, Django 連接 MySQL 的預設 psycopg2: PostgreSQL 吃料庫介接套件 pymongo: MongoDB 的介接套件 自己常用的主要都在科學計算的部分,努力想要切入 scikit-learn 中 XD,但是又覺得網頁端 ...

[python] Pandas 簡易處理資料

主要用於一個大型的 DataFrame 怎麼把其中某個 Column 的值減去某個特定值,雖然直觀但是超好用的! 一定要記下來XD import pandas as pd ds = pd.DataFrame(np.arange(12).reshape(3,4), cols=['A','B','C','Average']) ds['A'] = ds['A'] - ds['Average'] ds['B'] = ds['B'] - ds['Average'] ds['C'] = ds['C'] - ds['Average'] #Pandas is easy like that! #Oh, that does it for the entire DF. You only want it for the firs row is that right? ds.loc[1, 'A'] = ds.loc[1, 'A'] - ds.loc[1, 'Average'] ds.loc[1, 'B'] = ds.loc[1, 'B'] - ds.loc[1, 'Average'] ds.loc[1, 'C'] = ds.loc[1, 'C'] - ds.loc[1, 'Average'] #or in a loop: for col in ['A', 'B', 'C']:     ds.loc[1, col] = df.loc[1, col] - ds.loc[1, 'Average'] #and so on... #if you have thousands of columns then simply do: for col in ds.columns:     ds[col] = ds[col] - ds[...

[Chat] 程式各種原則

有時候覺得程式撰寫的術語非常可愛,有 EAFP 原則 (It's Easier to Ask Forgiveness than Permission),也有LBYL原則 (Look Before You Leap), 光是要記住這些原則說不定又有個4P原則之類的。    我也應該要來創造個 "吃吃喝喝" 原則 : 1. 吃快弄破碗原則 2. 吃飯皇帝大原則 3. 喝酒不開車原則 4. 沒事多喝水原則 真的是蠻有趣的XD

[python] 安裝與啟動虛擬環境

看到了一篇 Make 的報導: 使用 Twilio 打造簡訊機器人,讓我非常的心動,畢竟 tutorial 都寫好了, code 也都傳便便,怎麼能不嘗試一下呢XD。 不過失敗了(默),因為 twilio 改版,變成還要花很多時間研究 twilio ,那就算了。 但是中間學到最多的大概就是怎麼建立並啟動虛擬環境,幫助很大又好用,一定要記錄一下。 建立虛擬環境的詳細資料可以參考這篇  https://goo.gl/pzzbvS #安裝啟動虛擬環境套件 $ pip install virtualenv $ cd test/path/ $ virtualenv test_env  #建立虛擬環境,名稱 test_env $ cd test_env $ Scripts\activate  # 一定要用反斜線才能成功啟動 $ deactivate  #離開虛擬環境 測試了以後,這些指令最輕鬆寫意啦~(在 windows 下最輕鬆寫意XD)