ghtmarco commited on
Commit
16174fd
·
verified ·
1 Parent(s): 1cb5bbf

Upload 4 files

Browse files
Files changed (4) hide show
  1. app.py +81 -0
  2. random_forest_model.pkl +3 -0
  3. requirements.txt +7 -0
  4. scaler.pkl +3 -0
app.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import numpy as np
3
+ import gradio as gr
4
+ import joblib
5
+ from datetime import datetime, timedelta
6
+
7
+ # Load model dan scaler
8
+ model = joblib.load('random_forest_model.pkl')
9
+ scaler = joblib.load('scaler.pkl')
10
+
11
+ def predict_task_priority(task_name, duration, deadline_date):
12
+ try:
13
+ # Hitung deadline_days
14
+ start_date = datetime.now()
15
+ deadline = datetime.strptime(deadline_date, '%Y-%m-%d')
16
+ deadline_days = (deadline - start_date).days
17
+
18
+ # Transform input
19
+ input_data = np.array([[duration, deadline_days]])
20
+ input_scaled = scaler.transform(input_data)
21
+
22
+ # Predict
23
+ priority = model.predict(input_scaled)[0]
24
+
25
+ priority_map = {
26
+ 1: "Rendah",
27
+ 2: "Sedang",
28
+ 3: "Tinggi"
29
+ }
30
+
31
+ # Generate detailed response
32
+ response = f"Analisis Tugas: {task_name}\n"
33
+ response += f"Durasi: {duration} jam\n"
34
+ response += f"Deadline: {deadline_days} hari lagi\n"
35
+ response += f"Prioritas: {priority_map[priority]}\n\n"
36
+
37
+ # Add recommendations
38
+ if priority == 3:
39
+ response += "Rekomendasi: Kerjakan segera! Deadline dekat dan membutuhkan waktu lama."
40
+ elif priority == 2:
41
+ response += "Rekomendasi: Buatlah jadwal yang tepat dan mulai kerjakan secara bertahap."
42
+ else:
43
+ response += "Rekomendasi: Dapat dikerjakan dengan lebih santai, tapi tetap pantau progress."
44
+
45
+ return response
46
+
47
+ except Exception as e:
48
+ return f"Error: {str(e)}"
49
+
50
+ # Create Gradio interface
51
+ iface = gr.Interface(
52
+ fn=predict_task_priority,
53
+ inputs=[
54
+ gr.Dropdown(
55
+ choices=["Meeting", "Bekerja", "Belajar", "Tugas Kuliah", "Proyek"],
56
+ label="Nama Tugas"
57
+ ),
58
+ gr.Slider(
59
+ minimum=1,
60
+ maximum=10,
61
+ value=5,
62
+ step=0.5,
63
+ label="Durasi Tugas (dalam jam)"
64
+ ),
65
+ gr.Date(
66
+ label="Deadline",
67
+ info="Pilih tanggal deadline tugas"
68
+ )
69
+ ],
70
+ outputs=gr.Textbox(label="Hasil Analisis", lines=6),
71
+ title="Sistem Prioritas Tugas",
72
+ description="""
73
+ Sistem ini akan membantu Anda menentukan prioritas tugas berdasarkan:
74
+ 1. Durasi pengerjaan tugas
75
+ 2. Jarak waktu ke deadline
76
+
77
+ Hasil analisis akan memberikan rekomendasi pengelolaan waktu yang sesuai.
78
+ """
79
+ )
80
+
81
+ iface.launch()
random_forest_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0c6b11e5e479bebc736aa7301046e7a682a93f605df3e242cfd42ae888af4520
3
+ size 237761
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ pandas
2
+ numpy
3
+ scikit-learn
4
+ matplotlib
5
+ seaborn
6
+ openpyxl
7
+ joblib
scaler.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ab71200064b1353c21f0aaf545de90d44e0dcef85c461c77c47bae836d2c3caa
3
+ size 1023