Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I want to perform the MinnMax scaler for cross validation before modeling what is the code that I should put to implement it In [8]:
I want to perform the MinnMax scaler for cross validation before modeling what is the code that I should put to implement it
In [8]: from imblearn. under_sampling import RandomUnderSampler x2=df.drop('Class', axis=1) y2=df[ 'Class'] \[ \begin{array}{l}\text { undersample = RandomUnderSampler(sampling_strategy='majority') } \\ x 2, y 2=\text { undersample.fit_resample( } x, y)\end{array} \] In [16]: M kf2= RepeatedStratifiedKFold(n_splits =5, n_repeats=2e, random_state=101) In [ ]: M \# Feature scaling scaler = MinMaxscaler() \# \#???????????????????????? In [11]: M DT Random oversampler dt = DecisionTreeclassifier(random_state=101) scores=cross_validate(dt, x2,y2,cv=k+2, scoring [ [ accuracy', 'precision', 'recall']) print( 'Accuracy:', scores['test, accuracy'], mean())) print('Precision: ', scores['test_precision'], mean()) print('Recal1:', scores['test_reca11'], mean()) Step 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