Skip to content

Instantly share code, notes, and snippets.

@Keycatowo
Keycatowo / banned_ip_list.txt
Last active February 20, 2024 08:12
ip_blacklist(由 VPS 的 fail2ban 記錄1年輸出)
1.116.136.219
1.117.174.124
1.14.109.65
1.14.44.105
1.15.247.236
1.164.105.71
1.164.108.115
1.164.115.116
1.164.120.129
1.164.120.61
@Keycatowo
Keycatowo / streamlit-chat_element.py
Created September 9, 2023 07:54
本文介紹了Streamlit中的新組件st.chat_message和st.chat_input。
"""
Author: owo
Date: 2023/09/09
Post: https://blog.o-w-o.cc/archives/streamlit-chatelements
License: CC BY-NC-SA 4.0
"""
import streamlit as st
import numpy as np
MODE = st.sidebar.selectbox("選擇展示模式", ['chat_input用法', 'chat_message用法', '組合', '組合(含紀錄)'])
@Keycatowo
Keycatowo / DAC_HW1.py
Created March 5, 2023 00:38
DAC第一次作業
# -*- coding: utf-8 -*-
"""DAC HW1_劉弘祥
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1dwcMqxWb29IuwAxoX_6xn-ct64VHOLFD
# DAC-Python HW1
+ 時間:2023/03/01
@Keycatowo
Keycatowo / ChatGPT.json
Last active December 9, 2022 13:00
ChatGPT的POST Request格式
{
"model": "text-davinci-003",
"prompt": "{{1.events[].message.text}}",
"max_tokens": 100
}
@Keycatowo
Keycatowo / 2022-10-16DAC工作坊.py
Created October 16, 2022 00:26
去除Return的訂單、計算RFM
#%% 讀取資料
import pandas as pd
orders_df = pd.read_excel('Order1.xlsx')
orders_df.columns
#%% 合併訂單產品ID
orders_df["TradeProductID"] = orders_df["TradesID"] + orders_df["ProductID"]
#%% 篩選return
@Keycatowo
Keycatowo / show_python_env.py
Created June 30, 2022 12:38
檢視目前python解釋器的路徑和模組
import sys
print(sys.executable) # 顯示目前python解釋器的路徑
print(help("modules")) # 顯示所有目前的模組
@Keycatowo
Keycatowo / 簡體轉繁體.py
Created May 10, 2022 07:36
使用OpenCC用來轉換簡體繁體
# %%
from opencc import OpenCC
mode_config = {
"簡體->繁體":"s2t",
"簡體->繁體台灣":"s2tw",
"簡體->繁體台灣(含慣用詞)": "s2twp"
}
MODE = "簡體->繁體台灣(含慣用詞)"
FILE_INPUT = "data/input.txt"
@Keycatowo
Keycatowo / ffmpeg說明.md
Created April 15, 2022 09:07
ffmpeg簡單使用說明

說明

ffmpeg官網,這是一款用指令達成的影片工具

安裝

# ubuntu
sudo apt-get install ffmpeg

用指令剪輯影片

@Keycatowo
Keycatowo / [ML100-Day22]Feature Importance.py
Created March 3, 2022 09:49
查看特徵的重要程度(以RF為例)
from sklearn.ensemble import RandomForestClassifier
import matplotlib.pyplot as plt
feature_labels = list(train_X.columns) # 欄位名稱存下來等下顯示用
forest = RandomForestClassifier().fit(train_X, train_Y) # 送進模型fit
# 用`.feature_importances_`取得重要性
importances = forest.feature_importances_
# 取得對應的index,等下顯示用
indices = np.argsort(importances)[::-1]
@Keycatowo
Keycatowo / [ML100-Day07]column describe
Created February 4, 2022 08:39
pandas中對DataFrame進行統計之描述型方法
# 統計敘述(個別)
df.max()
df.mean()
df.count() # 回傳非nan數量
# 統計敘述(統合)
df.describe()
# 唯一值
df.apply(lambda x:x.unique(),axis=0) # uniques by columns