2017年11月7日 星期二

2017.11.7 小記




About 安安
  • 很需要人抱抱,常常因為肚子餓就哭(如果剛餵完大概是大便或尿尿,換尿布就好了),我又沒辦法親餵所以通通丟給沿莉處理。抱久了手關節疑似痠痛。
  • 換尿布越來越上手,頂多過程又噴地瓜味黃大便,洗衣機隨時保持待機狀態,如果急需使用附近還有洗衣店可以快速烘乾(6分鐘/10元)。
  • 尿布使用量驚人。
  • 下午時間洗澡,水溫38~39度。
  • 晚上一點~三點可能是我睡覺時間,清晨可以聽到安安肚子餓的哭聲,除非有急事不然就繼續睡到九點左右。買早餐吃,空擋換尿布把垃圾打包乾淨,煮開水補熱水瓶(溫度70度),讓掃地機器人工作,洗衣服。
  • 早上十一點跟下午五點拿月子餐,中間抓空擋吃午餐。有時候長輩會想來看安安,不過安安目前生理時鐘就是 two-state Markov process,兩個 states 就是睡覺跟吃奶,transition matrix 就是 [[0, 1], [1, 0]]。真的沒有可以請長輩幫忙的,定時清貓砂換水倒飼料?把貓砂盆清洗乾淨換新砂?倒垃圾掃地拖地?這些還是我自己來就好了。如果真的說有要幫忙,大概就是白花花的錢吧(逃)。


About Stanford University CS231n (Spring 2017)

2017年10月25日 星期三

蔡安安的前一天(2017.10.15)


先紀錄前一天(2017.10.15)發生什麼事。


2017.10.15

這週五(2017.10.13)到台大醫院產檢,李建南醫生建議沿莉可以做蹲地板擦地的動作幫助生產,如果寶寶太大隻會不好生。這週末沿莉就做這些動作,然後星期天凌晨半睡半醒之際沿莉就破水了,床單濕濕的,有點慌張稍微收拾一下。沿莉聯絡弟弟媽媽交代一些事項。

直接去台大兒童醫院 9F 準備生產。


破水沒有陣痛,護理師告訴我們要在 24小時內生產,不然可能有感染問題(即使感染也不會很難處理?總之醫學就是暗黑科技),我們必須跟時間賽跑,讓陣痛趕上破水的速度。


台大醫院是台灣最好的醫院之一,規模很大,辦理住院手續還得跑去 1F 再回到 9F,中間空擋時間有點擔心北鼻狀況,希望櫃檯人員手腳快一點但又不敢真的催他。我就是醫學外行人,明明就沒開指還在那邊瞎操心。


單人房的時間很漫長,窗戶很大可以看見遠方的總統府,躺在椅子上也不知道可以做什麼,大概就是陪沿莉開指,我以為開指是一個線性過程,但其實是 exponential 拉尾速的成長,聽說一開始只有半指,肚子上有兩個監測小圓盤,只要掉出容許範圍機器就會亂叫一通,剛開始很焦慮,後來護理師教我們怎麼關靜音,最後就是裝死沒聽到,只要不要持續一直覺就好了,雖說如此還是有些焦慮。那天晚上偷溜出去,跑去師大買包子、樂高磚塊放鬆一下心情,在醫院裡面聽到隔壁的哀號聲還是挺緊繃的。

平常在待產房就是上尿盆接尿,把尿倒進去馬桶沖乾淨,再用水把尿盆洗乾淨,底部黏到血的部分就用手推掉,雖然是尿盆還是要弄乾淨一點。產褥墊幾個小時就有很多血需要定期更換,血的味道有點奇妙,垃圾桶有濃濃的血味道。


