Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fictional character battle #721

Merged
merged 5 commits into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions Fictional Character Battle Outcome Prediction/Models/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Models Implemented in Fictional Character Battle Outcome Prediction Project

This document provides details on the machine learning models implemented in the "Fictional Character Battle Outcome Prediction" project.

## Models and Their Accuracies

1. **Random Forest**:
- Accuracy: 75.27%
- A versatile ensemble learning method that operates by constructing multiple decision trees during training and outputs the mode of the classes for classification.

2. **Support Vector Classifier (SVC)**:
- Accuracy: 77.40%
- A supervised learning model that analyzes data for classification by finding the hyperplane that best separates the classes.

3. **Logistic Regression**:
- Accuracy: 76.33%
- A statistical model that in its basic form uses a logistic function to model a binary dependent variable.

4. **Decision Tree**:
- Accuracy: 71.00%
- A decision support tool that uses a tree-like graph of decisions and their possible consequences.

5. **K-Nearest Neighbors (KNN)**:
- Accuracy: 73.56%
- A simple, instance-based learning algorithm that assigns a class to a sample based on the majority class among its k-nearest neighbors.

6. **Gradient Boosting**:
- Accuracy: 77.40%
- An ensemble technique that builds models sequentially, each new model correcting errors made by previous models.

7. **AdaBoost**:
- Accuracy: 78.25%
- A boosting algorithm that combines the predictions of several base estimators to improve robustness over a single estimator.

8. **CatBoost**:
- Accuracy: 76.12%
- A high-performance library for gradient boosting on decision trees, especially well-suited for categorical data.

9. **Extra Trees**:
- Accuracy: 73.35%
- An ensemble learning method similar to Random Forest but with more randomness in the splitting of nodes.

10. **XGBoost**:
- Accuracy: 72.71%
- An optimized distributed gradient boosting library designed to be highly efficient, flexible, and portable.

11. **Bagging Classifier**:
- Accuracy: 73.99%
- An ensemble meta-estimator that fits base classifiers each on random subsets of the original dataset and then aggregates their predictions.

12. **Stacking Classifier**:
- Accuracy: 75.27%
- An ensemble learning technique that combines multiple base classifiers via a meta-classifier. The base classifiers are trained on the training dataset, and the meta-classifier is trained on the outputs of the base classifiers.

