Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import pandas as pd import numpy as np from sklearn.model_selection import train_test_split mush_df = pd.read_csv('assets/mushrooms.csv') mush_df2 = pd.get_dummies(mush_df) X_mush = mush_df2.iloc[:,2:] y_mush = mush_df2.iloc[:,1] X_train2,
import pandas as pd import numpy as np from sklearn.model_selection import train_test_split
mush_df = pd.read_csv('assets/mushrooms.csv') mush_df2 = pd.get_dummies(mush_df)
X_mush = mush_df2.iloc[:,2:] y_mush = mush_df2.iloc[:,1]
X_train2, X_test2, y_train2, y_test2 = train_test_split(X_mush, y_mush, random_state=0)
*this is my code def answer_six():
from sklearn.svm import SVC
from sklearn.model_selection import validation_curve
param_range = np.logspace(-4,1,6)
train_scores, test_scores = validation_curve(SVC(random_state=0),X_test2,y_test2,param_name='gamma',param_range=param_range)
return np.array(list(map(np.mean,train_scores))),np.array(list(map(np.mean,test_scores)))
answer_six()
CAN SOMEONE HELP ME TO SOLVE MY PROBLEM?? I KEEP GETTING THIS FEEDBACK!!
For this question, use the function in sklearn.model_selection to determine training and test scores for a Support Vector Classifier ( SVC ) with varying parameter values. Create an with default parameters (i.e. and . Recall that the kernel width of the RBF kernel is controlled using the parameter. Explore the effect of classifier accuracy by using the function to find the training and test scores for 6 values of from to (i.e. For each level of will use 3 -fold cross validation (use as parameters for 1, returning two 63 ( 6 levels of gamma x 3 fits per level) arrays of the scores for the training and test sets in each fold. Find the mean score across the five models for each level of for both arrays, creating two arrays of length 6 , and return a tuple with the two arrays. e.g. if one of your array of scores is array([[0.5,0.4,0.6],[0.7,0.8,0.7],[0.9,0.8,0.8],[0.8,0.7,0.8],[0.7,0.6,0.6],[0.4,0.6,0.5]]) it should then become array([0.5,0.73333333,0.83333333,0.76666667,0.63333333,0.5]) This function should return a tuple of numpy arrays where each array in the tuple has shape (6,). Out [13]: (array ([0.83370474,0.93943926,0.99101417,1. array ([0.83160092,0.93747958,0.9901502,1. , 0.99852459, 0.52240229])) In [14]: Grade cell: Score: 0.0/2.0 (Top) You have failed this test due to an error. The traceback has been removed because it may conta in hidden tests. This is the exception that was thrown: AssertionError: Q6: The training_scores has inc orrect value at index 0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started