diff --git a/day1/01_streamlit_UI/app.py b/day1/01_streamlit_UI/app.py index dcfbe6fec..2f49c97c9 100644 --- a/day1/01_streamlit_UI/app.py +++ b/day1/01_streamlit_UI/app.py @@ -15,7 +15,7 @@ # ============================================ # タイトルと説明 # ============================================ -st.title("Streamlit 初心者向けデモ") +st.title("Streamlit 改良版") st.markdown("### コメントを解除しながらStreamlitの機能を学びましょう") st.markdown("このデモコードでは、コメントアウトされた部分を順番に解除しながらUIの変化を確認できます。") @@ -36,27 +36,27 @@ st.write(f"こんにちは、{name}さん!") # ボタン -# st.subheader("ボタン") -# if st.button("クリックしてください"): -# st.success("ボタンがクリックされました!") +st.subheader("ボタン") +if st.button("クリックしてください"): + st.success("ボタンがクリックされました!") # チェックボックス -# st.subheader("チェックボックス") -# if st.checkbox("チェックを入れると追加コンテンツが表示されます"): -# st.info("これは隠れたコンテンツです!") +st.subheader("チェックボックス") +if st.checkbox("チェックを入れると追加コンテンツが表示されます"): + st.info("これは隠れたコンテンツです!") # スライダー -# st.subheader("スライダー") -# age = st.slider("年齢", 0, 100, 25) -# st.write(f"あなたの年齢: {age}") +st.subheader("スライダー") +age = st.slider("年齢", 0, 100, 25) +st.write(f"あなたの年齢: {age}") # セレクトボックス -# st.subheader("セレクトボックス") -# option = st.selectbox( -# "好きなプログラミング言語は?", -# ["Python", "JavaScript", "Java", "C++", "Go", "Rust"] -# ) -# st.write(f"あなたは{option}を選びました") +st.subheader("セレクトボックス") +option = st.selectbox( + "好きなプログラミング言語は?", + ["Python", "JavaScript", "Java", "C++", "Go", "Rust"] + ) +st.write(f"あなたは{option}を選びました") # ============================================ # レイアウト @@ -90,22 +90,22 @@ # ============================================ # データ表示 # ============================================ -# st.header("データの表示") +st.header("データの表示") # サンプルデータフレームを作成 -# df = pd.DataFrame({ -# '名前': ['田中', '鈴木', '佐藤', '高橋', '伊藤'], -# '年齢': [25, 30, 22, 28, 33], -# '都市': ['東京', '大阪', '福岡', '札幌', '名古屋'] -# }) +df = pd.DataFrame({ + '名前': ['田中', '鈴木', '佐藤', '高橋', '伊藤'], + '年齢': [25, 30, 22, 28, 33], + '都市': ['東京', '大阪', '福岡', '札幌', '名古屋'] + }) # データフレーム表示 -# st.subheader("データフレーム") -# st.dataframe(df, use_container_width=True) +st.subheader("データフレーム") +st.dataframe(df, use_container_width=True) # テーブル表示 -# st.subheader("テーブル") -# st.table(df) +st.subheader("テーブル") +st.table(df) # メトリクス表示 # st.subheader("メトリクス") @@ -117,14 +117,14 @@ # ============================================ # グラフ表示 # ============================================ -# st.header("グラフの表示") +st.header("グラフの表示") # ラインチャート -# st.subheader("ラインチャート") -# chart_data = pd.DataFrame( -# np.random.randn(20, 3), -# columns=['A', 'B', 'C']) -# st.line_chart(chart_data) +st.subheader("ラインチャート") +chart_data = pd.DataFrame( + np.random.randn(20, 3), + columns=['A', 'B', 'C']) +st.line_chart(chart_data) # バーチャート # st.subheader("バーチャート") @@ -139,14 +139,14 @@ # ============================================ # st.header("インタラクティブ機能") -# プログレスバー -# st.subheader("プログレスバー") -# progress = st.progress(0) -# if st.button("進捗をシミュレート"): -# for i in range(101): -# time.sleep(0.01) -# progress.progress(i / 100) -# st.balloons() +# プログレスバー +st.subheader("プログレスバー") +progress = st.progress(0) +if st.button("進捗をシミュレート"): + for i in range(101): + time.sleep(0.01) + progress.progress(i / 100) + st.balloons() # ファイルアップロード # st.subheader("ファイルアップロード") diff --git "a/day5/\346\274\224\347\277\2222/.github/workflows/ci.yml" "b/day5/\346\274\224\347\277\2222/.github/workflows/ci.yml" new file mode 100644 index 000000000..e69de29bb diff --git "a/day5/\346\274\224\347\277\2222/black_check.py" "b/day5/\346\274\224\347\277\2222/black_check.py" index 3158f952d..910a40c3a 100644 --- "a/day5/\346\274\224\347\277\2222/black_check.py" +++ "b/day5/\346\274\224\347\277\2222/black_check.py" @@ -1,7 +1,18 @@ +def say_hello(name): + print("Hello," + name + "!") # greet + + +def say_hello(name): + print("Hello," + name + "!") # greet + + +def add(a, b): + return a + b + + +def add(a, b): + return a + b + -def say_hello(name):print("Hello,"+name+"!") # greet -def say_hello(name):print("Hello," + name +"!") # greet -def add( a,b):return a+b -def add( a , b ):return a+b def add(a, b): - return a+b \ No newline at end of file + return a + b diff --git "a/day5/\346\274\224\347\277\2222/main.py" "b/day5/\346\274\224\347\277\2222/main.py" index 776b70e75..2b256b6c5 100644 --- "a/day5/\346\274\224\347\277\2222/main.py" +++ "b/day5/\346\274\224\347\277\2222/main.py" @@ -11,6 +11,7 @@ import time import great_expectations as gx + class DataLoader: """データロードを行うクラス""" diff --git "a/day5/\346\274\224\347\277\2223/tests/test_model.py" "b/day5/\346\274\224\347\277\2223/tests/test_model.py" index e11a19a5c..66b94b9de 100644 --- "a/day5/\346\274\224\347\277\2223/tests/test_model.py" +++ "b/day5/\346\274\224\347\277\2223/tests/test_model.py" @@ -3,7 +3,10 @@ import pandas as pd import numpy as np import pickle +import pathlib +from datetime import datetime import time +import json from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score @@ -12,6 +15,9 @@ from sklearn.compose import ColumnTransformer from sklearn.pipeline import Pipeline +BASELINE_PATH = pathlib.Path(__file__).resolve().parents[1] / "baseline.json" + + # テスト用データとモデルパスを定義 DATA_PATH = os.path.join(os.path.dirname(__file__), "../data/Titanic.csv") MODEL_DIR = os.path.join(os.path.dirname(__file__), "../models") @@ -101,6 +107,19 @@ def train_model(sample_data, preprocessor): return model, X_test, y_test +def _load_baseline() -> float | None: + """baseline.json から accuracy を読む(無ければ None)""" + if BASELINE_PATH.exists(): + data = json.loads(BASELINE_PATH.read_text()) + return data.get("accuracy") + return None + +def _save_baseline(new_acc: float): + """精度が向上したとき baseline.json を更新""" + BASELINE_PATH.write_text(json.dumps( + {"accuracy": new_acc, "updated": datetime.utcnow().isoformat()}, + indent=2 + )) def test_model_exists(): """モデルファイルが存在するか確認"""