2020年11月22日 星期日

SQLite

 create table [table_name] (SN INTEGER PRIMARY KEY AUTOINCREMENT)

select * from sqlite_master

2020年10月29日 星期四

JS 筆記

parseInt("abc")            // 傳回NaN
parseInt("123abc")         // 傳回 123
parseInt("abc123")         // 傳回 NaN
parseInt("      123abc")   // 傳回 123

parseFloat("20");            //傳回20
parseFloat("30.00");         //傳回30
parseFloat("10.68");         //傳回10.68
parseFloat("12 22 32");      //傳回12
parseFloat("        80   "); //傳回80
parseFloat("378abc");        //傳回378
parseFloat("abc378");        //傳回NaN

Number(true);               //傳回1
Number(false);              //傳回0
Number(new Date());         //傳回1970/1/1到現在的毫秒數
Number("123");              //傳回123
Number("123 456");          //傳回NaN

2020年7月18日 星期六

背景執行 gunicorn

安裝
sudo pip install gunicorn

背景執行
sudo gunicorn -w 1 -b 0.0.0.0:80 run:app --daemon

結束
查PID
ps -ef | grep gunicorn

sudo kill -9 12705




2020年7月16日 星期四

2020年7月2日 星期四

資料前處理

from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler()
df["population_density"] = scaler.fit_transform(df["population_density"].values.reshape(-1, 1))

2020年6月20日 星期六

python df heatmap

heatmap = df[["city","class"]]
heatmap["cnt"] = 1
heatmap = heatmap.groupby(["city","class"]).sum().unstack().fillna(0)

2020年6月19日 星期五

sigmoid

def sigmoid(X):  # define activation: sigmoid
    output = 1 / (1 + np.exp(-X))
    return output

def sigmoid_gradient(X):
    output = sigmoid(X)*(1-sigmoid(X))
    return output

def softmax(X):  # define activation: softmax
    return np.exp(X) / np.sum(np.exp(X), axis=1, keepdims=True)

def cross_entropy(p, q):
    epsilon = 1e-15
    H = 0
    for i in range(len(p)):
        H += -p[i]*np.log(q[i]+epsilon)

    H = H.sum()/p.shape[0]
    return H


from tensorflow import keras
# 做 One-hot encoding
y = keras.utils.to_categorical(array)