晚上九點沿莉有點難熬,希望麻醉師打無痛,我又被叫出去簽奇怪的切結書,無痛可能也有副作用,家屬的責任就是簽名。晚上十點多麻醉師終於來了,意外的道具沒有很多,但手續意外的複雜,小心翼翼地幫沿莉背部酒精消毒,接著是帥氣的丟掉棉花棒,然後用針用管子整個很精細又大膽,最後護理師用一長條紙膠帶固定細細的麻醉汁輸送管,沿莉總算比較舒服,只要痛就可以按小按鈕輸入麻醉汁(小精靈),沿莉就會很開心,但我還是很擔心切結書裡面寫的東西。


監控器亂叫,護理師進進出出,沒什麼事的我也不太好睡。

2017年9月24日 星期日

[Python] mlxtend


mlxtend: http://rasbt.github.io/mlxtend/

StackingCVRegressor: http://rasbt.github.io/mlxtend/user_guide/regressor/StackingCVRegressor/



Example (Improvement of https://www.kaggle.com/serigne/stacked-regressions-top-4-on-leaderboard):


1. Add new feature: Age of the house
  • all_data['HouseAge'] = 2012 - all_data['YearBuilt']
  • all_data['HouseAge'] = 2011 - all_data['YearBuilt']

According to the age of this paper: https://ww2.amstat.org/publications/jse/v19n3/decock.pdf, we choose 2011 (or 2012) as the base year.


2. Replace the implementation of StackingAveragedModels
  • from mlxtend.regressor import StackingCVRegressor
  • stacking_regressor = StackingCVRegressor(regressors=(ENet, GBoost, KRR), meta_regressor=lasso)

Results: 0.11300



2017年9月6日 星期三

[Python] Install lightgbm in MacOS

If you cannot pip install lightgbm, try this:
https://github.com/Microsoft/LightGBM/wiki/Installation-Guide

If you cannot cmake .. to build lightgbm, try this: brew install gcc@7


[Python] Install xgboost in MacOS

By executing pip install xgboost in MacOS, we may get the following error message:
List of candidates:
/private/var/folders/.../xgboost/libxgboost.so /private/var/folders/.../xgboost/../../lib/libxgboost.so /private/var/folders/.../xgboost/./lib/libxgboost.so
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/.../

2017年9月3日 星期日

[Kaggle] House Prices: Advanced Regression Techniques


Problem: https://www.kaggle.com/c/house-prices-advanced-regression-techniques/leaderboard

參考 https://www.kaggle.com/apapiu/regularized-linear-models,現在算是模仿階段,所以盡量參考別人做法,接下來才有機會談創新,巨人肩膀好用。

Hyperparameters 改良為: preds = 0.85 * lasso_preds + 0.15 * xgb_preds,分數有進步 (0.12086 -> 0.12049),但名次還是很差。




https://www.kaggle.com/serigne/stacked-regressions-top-4-on-leaderboard


改善計畫:

# 移除 outliers: (仔細看題目給的文件)

There are 5 observations that an instructor may wish to remove from the data set before giving it to students (a plot of SALE PRICE versus GR LIV AREA will indicate them quickly). Three of them are true outliers (Partial Sales that likely don’t represent actual market values) and two of them are simply unusual sales (very large houses priced relatively appropriately). I would recommend removing any houses with more than 4000 square feet from the data set (which eliminates these 5 unusual observations) before assigning it to students.

不過文件也說:

A second issue closely related to the intended use of the model, is the handling of outliers and unusual observations. In general, I instruct my students to never throw away data points simply because they do not match a priori expectations (or other data points). I strongly make this point in the situation where data are being analyzed for research purposes that will be shared with a larger audience. Alternatively, if the purpose is to once again create a common use model to estimate a “typical” sale, it is in the modeler’s best interest to remove any observations that do not seem typical (such as foreclosures or family sales).

有點兩難,https://www.kaggle.com/humananalog/xgboost-lasso/code 做法是把所有 GrLivArea > 4000 的濾掉,然後調整 y_pred = 0.4 * y_pred_xgb + 0.6 * y_pred_lasso,分數大有進步,下面仔細研究怎麼做 feature engineering。



# Feature Engineering


然後在另外一台電腦重跑程式,分數會變爛(0.11481)。

# Imputation

# Stacked Regression