ghtmarco commited on
Commit
1cb5bbf
·
verified ·
1 Parent(s): 77ed324

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -56
app.py DELETED
@@ -1,56 +0,0 @@
1
- import pandas as pd
2
- import joblib
3
- import gradio as gr
4
- from datetime import datetime, timedelta
5
-
6
- # Load model
7
- model = joblib.load('random_forest_model.pkl')
8
-
9
- def predict_task_duration(task_name, duration, deadline):
10
- try:
11
- start_date = datetime(2024, 10, 20)
12
- deadline_date = datetime.strptime(deadline, '%Y-%m-%d')
13
- deadline_days = (deadline_date - start_date).days
14
-
15
- input_data = pd.DataFrame({
16
- 'duration': [duration],
17
- 'deadline_days': [deadline_days]
18
- })
19
-
20
- priority = model.predict(input_data)
21
- priority_map = {
22
- 1: "Rendah",
23
- 2: "Sedang",
24
- 3: "Tinggi"
25
- }
26
-
27
- result = priority_map.get(priority[0], "Tidak diketahui")
28
- return f'Prioritas Tugas: {result}'
29
-
30
- except Exception as e:
31
- return f"Error: {str(e)}"
32
-
33
- # Membuat interface Gradio
34
- iface = gr.Interface(
35
- fn=predict_task_duration,
36
- inputs=[
37
- gr.Dropdown(
38
- choices=["Meeting", "Bekerja", "Belajar"],
39
- label="Nama Tugas"
40
- ),
41
- gr.Slider(
42
- minimum=1,
43
- maximum=10,
44
- value=5,
45
- step=0.1,
46
- label="Durasi Tugas (dalam jam)"
47
- ),
48
- gr.Date(label="Deadline") # Menambahkan input deadline
49
- ],
50
- outputs=gr.Text(label="Hasil Prediksi"),
51
- title="Sistem Prediksi Prioritas Tugas",
52
- description="Masukkan nama tugas, durasi, dan deadline untuk memprediksi prioritasnya"
53
- )
54
-
55
- # Launch the interface
56
- iface.launch()