From c39980e86ff57adfcfb5ef7d14332221917f90ff Mon Sep 17 00:00:00 2001 From: koro91187 Date: Tue, 29 Apr 2025 08:49:36 +0000 Subject: [PATCH 1/9] =?UTF-8?q?Update:=20app.py=20UI=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- day1/01_streamlit_UI/app.py | 80 ++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 40 deletions(-) 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("ファイルアップロード") From 5c7146e2260be5983b0871eebbe3909d6fb3ff90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B2=A9=E4=BD=90=E6=B2=99=E5=BC=A5?= Date: Wed, 21 May 2025 14:00:59 +0900 Subject: [PATCH 2/9] Add new feature or fix something --- .../\346\274\224\347\277\2222/black_check.py" | 21 ++++++++++++++----- "day5/\346\274\224\347\277\2222/main.py" | 1 + 2 files changed, 17 insertions(+), 5 deletions(-) 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: """データロードを行うクラス""" From 614adc6f7870feea05c1a8adbe4fb57831347ff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B2=A9=E4=BD=90=E6=B2=99=E5=BC=A5?= Date: Wed, 21 May 2025 14:36:10 +0900 Subject: [PATCH 3/9] Add minimal GitHub Actions workflow for pytest --- "day5/\346\274\224\347\277\2222/.github/workflows/ci.yml" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "day5/\346\274\224\347\277\2222/.github/workflows/ci.yml" 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 From f591af7528d3deb89fc66251d641ec3b3a6896f7 Mon Sep 17 00:00:00 2001 From: koro91187 Date: Wed, 21 May 2025 16:29:01 +0900 Subject: [PATCH 4/9] Update test_model.py --- .../\346\274\224\347\277\2223/tests/test_model.py" | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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..3130d8515 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" @@ -101,6 +101,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(): """モデルファイルが存在するか確認""" From 86cd8568e0668135f72f2d9bacf77144f2d695f5 Mon Sep 17 00:00:00 2001 From: koro91187 Date: Wed, 21 May 2025 16:43:46 +0900 Subject: [PATCH 5/9] Update test_model.py --- "day5/\346\274\224\347\277\2223/tests/test_model.py" | 2 ++ 1 file changed, 2 insertions(+) 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 3130d8515..94ae727c2 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" @@ -12,6 +12,8 @@ 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") From 3e2d419944d2776ceb857ca25efa75bc72355709 Mon Sep 17 00:00:00 2001 From: koro91187 Date: Wed, 21 May 2025 16:49:48 +0900 Subject: [PATCH 6/9] Update test_model.py --- "day5/\346\274\224\347\277\2223/tests/test_model.py" | 1 + 1 file changed, 1 insertion(+) 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 94ae727c2..9e1ad01d7 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" @@ -14,6 +14,7 @@ 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") From 203934b5e649a0ac5b00f0d7fc811d9456edd966 Mon Sep 17 00:00:00 2001 From: koro91187 Date: Wed, 21 May 2025 16:53:40 +0900 Subject: [PATCH 7/9] Update test_model.py --- "day5/\346\274\224\347\277\2223/tests/test_model.py" | 1 + 1 file changed, 1 insertion(+) 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 9e1ad01d7..73bc72b4f 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,6 +3,7 @@ import pandas as pd import numpy as np import pickle +import pathlib import time from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_split From ab8b0e961fc705544465f0e228f4a9541406a403 Mon Sep 17 00:00:00 2001 From: koro91187 Date: Wed, 21 May 2025 16:55:35 +0900 Subject: [PATCH 8/9] Update test_model.py --- "day5/\346\274\224\347\277\2223/tests/test_model.py" | 1 + 1 file changed, 1 insertion(+) 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 73bc72b4f..03e341166 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" @@ -5,6 +5,7 @@ import pickle import pathlib import time +import json from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score From 05f526186c4581aa46b3d06d02003677079ce324 Mon Sep 17 00:00:00 2001 From: koro91187 Date: Wed, 21 May 2025 16:57:33 +0900 Subject: [PATCH 9/9] Update test_model.py --- "day5/\346\274\224\347\277\2223/tests/test_model.py" | 1 + 1 file changed, 1 insertion(+) 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 03e341166..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" @@ -4,6 +4,7 @@ import numpy as np import pickle import pathlib +from datetime import datetime import time import json from sklearn.ensemble import RandomForestClassifier