{"id":25452935,"url":"https://github.com/shadowwphoenix/cloud-server-workload-prediction","last_synced_at":"2025-05-16T13:10:45.138Z","repository":{"id":268922962,"uuid":"905871451","full_name":"ShadowwPhoenix/Cloud-server-workload-prediction","owner":"ShadowwPhoenix","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-19T17:36:48.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-17T23:42:47.822Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ShadowwPhoenix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-19T17:31:05.000Z","updated_at":"2024-12-19T17:36:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"e9e643c2-ffe8-4e9b-8b6e-c711af3e4e13","html_url":"https://github.com/ShadowwPhoenix/Cloud-server-workload-prediction","commit_stats":null,"previous_names":["shadowwphoenix/cloud-server-workload-prediction"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShadowwPhoenix%2FCloud-server-workload-prediction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShadowwPhoenix%2FCloud-server-workload-prediction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShadowwPhoenix%2FCloud-server-workload-prediction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShadowwPhoenix%2FCloud-server-workload-prediction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ShadowwPhoenix","download_url":"https://codeload.github.com/ShadowwPhoenix/Cloud-server-workload-prediction/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254535822,"owners_count":22087399,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-17T23:41:57.060Z","updated_at":"2025-05-16T13:10:45.132Z","avatar_url":"https://github.com/ShadowwPhoenix.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CPU Usage Prediction with LSTM\n\n## Overview\nThis project leverages a Long Short-Term Memory (LSTM) neural network to predict CPU usage based on various input features from a dataset of virtual machine (VM) statistics. The model processes time-series data and provides predictions for CPU usage in the future based on past usage trends and other features.\n\n## Files\n- `vmCloud_data.csv`: The raw dataset used for training the model.\n- `saved_lstm_model.keras`: The trained LSTM model saved for future use.\n- `cpu_usage_prediction.py`: The script that loads the dataset, preprocesses the data, trains the LSTM model, and evaluates its performance.\n\n## Data Preprocessing\nThe data is preprocessed as follows:\n1. **Drop unnecessary columns**: `timestamp`, `vm_id`.\n2. **Handle missing values**: Numeric columns are filled with their mean values.\n3. **One-hot encoding**: Applied to categorical columns (`task_type`, `task_priority`, `task_status`).\n4. **Feature engineering**: Create lag features (`cpu_usage_lag1`, `cpu_usage_lag2`, ...) and rolling statistics (mean, standard deviation, min, max).\n5. **Data Scaling**: The data is scaled using `StandardScaler` to standardize the features.\n\n## Model Architecture\nThe model is a sequential LSTM neural network with the following layers:\n1. **LSTM Layer**: 150 units with return sequences.\n2. **Dropout Layer**: Dropout rate of 0.4 to prevent overfitting.\n3. **LSTM Layer**: 100 units without returning sequences.\n4. **Dropout Layer**: Dropout rate of 0.4.\n5. **Dense Layer**: Single neuron to output the predicted `cpu_usage`.\n\n## Model Training\nThe model is trained with the following configuration:\n- **Optimizer**: Adam with a learning rate of 0.0005.\n- **Loss Function**: Mean Squared Error (MSE).\n- **Epochs**: 100 epochs.\n- **Batch Size**: 64.\n\n## Model Evaluation\nThe model performance is evaluated using the following metrics:\n- **Mean Absolute Error (MAE)**: 0.45\n- **Mean Squared Error (MSE)**: 0.32\n- **Root Mean Squared Error (RMSE)**: 0.56\n- **R-squared (R2)**: 0.9996\n\n## Predictions vs Actual Values (First 10 Predictions)\n\n| Predicted | Actual |\n|-----------|--------|\n| 18.07     | 17.64  |\n| 65.71     | 64.98  |\n| 28.13     | 27.89  |\n| 83.53     | 83.17  |\n| 68.62     | 68.42  |\n| 3.08      | 2.52   |\n| 96.17     | 95.58  |\n| 93.27     | 93.32  |\n| 92.26     | 92.01  |\n| 70.94     | 70.28  |\n\n## Visualization\nAn interactive plot is generated using `plotly` to compare actual vs predicted CPU usage for the first 100 test samples.\n\n## Saving and Loading the Model\nThe trained LSTM model is saved using Keras' `save_model` function and can be loaded back for future predictions.\n\n## How to Use\n1. **Load the trained model**:\n    ```python\n    from tensorflow.keras.models import load_model\n    model = load_model('saved_lstm_model.keras')\n    ```\n\n2. **Prepare the input data** (following the same preprocessing steps as in the training phase).\n\n3. **Make predictions**:\n    ```python\n    y_pred = model.predict(X_test_scaled)\n    ```\n\n4. **Evaluate the model's performance** using metrics like MAE, MSE, RMSE, and R2.\n\n## License\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshadowwphoenix%2Fcloud-server-workload-prediction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshadowwphoenix%2Fcloud-server-workload-prediction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshadowwphoenix%2Fcloud-server-workload-prediction/lists"}