├── employee_performance_model.pkl ├── file1 data ├── code ├── README(2).md ├── lstm_employee_forecast.py ├── README.md └── Synthetic_KPI_Dataset.csv /employee_performance_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Beckybams/Employee-Performance-Forecasting-Using-KPIs/HEAD/employee_performance_model.pkl -------------------------------------------------------------------------------- /file1 data: -------------------------------------------------------------------------------- 1 | employee_id,project_delivery_score,attendance_rate,quality_score,teamwork_score,learning_index,performance_score 2 | E001,82,96,85,78,74,84 3 | E002,75,89,80,72,65,78 4 | E003,90,98,88,85,82,90 5 | E004,60,70,65,68,50,65 6 | E005,95,99,90,88,85,92 7 | -------------------------------------------------------------------------------- /code: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | from sklearn.ensemble import RandomForestRegressor 3 | from sklearn.model_selection import train_test_split 4 | from sklearn.metrics import mean_squared_error 5 | import joblib 6 | 7 | # Load data 8 | df = pd.read_csv('data/employee_kpis.csv') 9 | 10 | # Features and target 11 | X = df.drop(['employee_id', 'performance_score'], axis=1) 12 | y = df['performance_score'] 13 | 14 | # Train/test split 15 | X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) 16 | 17 | # Model 18 | model = RandomForestRegressor(n_estimators=100, random_state=42) 19 | model.fit(X_train, y_train) 20 | 21 | # Evaluation 22 | y_pred = model.predict(X_test) 23 | mse = mean_squared_error(y_test, y_pred) 24 | print(f"Test MSE: {mse:.2f}") 25 | 26 | # Save model 27 | joblib.dump(model, 'model/performance_model.pkl') 28 | print("Model saved.") 29 | -------------------------------------------------------------------------------- /README(2).md: -------------------------------------------------------------------------------- 1 | 2 | # Employee Performance Forecasting Using KPIs 3 | 4 | This project demonstrates how to forecast employee performance using key performance indicators (KPIs) through machine learning models. It includes both a regression model using Random Forest and a time-series model using LSTM for individual forecasting over time. 5 | 6 | ## Features 7 | 8 | - ✅ Random Forest Regression for performance prediction 9 | - 📈 LSTM Time-Series Forecasting for future performance trends 10 | - 🧪 Synthetic KPI dataset generation 11 | - 📊 Streamlit dashboard interface (optional) 12 | - 💾 Model saving and loading with joblib 13 | 14 | ## Files 15 | 16 | - `train_model.py` – Train a Random Forest model on employee KPI data. 17 | - `app.py` – Streamlit app for interactive prediction using trained model. 18 | - `synthetic_employee_kpis.csv` – Generated dataset with 100 synthetic employees. 19 | - `employee_performance_model.pkl` – Trained Random Forest model. 20 | - `lstm_employee_forecast.py` – LSTM-based forecast for an individual over time. 21 | - `README.md` – Project description and usage instructions. 22 | 23 | ## How to Use 24 | 25 | ### Step 1: Install Dependencies 26 | ```bash 27 | pip install pandas numpy scikit-learn streamlit matplotlib tensorflow 28 | ``` 29 | 30 | ### Step 2: Train and Test Model 31 | ```bash 32 | python train_model.py 33 | ``` 34 | 35 | ### Step 3: Run Streamlit App 36 | ```bash 37 | streamlit run app.py 38 | ``` 39 | 40 | ### Step 4: Run LSTM Forecast 41 | ```bash 42 | python lstm_employee_forecast.py 43 | ``` 44 | 45 | ## Author 46 | Generated by ChatGPT on behalf of the user. 47 | -------------------------------------------------------------------------------- /lstm_employee_forecast.py: -------------------------------------------------------------------------------- 1 | 2 | import numpy as np 3 | import pandas as pd 4 | from sklearn.preprocessing import MinMaxScaler 5 | from tensorflow.keras.models import Sequential 6 | from tensorflow.keras.layers import LSTM, Dense 7 | import matplotlib.pyplot as plt 8 | 9 | # Simulate 24 months of KPI data for one employee 10 | np.random.seed(42) 11 | time_steps = 24 12 | 13 | time_data = { 14 | 'project_delivery_score': np.random.normal(75, 5, time_steps), 15 | 'attendance_rate': np.random.normal(90, 3, time_steps), 16 | 'quality_score': np.random.normal(80, 4, time_steps), 17 | 'teamwork_score': np.random.normal(78, 3, time_steps), 18 | 'learning_index': np.random.normal(70, 5, time_steps) 19 | } 20 | 21 | df_time = pd.DataFrame(time_data) 22 | df_time['performance_score'] = ( 23 | 0.3 * df_time['project_delivery_score'] + 24 | 0.2 * df_time['attendance_rate'] + 25 | 0.2 * df_time['quality_score'] + 26 | 0.15 * df_time['teamwork_score'] + 27 | 0.15 * df_time['learning_index'] + 28 | np.random.normal(0, 2, time_steps) 29 | ) 30 | 31 | # Normalize data 32 | scaler = MinMaxScaler() 33 | scaled_data = scaler.fit_transform(df_time) 34 | 35 | # Prepare LSTM input/output 36 | X, y = [], [] 37 | n_input = 3 38 | for i in range(n_input, len(scaled_data)): 39 | X.append(scaled_data[i-n_input:i, :-1]) 40 | y.append(scaled_data[i, -1]) 41 | X, y = np.array(X), np.array(y) 42 | 43 | # Define and train model 44 | model = Sequential([ 45 | LSTM(50, activation='relu', input_shape=(n_input, 5)), 46 | Dense(1) 47 | ]) 48 | model.compile(optimizer='adam', loss='mse') 49 | model.fit(X, y, epochs=50, verbose=1) 50 | 51 | # Forecast next time step 52 | last_input = scaled_data[-n_input:, :-1] 53 | last_input = np.expand_dims(last_input, axis=0) 54 | forecast_scaled = model.predict(last_input)[0][0] 55 | 56 | # Inverse transform 57 | placeholder = np.zeros((1, scaled_data.shape[1])) 58 | placeholder[0, -1] = forecast_scaled 59 | forecast_actual = scaler.inverse_transform(placeholder)[0, -1] 60 | 61 | print(f"Forecasted Performance Score for Next Month: {forecast_actual:.2f}") 62 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **Employee Performance Forecasting Using KPIs** 2 | 3 | This project demonstrates how to forecast employee performance using key performance indicators (KPIs) through machine learning models. It includes both a regression model using Random Forest and a time-series model using LSTM for individual forecasting over time. 4 | 🔍 Features 5 | 6 | ✅ Random Forest Regression for performance prediction across multiple employees 7 | 8 | 📈 LSTM Time-Series Forecasting for predicting future performance trends per employee 9 | 10 | 🧪 Synthetic KPI dataset generation (simulates realistic HR data) 11 | 12 | 🧠 Model training and evaluation with performance metrics 13 | 14 | 📊 Optional Streamlit dashboard interface for interactive forecasting 15 | 16 | 💾 Model serialization using joblib 17 | 18 | 📁 Project Files 19 | File Description 20 | train_model.py Trains a Random Forest model on synthetic KPI data 21 | app.py Streamlit app for forecasting performance scores 22 | synthetic_employee_kpis.csv Generated dataset of 100 employees and KPIs 23 | employee_performance_model.pkl Trained Random Forest model file 24 | lstm_employee_forecast.py LSTM-based time-series forecast for single employee 25 | README.md This documentation file 26 | 🛠️ How to Use 27 | 1. Install Required Libraries 28 | 29 | pip install pandas numpy scikit-learn streamlit matplotlib tensorflow 30 | 31 | 2. Train Random Forest Model 32 | 33 | python train_model.py 34 | 35 | 3. Launch Streamlit App (Optional) 36 | 37 | streamlit run app.py 38 | 39 | 4. Run LSTM Time Series Forecast 40 | 41 | python lstm_employee_forecast.py 42 | 43 | 📊 Example KPI Columns 44 | 45 | project_delivery_score 46 | 47 | attendance_rate 48 | 49 | quality_score 50 | 51 | teamwork_score 52 | 53 | learning_index 54 | 55 | performance_score (target variable) 56 | 57 | 📌 Notes 58 | 59 | Random Forest handles tabular KPI regression well for cross-sectional data. 60 | 61 | LSTM is used for sequential forecasting using historical KPI patterns (e.g., monthly updates). 62 | 63 | The synthetic dataset can be replaced with actual HR data for deployment. 64 | 65 | 👨‍💻 Author 66 | -------------------------------------------------------------------------------- /Synthetic_KPI_Dataset.csv: -------------------------------------------------------------------------------- 1 | employee_id,project_delivery_score,attendance_rate,quality_score,teamwork_score,learning_index,performance_score 2 | E001,79.96714153011233,82.92314628974793,82.86229888278626,72.19703492354549,54.05572341205633,78.86 3 | E002,73.61735698828815,87.89677338617321,84.48627621094587,74.07873271862121,64.00624977046228,83.0 4 | E003,81.47688538100692,88.28642741736616,88.66440994540221,83.23105523586284,70.05243699718183,78.63 5 | E004,90.23029856408026,85.9886136538919,88.43041641627923,82.27259185803425,70.46980593764742,86.55 6 | E005,72.65846625276664,89.19357144166996,68.97864505634327,77.85368884225096,65.49934528520757,72.98 7 | E006,72.6586304305082,92.02025428407269,72.49739968067902,78.82129168316148,76.22849932347499,76.5 8 | E007,90.79212815507391,99.43092950605265,84.12028213766928,86.94365427051898,59.32379570617405,84.11 9 | E008,82.67434729152909,90.8728890641592,84.11028760729766,73.8590002781492,68.57620514978707,78.57 10 | E009,70.30525614065049,91.28775195361382,84.12038149044838,81.82968166819026,71.20295631711899,79.27 11 | E010,80.42560043585965,89.62777042116916,100.0,76.58465143296274,75.14438834058748,82.32 12 | E011,70.36582307187538,80.4061439235048,84.56712408554533,76.47623157740946,77.11614878088889,77.95 13 | E012,70.34270246429743,89.86743062275391,89.08452512144478,85.69143796391033,58.75357908162131,78.41 14 | E013,77.41962271566034,90.30115104970513,87.63201410794562,83.77791444291621,54.65885829264378,78.86 15 | E014,55.86719755342202,100.0,85.21113001044638,83.69456745200446,82.7767682189851,76.05 16 | E015,57.75082167486967,89.03819517609439,77.47784604287723,87.1383516500803,73.32314011979592,72.97 17 | E016,69.37712470759027,91.50773671166806,86.07175376394613,78.14702689142932,62.51513463443446,79.69 18 | E017,64.87168879665576,89.82644115147379,73.81739828369942,82.77367079906475,85.51151975522524,78.94 19 | E018,78.14247332595274,84.15660981190234,78.10545114607993,75.82813270384581,71.15674634292859,75.01 20 | E019,65.91975924478788,95.7141140725751,76.11709161736717,80.26916446741909,81.79297184063826,78.75 21 | E020,60.87696298664709,93.75966516343387,80.65499311509058,77.0889986194262,70.67518481410109,77.56 22 | E021,89.65648768921554,93.95515973521523,98.51726853338806,78.67897175494903,90.60747924881987,85.78 23 | E022,72.74223699513465,85.4530627260263,65.06187845926601,82.1660991780584,87.55340842443204,79.01 24 | E023,75.67528204687923,97.0139715546805,85.4900815229961,72.27245521736569,67.51035851520926,78.18 25 | E024,60.75251813786544,82.9907446860386,67.09827303048279,92.64671092979822,79.71570950954356,75.81 26 | E025,69.55617275474818,92.93428546900135,76.22454507368454,70.95787832950208,76.45375949585147,74.52 27 | E026,76.10922589709867,100.0,88.71160477573893,69.50067971048587,83.68631557532349,78.14 28 | E027,63.490064225776976,85.04731837434656,80.5142401527637,86.10677611450048,60.35076539419896,69.25 29 | E028,78.75698018345672,87.16851135198614,71.37804177656555,83.54163885774055,76.8605145999844,79.54 30 | E029,68.99361310081196,90.4982568254382,74.27757032592025,82.36883871936509,80.58424486849587,78.88 31 | E030,72.08306250206724,87.48262172941901,85.4367819914774,82.39841856484996,52.41260513576886,73.72 32 | E031,68.98293387770603,82.24668284466934,74.1570669462629,77.9142725900716,58.16741487334225,74.3 33 | E032,93.52278184508938,90.34281487403014,81.7316687166558,71.71921939959918,49.607678222398995,75.69 34 | E033,74.86502775262066,84.68848143136948,80.3645747192305,78.53063190735608,67.30593165555442,77.15 35 | E034,64.422890710441,92.36796215317591,74.78719721915347,73.25986801941522,77.17542255795962,71.69 36 | E035,83.22544912103189,85.40287882883098,97.1515527146026,84.82583813392426,85.02357052096028,85.0 37 | E036,62.791563500289776,97.7496720250877,85.07135217854409,76.97059832948503,70.74094780419775,77.7 38 | E037,77.08863595004756,86.08373353831881,63.798859306739146,72.22151962245242,86.28615545571292,74.3 39 | E038,55.403298761202244,88.38969241897162,81.49163451815542,75.75029910842905,56.198985417851084,69.24 40 | E039,61.71813951101569,94.06758608684835,74.70570828185289,80.89052017992937,52.96617560644845,75.37 41 | E040,76.96861235869123,83.84567841783023,86.81946667836979,74.05392813037217,69.44452301103381,77.02 42 | E041,82.3846657999541,91.13729967302065,73.65983409253839,72.24445723103499,73.84065448939307,82.09 43 | E042,76.7136828118997,96.53571377141213,79.0821084682648,79.70581048044339,69.67305251905907,77.16 44 | E043,73.8435171761176,81.96258382719387,84.03989823184365,79.71476599776106,49.325578999601234,76.3 45 | E044,71.98896304410711,90.92316929266153,86.92604155336097,74.45139777240209,69.10879960487212,83.03 46 | E045,60.214780096325725,91.29941397124212,70.3976287435538,74.70273186067175,56.95530499495147,62.74 47 | E046,67.80155791605291,93.90911435888655,77.32399011327242,79.62434956150345,76.69672548830039,75.64 48 | E047,70.39361229040213,83.81524644560959,76.20043751071235,67.86340960951873,73.66598246096848,76.08 49 | E048,85.57122226218915,83.39771693457863,74.7733661394103,68.14775357936412,60.60120213672645,76.01 50 | E049,78.43618289568461,92.60970782808448,94.12363392224877,72.97089045123295,64.86133082663306,82.67 51 | E050,57.36959844637266,91.48492336616593,83.23985368768764,76.50586993801707,59.40786478111048,70.73 52 | E051,78.24083969394795,91.25246425172938,69.91292836531964,80.17635295918603,69.37320902726829,78.4 53 | E052,71.14917719583684,91.73224104748488,87.34289557643821,88.32749351864686,79.55142320501238,81.87 54 | E053,68.23077999694041,86.59987639210755,96.97724957610106,84.00361736241413,60.14273953664456,82.31 55 | E054,81.11676288840867,91.16126848580502,88.25972208440918,76.88043029025602,75.04046515517844,83.77 56 | E055,85.30999522495951,91.46536236649341,67.8450402723679,77.86688654468118,64.69742381627559,79.85 57 | E056,84.31280119116198,86.42824290986816,76.12612741707,70.98229444753534,62.07127167737656,76.53 58 | E057,66.60782476777362,99.32887255572378,90.13528919349298,77.87040804805326,68.92969640045442,78.43 59 | E058,71.90787624148786,92.36916460455893,74.33864427504976,75.97938952755904,59.64757677580626,73.96 60 | E059,78.31263431403563,84.04348251398676,83.55055542516983,80.25902992236662,64.46350694652818,79.9 61 | E060,84.75545127122359,93.28276804316914,86.19707242743469,72.20938339513374,58.021221074111516,79.59 62 | E061,70.2082576215471,85.1265916488634,72.58455622737533,81.6354255996882,89.6472513291639,79.17 63 | E062,73.14341023336183,93.93542301871226,79.5237971515056,88.72917239101804,70.35263551971728,86.72 64 | E063,63.93665025993972,95.79297789503703,60.0,77.23867896080199,63.00274492007414,73.99 65 | E064,63.037933759193294,85.89658840824144,71.80489886932568,80.81198205469259,72.13979910734221,72.42 66 | E065,83.12525822394198,94.8168806462216,77.97945478885472,82.83100794197779,68.8767195030917,85.86 67 | E066,88.56240028570824,92.06390463468249,70.01773454428121,75.19145669679915,67.79030400466777,79.21 68 | E067,74.27989878419666,94.11030079997245,93.05929043145308,79.56864737267291,76.14166700043425,76.96 69 | E068,85.03532897892023,99.48396491326974,68.55886897631494,78.08814680547256,77.57507710047305,79.44 70 | E069,78.61636025047635,88.77305941998564,76.47964410642413,78.68373268984182,64.69498852389472,72.53 71 | E070,68.54880245394875,86.23131917821256,81.04592461828874,72.58893151301173,64.2418175935532,73.49 72 | E071,78.61395605508415,85.55242785187238,91.53018631252893,78.1715712198126,67.24948302848355,80.87 73 | E072,90.38036566465969,85.92094857517282,68.51310279056449,81.48598803871815,46.980788352644154,82.3 74 | E073,74.64173960890048,89.61449145292949,89.30531001723968,88.1580052545653,54.84808937801448,80.61 75 | E074,90.64643655814007,91.70575987408321,80.0818644881567,84.71489578259644,83.66874267444524,86.15 76 | E075,50.0,91.38345399665009,72.14793079161639,93.07227720258089,86.44967713501283,77.12 77 | E076,83.21902504375224,94.13591624518011,83.69682779410617,72.62856705978365,67.50963960443622,74.92 78 | E077,75.87047068238171,90.06500945938953,81.59247756458777,84.10624445704475,75.76556963055766,81.78 79 | E078,72.00992649534132,97.26767038578659,75.19826498272964,79.28339404016846,73.11250154543536,81.27 80 | E079,75.91760776535503,88.67671583381022,80.55841667992016,93.3286205325237,100.0,81.19 81 | E080,55.124310853991076,100.0,76.91749122510592,72.34191200251394,81.19574911434577,78.38 82 | E081,72.80328112162488,93.12833673882503,80.90813876200998,72.12194710473457,68.72082408519233,78.79 83 | E082,78.57112571511746,85.71421221791859,85.29704539616837,73.80425148189184,60.44459559399574,76.67 84 | E083,89.77894044741517,84.64553750969444,92.68813452916282,63.132729929831356,53.93553679742428,81.86 85 | E084,69.81729781726352,92.41236207621593,70.0974760093852,74.31971484823467,72.03463635867223,82.21 86 | E085,66.91506397106812,88.88268607337075,97.06426699725013,72.68607136912411,62.436492547156966,78.08 87 | E086,69.98242956415463,93.57000247046047,64.38329760381998,79.05275650533345,55.77746290402326,73.55 88 | E087,84.15402117702074,92.36618812286773,78.78571923971533,80.39229183044012,63.534271157574736,79.69 89 | E088,78.28751109659684,89.63585543671563,84.70653765187662,91.1331958745112,59.18451996385605,78.35 90 | E089,69.70239796232961,85.76603140965797,82.24793494188026,84.65296686730235,86.87141635072564,82.73 91 | E090,80.13267433113356,82.42576387657067,75.01840384143524,73.96167441036317,78.81639756949451,75.88 92 | E091,75.9707754934804,87.76742523966489,78.3350219971418,71.71109730056149,69.92027358683383,77.47 93 | E092,84.68644990532889,94.28199397161737,76.05599252272934,81.44343420054554,84.79944138890026,82.98 94 | E093,67.97946906122648,91.07046872065102,75.2850819444463,68.75836755085551,70.77368307647619,76.03 95 | E094,71.72337853402232,83.77130610644006,86.7968167761682,90.82021136098048,61.38715798671736,79.46 96 | E095,71.07891846867842,90.86590462925591,82.85612388772037,86.25608084504901,85.23124077269657,84.9 97 | E096,60.364850518678814,91.92658689864419,74.45672323791477,74.71577043526706,75.38910043684659,72.37 98 | E097,77.96120277064576,85.58071281899433,87.19679900346601,66.00805829636386,59.62753845673544,75.98 99 | E098,77.6105527217989,90.76862552972764,82.45839616701288,87.4771066191579,68.09661321916391,78.33 100 | E099,75.05113456642461,90.29104359223,86.50289695071169,77.19822108323167,61.24381746615243,77.31 101 | E100,72.65412866624852,84.28514851084688,85.0370307353889,86.66471418381423,56.172002690356635,78.22 102 | --------------------------------------------------------------------------------