필터 지우기
필터 지우기

How can I Normalize test data by applying the mean and Standard deviation of the training data?

조회 수: 7 (최근 30일)
I have spam data (training data and Test Data). This file contains a training set of size 3065 and a test set of size 1536. I standardized the features so that they have zero mean and unit variance i.e. calculated the mean and standard deviation of the training data. Now I have to apply those same parameters to normalize the test data without recalculating the mean and standard deviation of the test data and Im stuck on this part. Can you please help.

답변 (3개)

taruv harshita priya
taruv harshita priya 2021년 4월 20일
Matlab has an inbuilt function normalize
For the training data
[Normalized_training_data, c,s]= normalize(training data)
For testing data
Normalized_testing_data= normalize(testing data, 'center', c, 'scale', s)
I hope this helps!!!
Enjoy coding!!!
  댓글 수: 1
Steven Lord
Steven Lord 2021년 4월 20일
Note that while the normalize function was introduced prior to release R2021a, the ability to center and scale simultaneously via the 'center' and 'scale' methods and to return the centering and scaling parameters was introduced in that release.

댓글을 달려면 로그인하십시오.


Star Strider
Star Strider 2014년 4월 13일
Is the zscore function what you are looking for?

Image Analyst
Image Analyst 2014년 4월 13일
Do you mean
testData = (testData - trainingMean) / trainingStdDev;
???

카테고리

Help CenterFile Exchange에서 Hypothesis Tests에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by