Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
# 支援が必要な児童生徒を抽出する関数
|
| 5 |
+
def extract_support_needed(file):
|
| 6 |
+
df = pd.read_csv(file.name)
|
| 7 |
+
support_needed = df[df['attendance_rate'] < 80]
|
| 8 |
+
|
| 9 |
+
def suggest_support(row):
|
| 10 |
+
if row['attendance_rate'] < 45:
|
| 11 |
+
return '個別指導が必要'
|
| 12 |
+
elif row['attendance_rate'] < 55:
|
| 13 |
+
return 'カウンセリングを提案'
|
| 14 |
+
else:
|
| 15 |
+
return '支援不要'
|
| 16 |
+
|
| 17 |
+
support_needed['support_suggestion'] = support_needed.apply(suggest_support, axis=1)
|
| 18 |
+
return support_needed[['student_id', 'attendance_rate', 'support_suggestion']]
|
| 19 |
+
|
| 20 |
+
# Gradioインターフェースの作成
|
| 21 |
+
interface = gr.Interface(
|
| 22 |
+
fn=extract_support_needed,
|
| 23 |
+
inputs=gr.File(label="スクリーニングシート(CSVファイル)をアップロード"),
|
| 24 |
+
outputs=gr.Dataframe(label="支援が必要な児童生徒")
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
# インターフェースの起動
|
| 28 |
+
interface.launch()
|