This project predicts the education level of political candidates using a Random Forest Classifier. It analyzes various candidate attributes like criminal record, total assets, party affiliation, and state to make predictions.
Ensure you have the following installed:
- Python 3.x
- Required Python libraries: pandas, matplotlib, seaborn, scikit-learn
train.csv: Training dataset containing information about political candidates.test.csv: Test dataset for predicting education levels.my_submission_rf_improved_2.csv: CSV file with predicted education levels for the test dataset.
-
Data Preprocessing:
- Load and clean the training and test datasets.
- Convert 'Total Assets' values to numeric format for analysis.
- Perform basic data exploration and visualization to understand the data.
-
Feature Engineering:
- Create new features based on candidate names and constituency preferences to improve model performance.
-
Data Encoding:
- Encode categorical variables into numeric format using LabelEncoder for model compatibility.
-
Model Training:
- Split the training data into training and validation sets for model evaluation.
- Train a Random Forest Classifier on the training data to predict education levels.
-
Prediction:
- Use the trained model to make predictions on the test set.
- Convert numeric predictions back to the original education levels for interpretation.
-
Output:
- Save the predictions to a CSV file for further analysis and submission.
- Clone the Repository git clone <repository_url>
- Install Dependencies: pip install pandas matplotlib seaborn scikit-learn
- Run the Code: python3 main.py
- View Results:
- After running the code, check the generated
my_submission_rf_improved_2.csvfile for the predicted education levels.
- Ensure that the training and test datasets are in the same directory as the script.
- Adjust hyperparameters of the Random Forest Classifier or try different machine learning models for experimentation.
- Explore additional feature engineering techniques for potentially improving model performance.