This project aims to classify music genres using various machine learning algorithms. The dataset consists of features extracted from music tracks, and the task is to predict the genre of each track.
Code Files
project_main.py
: Trains and evaluates each machine learning model.graphing.py
: Generates bar graphs to visualize the accuracies of the models.decisiontrees_466.py
: Contains the implementation of the decision tree classifier.knn_466.py
: Contains the implementation of the K-nearest neighbors classifier.fnn_466.py
: Contains the implementation of the feedforward neural network classifier.df_code.py
: Splits the dataset into training and testing sets.Dataset Preprocessing Code
: Combines the two music genre datasets
CSV Files
music_genre.csv
: from Prediction of Music Genre Datasetmusic_genre_spot.csv
: from Spotify Tracks Grenre Datasetmusic_genre_466.csv
: Full combined datasetmusic_shortened_features_466.csv
: Full combined dataset with less featuresmusic_shortened_genre_466.csv
: Less classes datasetmusic_shorted_features+genre_466.csv
: Less classes dataset with less features
To run the project, these dependencies are needed:
- Python 3.x
- pandas
- scikit-learn
- matplotlib
- numpy
- torch
- (All the cleaned csv files are already included too) Clean the datasets using the Google Colab Code. Download
music_genre.csv
andmusic_genre_spot.csv
into your Google Drive. Ensure that the path names in the code are changed to your directory. - Run
project_main.py
to train and evaluate the models. Copy the printed append statements intographing.py
. - Run
graphing.py
to generate visualizations of the model accuracies. Make sure to change the filepath names as needed.