Challenge Solution Review
In this lesson, we explain the solution to the last challenge lesson.
import pandas as pdfrom sklearn.model_selection import train_test_splitfrom sklearn.svm import SVCimport sklearn.metrics as metricsdf = pd.read_csv("./nonlinear.csv", sep=",", header=0)y = df.pop("target").valuesX = dftrain_x, test_x, train_y, test_y = train_test_split(X,y,test_size=0.2,random_state=42)svc = SVC(kernel='rbf')svc.fit(train_x, train_y)pred_y = svc.predict(test_x)f1 = metrics.f1_score(test_y, pred_y)print("The F1 score is {}.".format(f1))
Get hands-on with 1400+ tech skills courses.