<jupyter_start><jupyter_text>Example of genre predictor results with unseen artist data<jupyter_code># importing necessary pieces from main file, along with data viz components 

import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline

from main import get_discography, predictor, training_data, genres
import setup<jupyter_output><empty_output><jupyter_text>Quick exploratory piece, is there enough variance in audio feature attributes from each genre grouping?Quick boxplots show that there seems to be enough variance between groups to allow for classification to work<jupyter_code>def attribute_boxplt(attribute):
    x = attribute
    
    for key in genres:
        print(genres[key])
        df = training_data[training_data['genre'] == genres[key]]
        ranks = df.groupby('artist')[x].mean().sort_values(ascending=False).index
        sns.boxplot(data=df, x=x, y='artist', orient='h', order=ranks)
        plt.show()

attribute_boxplt('energy')
attribute_boxplt('tempo')<jupyter_output>rock<jupyter_text>Testing through new artists shows that decision trees are the most reliable classification model<jupyter_code>artists = [('<NAME>', 0),
            ('<NAME>', 1),
            ('<NAME>', 2),
            ('hieroglyphics', 3),
            ('<NAME>', 4),
            ('nirvana', 0),
            ('<NAME>', 3),
            ('<NAME>', 1)]

predictor(artists, 'knn')
print('\n')
predictor(artists, 'lr')
print('\n')
predictor(artists, 'rfr')
print('\n')
predictor(artists, 'xgb')
print('\n')
predictor(artists, 'nn')<jupyter_output>Model Type: K-Neighbors Classifier
------------------------------
                            actual genre predicted genre percent
<NAME> & The Blackhearts         rock            rock    0.68
<NAME>                          jazz            jazz    0.57
<NAME>               blues            jazz    0.42
Hieroglyphics                    hip hop         hip hop    0.84
<NAME>                    downtempo            rock    0.56
Nirvana                             rock            rock    0.61
<NAME>                  hip hop            jazz    0.37
<NAME>                       jazz            jazz    0.38


Model Type: Logistic Regression
------------------------------
                            actual genre predicted genre percent
<NAME> & The Blackhearts         rock            rock    0.64
<NAME>                          jazz            jazz    0.68
<NAME>               blues           blues    0.77
Hieroglyphics           [...]
{'fraction_non_alphanumeric': 0.12, 'fraction_numerical': 0.0164, 'mean_word_length': 1.9149184149184149, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '418018', 'license': 'MIT', 'n_tokens_mistral': 719, 'n_tokens_neox': 695, 'n_words': 203, 'path': 'Spotify Genre Classifier/Example.ipynb', 'repo_name': 'Gabriel-Reyes/spotify_genre_classifier', 'size': '2601'}