Spaces:
Runtime error
Runtime error
File size: 1,661 Bytes
3aea5d1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
import gradio as gr
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
def visualize_data(df):
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(20, 16))
# スクロール深度とクリック率の関係
sns.scatterplot(data=df, x='スクロール深度', y='クリック率', ax=ax1)
ax1.set_title('スクロール深度とクリック率の関係')
ax1.set_xlabel('スクロール深度')
ax1.set_ylabel('クリック率')
# クリック率の分布
sns.boxplot(data=df, y='クリック率', ax=ax2)
ax2.set_title('クリック率の分布')
# 離脱率の分布
sns.histplot(data=df, x='離脱率', kde=True, ax=ax3)
ax3.set_title('離脱率の分布')
# クリック数の分布
sns.histplot(data=df, x='クリック数', kde=True, ax=ax4)
ax4.set_title('クリック数の分布')
plt.tight_layout()
return fig
def process_input(file):
df = pd.read_csv(file.name)
visualization_plot = visualize_data(df)
# データの概要を文字列として取得
data_summary = df.describe().to_string()
return visualization_plot, data_summary
iface = gr.Interface(
fn=process_input,
inputs=[
gr.File(label="CSVファイルをアップロード")
],
outputs=[
gr.Plot(label="データ可視化"),
gr.Textbox(label="データ概要", lines=10)
],
title="リスティング広告LPデータの可視化",
description="CSVデータをアップロードして、データの可視化と概要を表示します。"
)
if __name__ == "__main__":
iface.launch() |