![eda-1](https://github.com/adi271001/ML-Crate/blob/Fictional-Character-Battle/Fictional%20Character%20Battle%20Outcome%20Prediction/Images/__results___25_0.png?raw=true)
![eda-1](https://github.com/adi271001/ML-Crate/blob/Fictional-Character-Battle/Fictional%20Character%20Battle%20Outcome%20Prediction/Images/__results___25_1.png?raw=true)
![eda-1](https://github.com/adi271001/ML-Crate/blob/Fictional-Character-Battle/Fictional%20Character%20Battle%20Outcome%20Prediction/Images/__results___25_2.png?raw=true)
![eda-1](https://github.com/adi271001/ML-Crate/blob/Fictional-Character-Battle/Fictional%20Character%20Battle%20Outcome%20Prediction/Images/__results___25_3.png?raw=true)
![eda-1](https://github.com/adi271001/ML-Crate/blob/Fictional-Character-Battle/Fictional%20Character%20Battle%20Outcome%20Prediction/Images/__results___25_4.png?raw=true)
![eda-1](https://github.com/adi271001/ML-Crate/blob/Fictional-Character-Battle/Fictional%20Character%20Battle%20Outcome%20Prediction/Images/__results___25_5.png?raw=true)
![eda-1](https://github.com/adi271001/ML-Crate/blob/Fictional-Character-Battle/Fictional%20Character%20Battle%20Outcome%20Prediction/Images/__results___25_6.png?raw=true)
![eda-1](https://github.com/adi271001/ML-Crate/blob/Fictional-Character-Battle/Fictional%20Character%20Battle%20Outcome%20Prediction/Images/__results___25_7.png?raw=true)
![eda-1](https://github.com/adi271001/ML-Crate/blob/Fictional-Character-Battle/Fictional%20Character%20Battle%20Outcome%20Prediction/Images/__results___25_8.png?raw=true)
![eda-1](https://github.com/adi271001/ML-Crate/blob/Fictional-Character-Battle/Fictional%20Character%20Battle%20Outcome%20Prediction/Images/__results___25_9.png?raw=true)
![eda-1](https://github.com/adi271001/ML-Crate/blob/Fictional-Character-Battle/Fictional%20Character%20Battle%20Outcome%20Prediction/Images/__results___25_10.png?raw=true)
![eda-1](https://github.com/adi271001/ML-Crate/blob/Fictional-Character-Battle/Fictional%20Character%20Battle%20Outcome%20Prediction/Images/__results___25_11.png?raw=true)

## Conclusion
Among the models evaluated, **AdaBoost** achieved the highest accuracy of 78.25%. This model is the best performer due to its ability to adaptively adjust the weights of misclassified instances, leading to improved performance in the prediction task. AdaBoost’s strong performance across multiple metrics, including precision, recall, and F1 score, highlights its effectiveness in handling this classification problem.

## Signature

**Name:** Aditya D
**Github:** [https://www.github.com/adi271001](https://www.github.com/adi271001)
**LinkedIn:** [https://www.linkedin.com/in/aditya-d-23453a179/](https://www.linkedin.com/in/aditya-d-23453a179/)
**Topmate:** [https://topmate.io/aditya_d/](https://topmate.io/aditya_d/)
**Twitter:** [https://x.com/ADITYAD29257528](https://x.com/ADITYAD29257528)

Large diffs are not rendered by default.

119 changes: 119 additions & 0 deletions Fictional Character Battle Outcome Prediction/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Fictional Character Battle Outcome Prediction Project

## Goal
The goal of this project is to predict the outcomes of battles between fictional characters using various machine learning models.

## Dataset
The dataset used for this project is the ["Fictional Character Battle Outcome Prediction"](https://www.kaggle.com/datasets/rabieelkharoua/fictional-character-battle-outcome-prediction/data) dataset from Kaggle.

## Description
The dataset contains features related to fictional characters and the outcomes of their battles. The features include attributes such as strength, intelligence, speed, durability, power, and combat skills of the characters. The target variable is the outcome of the battle.

## What I Had Done
1. **Data Preprocessing**:
- Loaded the dataset.
- Handled missing values.
- Encoded categorical variables.
- Split the data into training and testing sets.

2. **Exploratory Data Analysis (EDA)**:
- Visualized the distribution of features.
- Analyzed the correlation between features.
- Examined the class distribution of the target variable.

3. **Model Training and Evaluation**:
- Trained multiple machine learning models.
- Evaluated the performance of each model using accuracy, precision, recall, and F1 score.
- Implemented a stacking classifier as an ensemble method.

## Models Implemented
The following machine learning models were implemented and evaluated in this project:

1. **Random Forest**:
- A versatile ensemble learning method that operates by constructing multiple decision trees during training and outputs the mode of the classes for classification.

2. **Support Vector Classifier (SVC)**:
- A supervised learning model that analyzes data for classification by finding the hyperplane that best separates the classes.

3. **Logistic Regression**:
- A statistical model that in its basic form uses a logistic function to model a binary dependent variable.

4. **Decision Tree**:
- A decision support tool that uses a tree-like graph of decisions and their possible consequences.

5. **K-Nearest Neighbors (KNN)**:
- A simple, instance-based learning algorithm that assigns a class to a sample based on the majority class among its k-nearest neighbors.

6. **Gradient Boosting**:
- An ensemble technique that builds models sequentially, each new model correcting errors made by previous models.

7. **AdaBoost**:
- A boosting algorithm that combines the predictions of several base estimators to improve robustness over a single estimator.

8. **CatBoost**:
- A high-performance library for gradient boosting on decision trees, especially well-suited for categorical data.

9. **Extra Trees**:
- An ensemble learning method similar to Random Forest but with more randomness in the splitting of nodes.

10. **XGBoost**:
- An optimized distributed gradient boosting library designed to be highly efficient, flexible, and portable.

11. **Bagging Classifier**:
- An ensemble meta-estimator that fits base classifiers each on random subsets of the original dataset and then aggregates their predictions.

12. **Stacking Classifier**:
- An ensemble learning technique that combines multiple base classifiers via a meta-classifier. The base classifiers are trained on the training dataset, and the meta-classifier is trained on the outputs of the base classifiers.

## Libraries Needed
The following libraries were used in this project:
- pandas
- numpy
- matplotlib
- scikit-learn
- xgboost
- catboost
- mlxtend

## EDA Results
- Visualizations of feature distributions showed that most features are normally distributed.
- Correlation analysis indicated that certain features like strength and power have a high correlation.
- The target variable was found to be balanced, with a nearly equal distribution of battle outcomes.

![eda-1](https://github.com/adi271001/ML-Crate/blob/Fictional-Character-Battle/Fictional%20Character%20Battle%20Outcome%20Prediction/Images/__results___13_0.png?raw=true)
![eda-1](https://github.com/adi271001/ML-Crate/blob/Fictional-Character-Battle/Fictional%20Character%20Battle%20Outcome%20Prediction/Images/__results___14_0.png?raw=true)
![eda-1](https://github.com/adi271001/ML-Crate/blob/Fictional-Character-Battle/Fictional%20Character%20Battle%20Outcome%20Prediction/Images/__results___15_1.png?raw=true)
![eda-1](https://github.com/adi271001/ML-Crate/blob/Fictional-Character-Battle/Fictional%20Character%20Battle%20Outcome%20Prediction/Images/__results___15_3.png?raw=true)
![eda-1](https://github.com/adi271001/ML-Crate/blob/Fictional-Character-Battle/Fictional%20Character%20Battle%20Outcome%20Prediction/Images/__results___15_5.png?raw=true)
![eda-1](https://github.com/adi271001/ML-Crate/blob/Fictional-Character-Battle/Fictional%20Character%20Battle%20Outcome%20Prediction/Images/__results___16_1.png?raw=true)
![eda-1](https://github.com/adi271001/ML-Crate/blob/Fictional-Character-Battle/Fictional%20Character%20Battle%20Outcome%20Prediction/Images/__results___17_0.png?raw=true)
![eda-1](https://github.com/adi271001/ML-Crate/blob/Fictional-Character-Battle/Fictional%20Character%20Battle%20Outcome%20Prediction/Images/__results___18_0.png?raw=true)
![eda-1](https://github.com/adi271001/ML-Crate/blob/Fictional-Character-Battle/Fictional%20Character%20Battle%20Outcome%20Prediction/Images/__results___19_0.png?raw=true)
![eda-1](https://github.com/adi271001/ML-Crate/blob/Fictional-Character-Battle/Fictional%20Character%20Battle%20Outcome%20Prediction/Images/__results___20_0.png?raw=true)

## Performance of the Models based on Accuracy Scores

| Model | Accuracy | Precision | Recall | F1 Score |
|-------------------------|----------|-----------|--------|----------|
| Random Forest | 0.752665 | 0.686600 | 0.662923 | 0.671616 |
| Support Vector Classifier | 0.773987 | 0.721856 | 0.665816 | 0.681222 |
| Logistic Regression | 0.763326 | 0.702406 | 0.663184 | 0.675493 |
| Decision Tree | 0.710021 | 0.638167 | 0.638167 | 0.638167 |
| K-Nearest Neighbors | 0.735608 | 0.661683 | 0.639267 | 0.646975 |
| Gradient Boosting | 0.773987 | 0.717072 | 0.689528 | 0.699925 |
| AdaBoost | 0.782516 | 0.728192 | 0.712026 | 0.718984 |
| CatBoost | 0.761194 | 0.699333 | 0.683050 | 0.689800 |
| Extra Trees | 0.733475 | 0.658311 | 0.635421 | 0.643107 |
| XGBoost | 0.727079 | 0.656931 | 0.652337 | 0.654464 |
| Bagging Classifier | 0.739872 | 0.667861 | 0.644588 | 0.652669 |
| Stacking Classifier | 0.752665 | 0.687412 | 0.670036 | 0.676997 |

## Conclusion
Among the models evaluated, **AdaBoost** achieved the highest accuracy of 78.25%. This model is the best performer due to its ability to adaptively adjust the weights of misclassified instances, leading to improved performance in the prediction task. AdaBoost’s strong performance across multiple metrics, including precision, recall, and F1 score, highlights its effectiveness in handling this classification problem.

## Signature
- **Name:** Aditya D
- **Github:** [https://www.github.com/adi271001](https://www.github.com/adi271001)
- **LinkedIn:** [https://www.linkedin.com/in/aditya-d-23453a179/](https://www.linkedin.com/in/aditya-d-23453a179/)
- **Topmate:** [https://topmate.io/aditya_d/](https://topmate.io/aditya_d/)
- **Twitter:** [https://x.com/ADITYAD29257528](https://x.com/ADITYAD29257528)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Model,Accuracy,Precision,Recall,F1 Score
Random Forest,0.7377398720682303,0.6640658631080499,0.6383707737690039,0.6467789636106468
Support Vector Classifier,0.7739872068230277,0.7218562147064181,0.6658157476741547,0.6812224274135632
Logistic Regression,0.7633262260127932,0.7024064171122995,0.6631835715906512,0.6754932211313699
Decision Tree,0.7142857142857143,0.6414804016844833,0.6387451781257091,0.6400407807917888
K-Nearest Neighbors,0.7356076759061834,0.6616833508956796,0.639267075107783,0.6469745532245532
Gradient Boosting,0.7739872068230277,0.7170720931441343,0.68952802359882,0.6999251533149837
AdaBoost,0.7825159914712153,0.7281918530819576,0.712026321760835,0.7189835048639504
CatBoost,0.7611940298507462,0.6993328391401038,0.6830496936691627,0.6898001606273917
Extra Trees,0.7505330490405118,0.6828282828282828,0.6519627864760609,0.6620309064368906
XGBoost,0.7270788912579957,0.6569308087891539,0.6523371908327661,0.6544642446010038
Bagging Classifier,0.7526652452025586,0.6860840108401084,0.6558089403222147,0.6659051830017195
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Model,Accuracy,Precision,Recall,F1 Score
Random Forest,0.7377398720682303,0.6640658631080499,0.6383707737690039,0.6467789636106468
Support Vector Classifier,0.7739872068230277,0.7218562147064181,0.6658157476741547,0.6812224274135632
Logistic Regression,0.7633262260127932,0.7024064171122995,0.6631835715906512,0.6754932211313699
Decision Tree,0.7142857142857143,0.6414804016844833,0.6387451781257091,0.6400407807917888
K-Nearest Neighbors,0.7356076759061834,0.6616833508956796,0.639267075107783,0.6469745532245532
Gradient Boosting,0.7739872068230277,0.7170720931441343,0.68952802359882,0.6999251533149837
AdaBoost,0.7825159914712153,0.7281918530819576,0.712026321760835,0.7189835048639504
CatBoost,0.7611940298507462,0.6993328391401038,0.6830496936691627,0.6898001606273917
Extra Trees,0.7505330490405118,0.6828282828282828,0.6519627864760609,0.6620309064368906
XGBoost,0.7270788912579957,0.6569308087891539,0.6523371908327661,0.6544642446010038
Bagging Classifier,0.7526652452025586,0.6860840108401084,0.6558089403222147,0.6659051830017195
Stacking Classifier,0.7569296375266524,0.6924390243902439,0.6611300204220558,0.671665438467207
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pandas==2.0.3
numpy==1.24.3
seaborn==0.11.2
matplotlib==3.7.1
scikit-learn==1.2.2
scipy==1.10.1
xgboost==1.7.6
catboost==1.2
mlxtend==0.22.0
Loading