text_plain_output_1.png
from sklearn import svm

from sklearn.model_selection import train_test_split

from sklearn.preprocessing import scale

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

table = pd.read_csv('../input/genre-dataset/genre_dataset.txt')
table = table[table.genre.str.contains('jazz and blues') | table.genre.str.contains('soul and reggae')]
for i in range(4, len(table.columns)):
    col = table.iloc[:, [i]].values
    table.iloc[:, [i]] = scale(col)

le = LabelEncoder()
table['genre'] = le.fit_transform(table[['genre']])

X_train, X_test = train_test_split(table, test_size=0.2)
x_train = X_train.iloc[:, 4:].values
y_train = X_train.iloc[:, 0]
x_test = X_test.iloc[:, 4:].values
y_test = X_test.iloc[:, 0]

cls = svm.SVC(kernel='poly')

smallgrid = {'degree': [2, 3, 4, 5, 6, 7, 8, 9, 10]}
grid1 = GridSearchCV(cls, smallgrid)
grid1.fit(x_train, y_train)
grid_result1 = pd.DataFrame(grid1.cv_results_)
plt = grid_result1.plot(x='param_degree', y='mean_test_score')
plt = plt.set_ylabel('Precisión')