diff --git a/day1/01_streamlit_UI/app.py b/day1/01_streamlit_UI/app.py index dcfbe6fec..6c550aa05 100644 --- a/day1/01_streamlit_UI/app.py +++ b/day1/01_streamlit_UI/app.py @@ -6,198 +6,163 @@ # ============================================ # ページ設定 # ============================================ -# st.set_page_config( -# page_title="Streamlit デモ", -# layout="wide", -# initial_sidebar_state="expanded" -# ) +st.set_page_config( + page_title="Streamlit カスタムUIデモ", + layout="wide", + initial_sidebar_state="expanded", + menu_items={ + 'Get Help': None, + 'Report a bug': None, + 'About': 'Enhanced UI demo with custom CSS' + } +) # ============================================ -# タイトルと説明 +# カスタムCSS / テーマ # ============================================ -st.title("Streamlit 初心者向けデモ") -st.markdown("### コメントを解除しながらStreamlitの機能を学びましょう") -st.markdown("このデモコードでは、コメントアウトされた部分を順番に解除しながらUIの変化を確認できます。") +st.markdown(""" + +""", unsafe_allow_html=True) + +# ============================================ +# ヘッダー +# ============================================ +st.markdown('
コメントを解除しながらStreamlitの機能を学びましょう。
', unsafe_allow_html=True) # ============================================ # サイドバー # ============================================ st.sidebar.header("デモのガイド") -st.sidebar.info("コードのコメントを解除して、Streamlitのさまざまな機能を確認しましょう。") +st.sidebar.info( + "1. コメントを解除する\n" + "2. UIの変化を確認する\n" + "3. 自由にアレンジしよう!" +) # ============================================ -# 基本的なUI要素 +# 基本要素 in カード # ============================================ -st.header("基本的なUI要素") +st.markdown('これはカスタムCSSでスタイリングされたテキストです!
', unsafe_allow_html=True) - -# ============================================ -# デモの使用方法 +# フッター # ============================================ st.divider() -st.subheader("このデモの使い方") -st.markdown(""" -1. コードエディタでコメントアウトされた部分を見つけます(#で始まる行) -2. 確認したい機能のコメントを解除します(先頭の#を削除) -3. 変更を保存して、ブラウザで結果を確認します -4. 様々な組み合わせを試して、UIがどのように変化するか確認しましょう -""") - -st.code(""" -# コメントアウトされた例: -# if st.button("クリックしてください"): -# st.success("ボタンがクリックされました!") - -# コメントを解除した例: -if st.button("クリックしてください"): - st.success("ボタンがクリックされました!") -""") \ No newline at end of file +st.markdown('© 2025 Streamlit カスタムUIデモ
', unsafe_allow_html=True) diff --git "a/day5/\346\274\224\347\277\2222/.github/workflows/test.yml" "b/day5/\346\274\224\347\277\2222/.github/workflows/test.yml" new file mode 100644 index 000000000..e693b14bb --- /dev/null +++ "b/day5/\346\274\224\347\277\2222/.github/workflows/test.yml" @@ -0,0 +1,28 @@ +name: Run Tests + +on: + push: + branches: [ main, develop ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.10 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Run tests + run: | + pytest 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\2222/models/old_model.pkl" "b/day5/\346\274\224\347\277\2222/models/old_model.pkl" new file mode 100644 index 000000000..02a80d86e Binary files /dev/null and "b/day5/\346\274\224\347\277\2222/models/old_model.pkl" differ diff --git "a/day5/\346\274\224\347\277\2222/models/titanic_model.pkl" "b/day5/\346\274\224\347\277\2222/models/titanic_model.pkl" index 9e1859fdf..02a80d86e 100644 Binary files "a/day5/\346\274\224\347\277\2222/models/titanic_model.pkl" and "b/day5/\346\274\224\347\277\2222/models/titanic_model.pkl" differ diff --git "a/day5/\346\274\224\347\277\2222/test_model_perf.py" "b/day5/\346\274\224\347\277\2222/test_model_perf.py" new file mode 100644 index 000000000..cde41a8ba --- /dev/null +++ "b/day5/\346\274\224\347\277\2222/test_model_perf.py" @@ -0,0 +1,22 @@ +import os +import pytest +from main import DataLoader, ModelTester + +def test_model_accuracy_against_old_model(): + # 現在のモデルを評価 + data = DataLoader.load_titanic_data() + X, y = DataLoader.preprocess_titanic_data(data) + model = ModelTester.load_model("models/titanic_model.pkl") + metrics = ModelTester.evaluate_model(model, X, y) + current_accuracy = metrics["accuracy"] + + # ベースラインのモデルを評価(例: old_model.pkl) + old_model_path = "models/old_model.pkl" + if not os.path.exists(old_model_path): + pytest.skip("old_model.pkl が存在しません。スキップします。") + + old_model = ModelTester.load_model(old_model_path) + old_metrics = ModelTester.evaluate_model(old_model, X, y) + old_accuracy = old_metrics["accuracy"] + + assert current_accuracy >= old_accuracy, f"現モデルが旧モデルより劣化しています。({current_accuracy:.4f} < {old_accuracy:.4f})"