우리는 주어진 데이터를 regression을 통해 여러가지를 도출해 낼 수 있다.
그럼.
과연 데이터를 어떻게 python에서
- 표현하고,
- 저장하고,
- 계산 할 수 있을 것인가.
Matrix (행렬)
고등학교 수학에서 부터 계속 써온 행렬이다 !
행렬의 형태가 헷갈릴 때에는
행 : 층
열 : 순서
이렇게 기억하면 편하다 !
행렬의 곱셈 (Matrix multiplication)
행렬의 곱셈에서는 어떻게 곱해지는가 보다 더 먼저 생각해야하는 것은 결과물의 shape(차원)이다.
곱셈에서는
앞에 있는 열과 뒤에있는 행의 크기가 같아야만 연산이 가능하다.!!
예를들어 > (4 , 4) X (4 , 2) => (4 , 2)
중간에 같은 4가 있으면 그 4를 생략.
앞 행과 뒷 열을 괄호안에 써주면 곱셈 후 차원의 크기를 직관적으로 알 수 있다. !!
만약 > (4 , 3) X (4, 3)
다르다면 연산을 하였을 때.. 오류가 뜬다!!
Transpose (전치 행렬)
매트릭스의 전치는, 행과 열을 바꾸는 것을 의미합니다. 이는 일반적으로 매트릭스 우측 상단에
혹은 tick 마크를 통해 표기 됩니다:
이를 읽는 방법은 B transpose 혹은 B prime.
실제 계산은, 대각선 부분의 구성요소를 고정시키고 이를 기준으로 나머지 구성요소들을 뒤집는다 라고 생각하면 된다.
Inverse (역행렬)
ad - bc = 0 인 경우에는 역행렬이 존재하지 않는다!!
Identity (단위 매트릭스)
- Diagonal 매트릭스 중에서, 모든 값이 1인 경우입니다. 임의의 정사각 매트릭스에 단위 행렬을 곱하면, 그 결과값은 원본 정사각 매트릭스로 나온다.
- 반대로 임의의 매트릭스에 대해서 곱했을때 단위 매트릭스가 나오게 하는 매트릭스를 역행렬 (Inverse)라고 부른다.
,
'Data analysis > Data Process' 카테고리의 다른 글
Simple Regression/ 선형회귀(Linear Regression) (0) | 2021.02.14 |
---|---|
Matrix Calculation(Matrix multiplication)/행렬의 연산 Python으로 구현하기 (0) | 2021.01.13 |
Hypothesis Test(가설검정) / Python 코드구현/random.seed()/난수 (0) | 2021.01.11 |
Hypothesis Test(가설검정) / 기술통계 vs 추론통계 / python 파이썬! (0) | 2021.01.11 |
Colab환경에서 데이터 분석 진행하기! (데이터 불러오기) (0) | 2021.01.04 |