import gradio as gr import pandas as pd from sklearn.preprocessing import LabelEncoder from sklearn.feature_selection import mutual_info_classif from sklearn.feature_selection import chi2 from sklearn.linear_model import LinearRegression import numpy as np def update(name): df = pd.read_csv('emp_experience_data.csv') pd.options.display.max_columns = 25 data_encoded = df.copy(deep=True) categorical_column = ['Attrition', 'Gender', 'BusinessTravel', 'Education', 'EmployeeExperience', 'EmployeeFeedbackSentiments', 'Designation', 'SalarySatisfaction', 'HealthBenefitsSatisfaction', 'UHGDiscountProgramUsage', 'HealthConscious', 'CareerPathSatisfaction', 'Region'] label_encoding = LabelEncoder() for col in categorical_column: data_encoded[col] = label_encoding.fit_transform(data_encoded[col]) data_selected = data_encoded[['EmployeeExperience', 'HealthBenefitsSatisfaction', 'SalarySatisfaction', 'Designation', 'HealthConscious', 'EmployeeFeedbackSentiments', 'Education', 'Gender', 'HoursOfTrainingAttendedLastYear', 'InternalJobMovement', 'Attrition']] validation_data = data_selected[100:198] validation_input_data = validation_data.drop(['Attrition'], axis=1) validation_target_data = validation_data[['Attrition']] reg = LinearRegression().fit(validation_input_data, validation_target_data) prediction_value = reg.predict(np.array([[2,2,1,3,1,2,0,1,40,1]])) return f"Prediction : , {prediction_value}!" with gr.Blocks() as demo: gr.Markdown("Start typing below and then click **Run** to see the output.") with gr.Row(): inp = gr.Textbox(placeholder="Enter Employee Experience Data") out = gr.Textbox() btn = gr.Button("Run") btn.click(fn=update, inputs=inp, outputs=out) demo.launch()