728x90
import numpy as np
numpy 를 np 로 불러온다.
array
test = np.array([1,2,3],[4,5,6])
[1,2,3]
[4,5,6]
형태의 행렬 만들어짐
reshape
test1 = test.reshape(3,2)
[1,2]
[3,4]
[5,6]
과 같이 바뀜 행렬의 모양을 바꿔주는 함수
concatenate
test1 = np.array([[1, 2], [3, 4]])
test2 = np.array([[5, 6], [7, 8]])
result1 = numpy.concatenate((A, B), axis = 0)
result2 = numpy.concatenate((A, B), axis = 1)
concatenate는 두 개의 array를 합치는 함수이다.
axis=0 인 경우 세로로 합쳐지고 axis=1 인 경우 가로로 합쳐진다.
result1 :
[1,2]
[3,4]
[5,6]
[7,8]
result2:
[1,2,5,6]
[3,4,7,8]
728x90
'인공지능 > 데이터 분석' 카테고리의 다른 글
[사이킷런] GridSearchCV : 교차 검증 + 하이퍼 파라미터 튜닝 (0) | 2021.08.16 |
---|---|
[사이킷런] 과적합의 문제와 교차 검증 모델(KFold, StratifiedKFold, cross_val_score) (0) | 2021.08.16 |
[사이킷런] train_test_split, DecisionTreeClassifier 체험 (0) | 2021.08.16 |
[numpy] transpose, linalg.inv, dot (0) | 2020.10.04 |
[pandas] 데이터를 같은 값끼리 묶고 column 별로 다른 함수 실행하기 (0) | 2020.10.03 |