File size: 1,480 Bytes
768a4d5
 
 
 
 
 
 
 
 
 
60a00d7
faeb0e4
768a4d5
 
60a00d7
768a4d5
2814f62
768a4d5
 
 
2814f62
768a4d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# -*- coding: utf-8 -*-
"""app_gradio.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1hRynOROyrpbf0wKKcizHOXeZhx3Xo51M
"""

import numpy as np
import gradio

import pandas as pd



import plotly.express as px



taraf_s = pd.read_csv('FDSRashid/HadithML/taraf_by_year.csv')

taraf_s = taraf_s.sort_values(['City', 'Year'], ascending=True)

cities = taraf_s['City'].unique().tolist()
min_year = int(taraf_s['Year'].min())
max_year = int(taraf_s['Year'].max())



def plot_timeline(citi = ['المدينه', 'بغداد', 'كوفة', 'بصرة'], min_year = 0, max_year = 400):
  filtered = taraf_s[taraf_s['City'].isin(citi) & (taraf_s['Year'] >= min_year) & (taraf_s['Year'] <= max_year)]
  fig = px.line(data_frame = filtered, x = 'Year', y = 'Taraf', title = "Tarafs per Year", color = 'City' )
  fig.update_layout(title_font_color = 'red', title_x = .5)



  return fig

app = gradio.Interface(plot_timeline,
             [gradio.Dropdown(choices = cities, value = ['المدينه', 'بغداد', 'كوفة', 'بصرة'], multiselect=True),
                        gradio.Slider(min_year, max_year, value = 0, label = 'Begining', info = 'Choose the first year to display Tarafs'),
                        gradio.Slider(min_year, max_year, value = 400, label = 'End', info = 'Choose the last year to display Tarafs')

                        ],
                       gradio.Plot()).launch(share = True)