From 3343f65e675dd6d14ae0a8b8959a0c000a8a3945 Mon Sep 17 00:00:00 2001 From: ayako0520 Date: Tue, 29 Apr 2025 21:35:44 +0900 Subject: [PATCH 1/6] =?UTF-8?q?day1=20=20=E6=BC=94=E7=BF=92=E3=81=A8?= =?UTF-8?q?=E3=81=97=E3=81=A6app.py=E3=81=AEUI=E3=82=92=E6=9C=89=E5=8A=B9?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- day1/01_streamlit_UI/app.py | 200 ++++++++++++++++++------------------ 1 file changed, 100 insertions(+), 100 deletions(-) diff --git a/day1/01_streamlit_UI/app.py b/day1/01_streamlit_UI/app.py index dcfbe6fec..3d39d7c22 100644 --- a/day1/01_streamlit_UI/app.py +++ b/day1/01_streamlit_UI/app.py @@ -3,14 +3,14 @@ import numpy as np import time -# ============================================ -# ページ設定 -# ============================================ -# st.set_page_config( -# page_title="Streamlit デモ", -# layout="wide", -# initial_sidebar_state="expanded" -# ) + #============================================ + #ページ設定 + #============================================ +st.set_page_config( + page_title="Streamlit デモ", + layout="wide", + initial_sidebar_state="expanded" +) # ============================================ # タイトルと説明 @@ -36,149 +36,149 @@ 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}を選びました") # ============================================ # レイアウト # ============================================ -# st.header("レイアウト") +st.header("レイアウト") # カラム -# st.subheader("カラムレイアウト") -# col1, col2 = st.columns(2) -# with col1: -# st.write("これは左カラムです") -# st.number_input("数値を入力", value=10) -# with col2: -# st.write("これは右カラムです") -# st.metric("メトリクス", "42", "2%") +st.subheader("カラムレイアウト") +col1, col2 = st.columns(2) +with col1: + st.write("これは左カラムです") + st.number_input("数値を入力", value=10) +with col2: + st.write("これは右カラムです") + st.metric("メトリクス", "42", "2%") # タブ -# st.subheader("タブ") -# tab1, tab2 = st.tabs(["第1タブ", "第2タブ"]) -# with tab1: -# st.write("これは第1タブの内容です") -# with tab2: -# st.write("これは第2タブの内容です") +st.subheader("タブ") +tab1, tab2 = st.tabs(["第1タブ", "第2タブ"]) +with tab1: + st.write("これは第1タブの内容です") +with tab2: + st.write("これは第2タブの内容です") # エクスパンダー -# st.subheader("エクスパンダー") -# with st.expander("詳細を表示"): -# st.write("これはエクスパンダー内の隠れたコンテンツです") -# st.code("print('Hello, Streamlit!')") +st.subheader("エクスパンダー") +with st.expander("詳細を表示"): + st.write("これはエクスパンダー内の隠れたコンテンツです") + st.code("print('Hello, Streamlit!')") # ============================================ # データ表示 # ============================================ -# 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("メトリクス") -# col1, col2, col3 = st.columns(3) -# col1.metric("温度", "23°C", "1.5°C") -# col2.metric("湿度", "45%", "-5%") -# col3.metric("気圧", "1013hPa", "0.1hPa") +st.subheader("メトリクス") +col1, col2, col3 = st.columns(3) +col1.metric("温度", "23°C", "1.5°C") +col2.metric("湿度", "45%", "-5%") +col3.metric("気圧", "1013hPa", "0.1hPa") # ============================================ # グラフ表示 # ============================================ -# 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("バーチャート") -# chart_data = pd.DataFrame({ -# 'カテゴリ': ['A', 'B', 'C', 'D'], -# '値': [10, 25, 15, 30] -# }).set_index('カテゴリ') -# st.bar_chart(chart_data) +st.subheader("バーチャート") +chart_data = pd.DataFrame({ + 'カテゴリ': ['A', 'B', 'C', 'D'], + '値': [10, 25, 15, 30] +}).set_index('カテゴリ') +st.bar_chart(chart_data) # ============================================ # インタラクティブ機能 # ============================================ -# st.header("インタラクティブ機能") +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("ファイルアップロード") -# uploaded_file = st.file_uploader("ファイルをアップロード", type=["csv", "txt"]) -# if uploaded_file is not None: -# # ファイルのデータを表示 -# bytes_data = uploaded_file.getvalue() -# st.write(f"ファイルサイズ: {len(bytes_data)} bytes") -# -# # CSVの場合はデータフレームとして読み込む -# if uploaded_file.name.endswith('.csv'): -# df = pd.read_csv(uploaded_file) -# st.write("CSVデータのプレビュー:") -# st.dataframe(df.head()) +st.subheader("ファイルアップロード") +uploaded_file = st.file_uploader("ファイルをアップロード", type=["csv", "txt"]) +if uploaded_file is not None: + # ファイルのデータを表示 + bytes_data = uploaded_file.getvalue() + st.write(f"ファイルサイズ: {len(bytes_data)} bytes") + + # CSVの場合はデータフレームとして読み込む + if uploaded_file.name.endswith('.csv'): + df = pd.read_csv(uploaded_file) + st.write("CSVデータのプレビュー:") + st.dataframe(df.head()) # ============================================ # カスタマイズ # ============================================ -# st.header("スタイルのカスタマイズ") +st.header("スタイルのカスタマイズ") # カスタムCSS -# st.markdown(""" -# -# """, unsafe_allow_html=True) +st.markdown(""" + +""", unsafe_allow_html=True) # -# st.markdown('

