{"id":19306252,"url":"https://github.com/audrbar/ml-classification","last_synced_at":"2025-08-27T15:15:37.393Z","repository":{"id":258657161,"uuid":"874296829","full_name":"audrbar/ml-classification","owner":"audrbar","description":"Classification Methods in Machine Learning","archived":false,"fork":false,"pushed_at":"2024-10-30T19:34:36.000Z","size":1710,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-06T00:43:38.194Z","etag":null,"topics":["classification","decision-tree-classifier","gaussian","kneighborsclassifier","logistic-regression","random-forest-classifier"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/audrbar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-10-17T15:20:55.000Z","updated_at":"2024-10-30T19:34:39.000Z","dependencies_parsed_at":"2024-10-23T23:19:11.420Z","dependency_job_id":null,"html_url":"https://github.com/audrbar/ml-classification","commit_stats":null,"previous_names":["audrbar/ml-classification"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/audrbar%2Fml-classification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/audrbar%2Fml-classification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/audrbar%2Fml-classification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/audrbar%2Fml-classification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/audrbar","download_url":"https://codeload.github.com/audrbar/ml-classification/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240405587,"owners_count":19796209,"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":["classification","decision-tree-classifier","gaussian","kneighborsclassifier","logistic-regression","random-forest-classifier"],"created_at":"2024-11-10T00:05:07.508Z","updated_at":"2025-02-24T02:27:43.821Z","avatar_url":"https://github.com/audrbar.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)\n# Classification in Machine Learning Project\nClassification is a supervised machine learning method where the model tries to predict the \ncorrect label of a given input data. In classification, the model is fully trained using \nthe training data, and then it is evaluated on test data before being used to perform \nprediction on new unseen data.\n### Dataset and it's Features\nCan you predict if customer is going to cancel the reservation ?\\\nA significant number of hotel reservations are called-off due to cancellations or no-shows. The typical reasons \nfor cancellations include change of plans, scheduling conflicts, etc. This is often made easier by the option \nto do so free of charge or preferably at a low cost which is beneficial to hotel guests, but it is a less desirable \nand possibly revenue-diminishing factor for hotels to deal with. A [Kaggle Hotel Reservations Dataset](https://www.kaggle.com/datasets/ahsan81/hotel-reservations-classification-dataset) \nis used for the project. It has **36275 entries, 19 columns**. One of them (booking_status) is the _target column_, \n_12 features columns_ with data type of integer or float and _3 features columns_ with data type of object. One \ncolumn - Booking_ID - was dropped.\n### Encoding categorical columns\nLabel Encoder was applied to categorical columns: type_of_meal_plan, room_type_reserved and market_segment_type.\n### Data Normalization\nStandard Scaler method was applied to normalize the numeric features (columns), where the maximum value is greater \nthan 10.\n### Data Correlation\n**Data Correlation** (a statistical indicator that quantifies the degree to which two variables change in relation to each \nother) of the Dataset *does not show clear correlation* between data columns, except two minor dependencies:\\\n- no_of_previous_bookings_not_canceled / repeated_guest - 0,54\n- avg_price_per_room / room_type_reserved - 0,47\n- lead_time / booking_status - -0,44\\\nAfter removing these tree features from dataset result was 0.8624 for Logistic Regression and 0.8414 for Random Forest.\\ \n![Data Correlation Plot](./img/Figure_data_correlation.png)\n### Dataset Balancing\n**Dataset is unbalanced** - initial train data class distribution is 19512 for not canceled bookings to 9508 \ncanceled bookings.\nAfter *Target Class Balancing* class distribution is as follows:\n![Data Distribution Plot](./img/Screen_target_balace.png)\n### Classification Algorithms Evaluated\n- Logistic Regression\n- Decision Tree\n- Random Forests\n- K-Nearest Neighbours\n- Naive Bayes\n### Models Evaluation Metrics used\n**Accuracy:** The proportion of correctly classified instances over the total number \nof instances in the test set.\\\n**Precision:** Precision measures the proportion of true positives over the total number of predicted positives.\\\n**Recall:** Recall measures the proportion of true positives over the total number of actual positives.\\\n**Specificity:** Specificity measures how well the model can correctly identify instances of the negative class.\\\n**F1-Score:** The harmonic mean of precision and recall, calculated as 2 x (precision x recall) / (precision + \nrecall).\\\n**Confusion matrix:** A table that shows the number of true positives, true negatives, false positives, \nand false negatives for each class, which can be used to calculate various evaluation metrics.\\\n**Cross-validation:** A technique that divides the data into multiple folds and trains the model on each fold \nwhile testing on the others, to obtain a more robust estimate of the model’s performance.\n### Initial Evaluation results\nClassifiers Performance Metrics on Hotel Reservations Dataset are:\n![Classifier Performance Metrics Table](./img/Screen_accuracy_all.png)\n![Classifier Performance Metrics Figure](./img/Figure_performance_all.png)\n### Models fitting\nTwo models were fitted: Logistic Regression and Random Forest Classifier.\n### Logistic Regression\nThe certain set of a thresholds was used to find the best threshold for the Logistic Regression model:\n![Classifier Performance Metrics Table](./img/Figure_logistic.png)\nThe best fitted threshold and corresponding accuracy is:\n![Classifier Performance Metrics Table](./img/Table_logistic.png)\n### Random Forests\nInitially 3 parameters for a model tuning was used: n_estimators, max_depth and bootstrap. \n![Classifier Performance Metrics Plot](./img/Figure_random_forest.png)\nLater additional 4 params were introduced: min_samples_split, min_samples_leaf, max_features, criterion.\nThe GridSearch Cross Validation method was used to find the best parameters for the Random Forest model:\n![Classifier Performance Metrics Plot](./img/Screen_rf_best_params.png)\n![Classifier Performance Metrics Plot](./img/Screen_rf_Accuracy_7.png)\n### Overfitting Check\n![Classifier Overfitting Plot](./img/Figure_lr_overfitting.png)\n![Classifier Overfitting Plot](./img/Figure_rf_overfitting.png)\n### Features Importance\n![Classifier Feature Importance Plot](./img/Figure_features_importance.png)\n### Final Results\n| Model               | Accuracy          | Overfitting distance |\n|---------------------|-------------------|----------------------|\n| Logistic Regression | 0.8857            | 23,17 %              |\n| Random Forests      | 0.8928            | 10 %                 |\n### Project status\nWay forward:\n- Check for data correlation (+).\n- Features normalisation (+).\n- Check for model overfitting (+).\n- Evaluate feature importance (+).\n- Introduce more params fo Random Forest model (+).\n### Contributing\nContributions are welcome! Please open an issue or submit a pull request if you have any improvements or bug fixes.\n### Resources\n[Kaggle Hotel Reservations Dataset Link](https://www.kaggle.com/datasets/ahsan81/hotel-reservations-classification-dataset)\n### License\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faudrbar%2Fml-classification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faudrbar%2Fml-classification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faudrbar%2Fml-classification/lists"}