Spaces:
Runtime error
Runtime error
File size: 4,357 Bytes
6e80622 ed17d8c 6e80622 c21b345 d1f9bf3 64a1b9d 6e80622 c21b345 6e80622 c21b345 6e80622 44beeb5 6e80622 c21b345 6e80622 c333c03 c21b345 6e80622 |
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 54 55 56 57 58 59 |
import pickle
import gradio as gr
# Load the pickled model
with open('./rf_cv_waze.pickle' , 'rb') as file:
model = pickle.load(file)
# Define the function for making predictions
def salifort(sessions, drives, total_sessions, n_days_after_onboarding, total_navigations_fav1, total_navigations_fav2, driven_km_drives, duration_minutes_drives, activity_days, driving_days, km_per_driving_day, percent_sessions_in_last_month, professional_driver, total_sessions_per_day, km_per_hour, km_per_drive, percent_of_drives_to_favorite, device2):
inputs = [[ float(sessions), float(drives), float(total_sessions), float(n_days_after_onboarding),
float(total_navigations_fav1), float(total_navigations_fav2), float(driven_km_drives),
float(duration_minutes_drives), float(activity_days), float(driving_days),
float(km_per_driving_day), float(percent_sessions_in_last_month),
float(professional_driver), float(total_sessions_per_day), float(km_per_hour),
float(km_per_drive), float(percent_of_drives_to_favorite), float(device2)
]]
prediction = model.predict(inputs)
prediction_value = prediction[0]
if prediction_value == 0:
label_text = 'User Retained 🟢'
else:
label_text = 'User Churned 🔴'
return label_text
# Create the Gradio interface
salifort_ga = gr.Interface(fn=salifort,
inputs = [
gr.Number(0, 743, label="sessions: [0 to 743]"),
gr.Number(0, 596, label="drives: [0 to 596]"),
gr.Number(0, 1216, label="total_sessions: [0 to 1216]"),
gr.Number(4, 3500, label="n_days_after_onboarding: [4 to 3500]"),
gr.Number(0, 1236, label="total_navigations_fav1: [0 to 1236]"),
gr.Number(0, 415, label="total_navigations_fav2: [0 to 415]"),
gr.Number(60, 21183, label="driven_km_drives: [60 to 21183]"),
gr.Number(18, 15852, label="duration_minutes_drives: [18 to 15852]"),
gr.Number(0, 31, label="activity_days: [0 to 31]"),
gr.Number(0, 30, label="driving_days: [0 to 30]"),
gr.Number(0, 15420, label="km_per_driving_day: [0 to 15420]"),
gr.Number(0, 1.5, label="percent_sessions_in_last_month: [0 to 1.5]"),
gr.Number(0, 1, label="professional_driver: [0 to 1]"),
gr.Number(0, 39, label="total_sessions_per_day: [0 to 39]"),
gr.Number(72, 23642, label="km_per_hour: [72 to 23642]"),
gr.Number(0, 15777, label="km_per_drive: [0 to 15777]"),
gr.Number(0, 777, label="percent_of_drives_to_favorite: [0 to 777]"),
gr.Number(0, 1, label="device2: [0 to 1]"),
],
outputs = "text", title="Data-driven suggestions for Waze - User Churn",
examples = [
[30, 30, 207, 2239, 11, 12, 3919, 2182, 26, 25, 157, 0, 0, 0, 108, 131, 0, 0],
[47, 40, 144, 36, 353, 0, 10764, 4617, 18, 17, 633, 0, 0, 4, 140, 269, 2, 0],
[75, 61, 87, 2825, 67, 94, 243, 183, 2, 0, 0, 1, 0, 0, 80, 4, 2, 0, 0, 0],
[0, 0, 291, 1589, 447, 110, 1574, 1163, 17, 16, 98, 0, 0, 0, 81, 0, 2, 1, 0],
[56, 45, 82, 701, 80, 32, 1515, 691, 20, 15, 101, 1, 0, 0, 132, 34, 1, 0, 0]
],
description="User Churn Prediction Using Machine Learning",
theme='dark'
)
salifort_ga.launch(share=True) |