これはカスタムCSSでスタイリングされたテキストです!

', unsafe_allow_html=True) +st.markdown('

これはカスタムCSSでスタイリングされたテキストです!

', unsafe_allow_html=True) # ============================================ # デモの使用方法 From ae19824391b00ba68ce7f49f7d06e4cfe77d1358 Mon Sep 17 00:00:00 2001 From: ayako0520 Date: Wed, 30 Apr 2025 13:12:21 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=E3=83=A2=E3=83=87=E3=83=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- day1/02_streamlit_app/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/day1/02_streamlit_app/config.py b/day1/02_streamlit_app/config.py index 4b6954949..6e3fd9512 100644 --- a/day1/02_streamlit_app/config.py +++ b/day1/02_streamlit_app/config.py @@ -1,3 +1,3 @@ # config.py DB_FILE = "chat_feedback.db" -MODEL_NAME = "google/gemma-2-2b-jpn-it" \ No newline at end of file +MODEL_NAME = "rinna/japanease-gpt-neox-3.6b" \ No newline at end of file From 97e6548567ddef59814b36dc8563f58469a3a77c Mon Sep 17 00:00:00 2001 From: ayako0520 Date: Wed, 21 May 2025 12:59:53 +0900 Subject: [PATCH 3/6] Add CI trigger comment to day5 README --- day5/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/day5/README.md b/day5/README.md index 39b52a201..cbe887d69 100644 --- a/day5/README.md +++ b/day5/README.md @@ -1,4 +1,5 @@ -# day5 演習用ディレクトリ +# day5 演習用ディレクトリ 2 +# ちょっと変更 第3回「MLOps」に関する演習用のディレクトリです。 From 98c1888e0c70e5c917a1c1d61562f7664d2cebe2 Mon Sep 17 00:00:00 2001 From: ayako0520 Date: Wed, 21 May 2025 16:49:42 +0900 Subject: [PATCH 4/6] Add dummy line for CI PR trigger --- day5/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/day5/README.md b/day5/README.md index cbe887d69..ac7183bd1 100644 --- a/day5/README.md +++ b/day5/README.md @@ -1,5 +1,5 @@ # day5 演習用ディレクトリ 2 -# ちょっと変更 +# ちょっと変更(CI動作確認用) 第3回「MLOps」に関する演習用のディレクトリです。 From 4774106543516bf84b0c27bfcb28c377a663f5e3 Mon Sep 17 00:00:00 2001 From: ayako0520 Date: Wed, 21 May 2025 17:26:04 +0900 Subject: [PATCH 5/6] Add test for high accuracy threshold (>= 0.80) --- "day5/\346\274\224\347\277\2223/tests/test_model.py" | 9 +++++++++ 1 file changed, 9 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..3795a0116 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" @@ -120,6 +120,15 @@ def test_model_accuracy(train_model): # Titanicデータセットでは0.75以上の精度が一般的に良いとされる assert accuracy >= 0.75, f"モデルの精度が低すぎます: {accuracy}" +def test_model_high_accuracy(train_model): + """モデルの精度が0.80以上と高い水準にあるかを確認""" + model, X_test, y_test = train_model + + y_pred = model.predict(X_test) + accuracy = accuracy_score(y_test, y_pred) + + assert accuracy >= 0.80, f"精度がやや低いです: {accuracy:.3f} < 0.80" + def test_model_inference_time(train_model): """モデルの推論時間を検証""" From f6c16959f478338a5a82c5c89abfe59f622b2d70 Mon Sep 17 00:00:00 2001 From: ayako0520 Date: Wed, 21 May 2025 17:41:36 +0900 Subject: [PATCH 6/6] Fix code format to pass black check --- "day5/\346\274\224\347\277\2223/tests/test_model.py" | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 3795a0116..cb7d5c6e8 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" @@ -120,6 +120,7 @@ def test_model_accuracy(train_model): # Titanicデータセットでは0.75以上の精度が一般的に良いとされる assert accuracy >= 0.75, f"モデルの精度が低すぎます: {accuracy}" + def test_model_high_accuracy(train_model): """モデルの精度が0.80以上と高い水準にあるかを確認""" model, X_test, y_test = train_model @@ -127,7 +128,7 @@ def test_model_high_accuracy(train_model): y_pred = model.predict(X_test) accuracy = accuracy_score(y_test, y_pred) - assert accuracy >= 0.80, f"精度がやや低いです: {accuracy:.3f} < 0.80" + assert accuracy >= 0.80, f"精度がやや低いです: {accuracy:.3f} < 0.80" def test_model_inference_time(train_model):