필터 지우기
필터 지우기

Data Analysis - Matlab Code

조회 수: 1 (최근 30일)
Mustafa Furkan SAHIN
Mustafa Furkan SAHIN 2022년 12월 11일
댓글: Mustafa Furkan SAHIN 2022년 12월 13일
I have a dataset(145 rows, 32 columns without id and attributes https://archive.ics.uci.edu/ml/datasets/Higher+Education+Students+Performance+Evaluation+Dataset ). I can read it in matlab with code. But I can't find the centered data matrix. I can find centered data matrix in another example.
D = randi([-5, 5] , 4,2] generate 8 numbers from -5 to 5 and I use size() ones() etc.
onesd = ones(size(D,1)1)
meand= mean(D)
D=onesd*meand then i find the centered data matrix
how can i write this dataset i have with centered data matrix
  댓글 수: 1
Mustafa Furkan SAHIN
Mustafa Furkan SAHIN 2022년 12월 11일
clc
clear
dataset = xlsread('DATA.csv','DATA');
[m,n] = size(dataset)
Mean = mean(dataset)
Size = size(dataset, 1)
dataset2 = repmat(Mean,Size,1)
CenterMatrix = dataset - dataset2
Is this my code correct? Is such use acceptable?

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

채택된 답변

Torsten
Torsten 2022년 12월 11일
D = randi([-5, 5],4,2)
D = 4×2
4 -1 -2 -5 -4 -1 -2 -3
Cn = eye(size(D,1))-1/size(D,1)*ones(size(D,1))
Cn = 4×4
0.7500 -0.2500 -0.2500 -0.2500 -0.2500 0.7500 -0.2500 -0.2500 -0.2500 -0.2500 0.7500 -0.2500 -0.2500 -0.2500 -0.2500 0.7500
D_centered = Cn*D
D_centered = 4×2
5.0000 1.5000 -1.0000 -2.5000 -3.0000 1.5000 -1.0000 -0.5000
mean(D_centered,1)
ans = 1×2
0 0
  댓글 수: 10
Torsten
Torsten 2022년 12월 13일
Yes, it's correct. See above.
Mustafa Furkan SAHIN
Mustafa Furkan SAHIN 2022년 12월 13일
That's great. Thanks for taking the time,Torsten

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

추가 답변 (1개)

Steven Lord
Steven Lord 2022년 12월 12일
I would use the normalize function or the Normalize Data task in Live Editor.
  댓글 수: 2
Torsten
Torsten 2022년 12월 12일
It's only asked for mean 0, not standard deviation 1. Is this also possible with "normalize" ?
Steven Lord
Steven Lord 2022년 12월 12일
The normalize function can center without scaling:
format longg
x = rand(1, 10);
n = normalize(x, 'center');
[mean(n), std(n)]
ans = 1×2
-1.11022302462516e-17 0.266647564148699
scale without centering:
s = normalize(x, 'scale');
[mean(s), std(s)]
ans = 1×2
2.19316158923735 1
or both center and scale.
z = normalize(x); % 'zscore' is the default
[mean(z), std(z)]
ans = 1×2
-5.55111512312578e-18 1
There are other normalization options as well.

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

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by