Machine Learning
-
[numpy] axis, rank 이해. (n,)와(n,1)의 차이. keepdimsMachine Learning/numpy & pandas & maplotlib 2023. 9. 5. 19:35
이전 글에서 선형대수 관련 강의 영상을 정리했었는데, 기본 용어들이 헷갈려서 정리해봤다. * Rank (=basis의 개수) 더보기 "랭크(Rank)"는 행렬의 중요한 개념 중 하나입니다. 랭크는 주어진 행렬의 열 벡터(또는 행 벡터)들 중 독립적인 벡터의 최대 개수를 나타내며, 이 개수는 해당 행렬의 열(또는 행) 공간의 차원을 나타냅니다. 독립적인 벡터의 최대 개수: 랭크는 행렬 내의 열 벡터(또는 행 벡터) 중 서로 독립적인 벡터의 최대 개수를 나타냅니다. 벡터가 서로 독립적이라는 것은 어떤 한 벡터를 다른 벡터들의 선형 조합으로 나타낼 수 없다는 것을 의미합니다. 열 공간의 차원: 랭크는 해당 행렬의 열 벡터가 구성하는 열 공간(column space)의 차원을 나타냅니다. 열 공간은 벡터들이 생..
-
[Pandas#1] Pandas 기초Machine Learning/numpy & pandas & maplotlib 2023. 8. 5. 20:35
* pandas 표 형식의 데이터나 다양한 형태의 데이터를 다루는 데 초점을 맞춰 설계된 라이브러리. pandas는 배열 기반의 함수를 제공하는 등 numpy의 배열 기반 계산 스타일을 많이 차용했다.(numpy는 단일 산술 배열 데이터를 다루는 데 특화되어 있다.) pandas는 Series와 DataFrame 크게 두 가지 자료구조를 갖는다. * import pandas as pd 라이브러리 호출. 관례적으로 pd로 이름을 지음. # 데이터 불러오기 예시 data_url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data' #Data URL # data_url = './housing.data' #Data U..
-
[NumPy] np.where()Machine Learning/numpy & pandas & maplotlib 2023. 8. 4. 23:34
* np.where() NumPy 라이브러리에서 제공되는 조건에 따라 배열의 요소를 선택적으로 변경하거나 조건을 만족하는 요소의 인덱스를 반환하는 함수. 이 함수는 특정 조건을 검사하고, 해당 조건을 만족하는 요소를 선택적으로 처리하는데 유용. import numpy as np # np.where() 함수의 예시 arr = np.array([1, 5, 2, 7, 4, 9]) # 조건을 만족하는 요소의 인덱스를 반환 indices = np.where(arr > 4) print(indices) # 출력: (array([1, 3, 5]),) # 조건을 만족하는 요소를 다른 값으로 변경 new_arr = np.where(arr > 4, 0, arr)# 4보다 크면 0으로 변경하고 아닌 값은 그대로. print(..
-
[NumPy] np.random.rand(), RandomState(), randn(), randint(), random(), normal()정리Machine Learning/numpy & pandas & maplotlib 2023. 8. 4. 23:13
1. np.random.rand() [0,1) 사이의 (uniform distribution)값을 램덤하게 반환 import numpy as np np.random.rand()# 하나의 값 생성 np.random.rand(4)# 4행의 랜덤 값 생성 np.random.rand(5,2)# 5행 2열의 랜덤 값 생성 ------------------------- 0.5026802324958345 array([0.58979257, 0.72740942, 0.58333496, 0.74748877]) array([[0.9106447 , 0.68091985], [0.29337807, 0.01162554], [0.18417443, 0.40650219], [0.52841246, 0.78908411], [0.5049810..
-
[NumPy#1] 넘파이란? dtype, astype(), itemsize, size, shapeMachine Learning/numpy & pandas & maplotlib 2023. 8. 4. 01:39
* 넘파이(NumPy)란? 넘파이(NumPy)는 파이썬의 다차원 배열을 다루기 위한 라이브러리이다. 2005년 Travis Oliphant이 Numarray을 Numeric에 합쳐 만들었다. 넘파이 배열 데이터 구조를 ndarray라고도 부른다. n-dimensional array의 준말이다. 넘파이는 C언어로 작성되었고, 넘파이의 속도가 빠른 이유는 연속된 메모리 블럭을 갖기 때문에 CPU가 빠르게 읽을 수 있다. 반면에, Python의 리스트는 랜덤한 메모리 블럭의 객체를 지정하는 포인터 개념이기 때문에 CPU가 빠르게 캐치하지 못해서 속도가 느린 것이다. 넘파이 배열은 고정된 사이즈를 갖고, homogenous하다. 원소들이 반드시 같은 타입이어야 한다. 파이썬 리스트에서 원소를 추가하거나 삭제하는..
-
[cs231n_review#Lecture 3-1] loss functionsMachine Learning/cs231n 2023. 6. 18. 17:01
there exists some parameter matrix, W which will take this long column vector representing the image pixels, and convert this and give you 10 numbers giving scores for each of the 10 classes in the case of CIFAR-10. Where we kind of had this interpretation where larger values of those scores, so a larger value for the cat class means the classifier thinks that the cat is more likely for that ima..
-
[cs231n_review#Lecture 2-5] Linear Classifier from viewpoint of the template matching approachMachine Learning/cs231n 2023. 6. 17. 18:40
In linear classification, we're going to take a bit of a different approach from k-nearest neighbor. So, the linear classifier is one of the simplest examples of what we call a parametric model. we usually write as X for our input data, and also a set of parameters, or weights, which is usually called W, also sometimes theta, depending on the literature. So, in the k-nearest neighbor setup there..
-
[cs231n_review#Lecture 2-4] Cross-ValidationMachine Learning/cs231n 2023. 6. 16. 19:21
idea # 4 Cross-validation Where your algorithm is able to see the labels of the training set, but for the validation set, your algorithm doesn't have direct access to the labels. We only use the labels of the validation set to check how well our algorithm is doing. (Cross-Validation can alleviates over-fitting problem) these things like Euclidean distance, or L1 distance, are really not a very g..