분류 전체보기
-
[자료구조] 힙(Heap)개발/자료구조와 알고리즘 2022. 2. 5. 01:52
Heap 최대값, 혹은 최소값을 빠르게 찾기 위한 자료구조이며, 일반적으로 완전이진트리를 활용하여 구현하고, 우선순위 큐에 사용한다. 우선순위 큐란 FIFO구조의 일반적인 큐가 아니라, 각 데이터에 우선순위가 있어서, 우선순위가 높은 데이터가 먼저 POP되는 자료형태이다. 예를 들어 운영체제에서 프로그램들을 스케쥴링 할 때, FIFO방식으로 프로세스를 처리한다면, 처리시간이 긴 프로세스를 처리하는 동안 처리시간이 짧은 프로세스는 대기시간이 길어지게 되고, 이는 비효율적이다. 따라서 처리시간이 짧은 프로세스에 높은 우선순위를 두어 이를 먼저 처리하고, 처리시간이 긴 프로세스를 나중에 처리하려고 할 때 우선순위 큐를 사용할 수 있다. Heap의 구조 힙은 두가지로 나뉜다. 루트노드가 가장 작은 값인 Min ..
-
[책 리뷰] 데이터 과학자의 일 - 박준석 외 4리뷰/책 리뷰 2022. 2. 3. 01:25
데이터 과학자의 일 - 박준석, 손승우, 우지환, 이은조, 박영호 서로 다른 도메인에서 일하는 데이터 과학자들이 구체적으로 어떤 일을 하는지 적혀있는 책 문장 머신러닝은 특정 문제를 해결하기 위한 수단일 뿐이며, 머신러닝이 목적이 되어 끼워 맞추는 식으로 활용할 경우 오히려 안 좋은 결과를 초래할 수 있다. 머신러닝 프로젝트의 첫 단계는 목표를 정확히 파악하고, 모델 성능과 제품의 평가 지표를 설정하는 것에 있다. 온라인 서비스에 머신러닝을 도입하기 전후의 평가 지표를 어떻게 비교할 수 있을까? 보통 임의로 뽑은 유저들에게 일정기간 동안 A/B테스트를 실행한다. 데이터 분석가라고 하면 뭔가 고도의 통계이론을 이용해 가설 검정을 하거나 머신러닝을 이용한 예측 분석을 할 것이라 기대하고 이 분야에 들어온 사..
-
[자료구조] 이진 탐색 트리(Binary Search Tree)개발/자료구조와 알고리즘 2022. 1. 31. 01:50
이진 탐색 트리 앞으로 글을 쓰겠지만 선형 자료 구조에서는 원하는 값을 탖는 방법이 여러가지가 있다. 가장 먼저 생각할 수 있는 것은 앞 혹은 뒤에서부터 하나씩 살펴보는 선형탐색이다. 그렇다면 트리형 자료구조에서는 원하는 값을 어떻게 찾을 수 있을까? 가장 기초적인 방법이 바로 이진탐색 트리이다. (물론 모두 살펴볼 수도 있을 것이다.) 먼저 그림부터 보자. 루트 노드에 값 K가 담겨있다고 생각하자. 그렇다면 이 루트 노드의 왼쪽에 있는 서브 트리에는 K보다 작은 값이, 오른쪽에는 K보다 큰 값만이 들어있는 트리를 생각할 수 있고, 이 모든 서브트리에도 같은 생각이 적용된다면 원하는 값을 찾기가 쉬울 것이다. 이를 이진 탐색 트리라 한다. 실제 값을 넣어서 확인해보자 위 트리에서 13을 찾고 싶다고 생각..
-
[자료구조] 트리개발/자료구조와 알고리즘 2022. 1. 26. 02:03
트리 단순 선형 자료구조에서는 계층을 나타내기가 어렵다. 따라서 계층적 자료구조를 만들기 위해서 트리를 생각했다. 값을 가지는 노드와, 노드 사이를 잇는 간선으로 이루어져 있으며, 부모 - 자식 관계를 가진다. 트리를 그림으로 나타내면 위와 같다. 여기서 A - B, C, D의 관계를 부모 - 자식 관계라 하며, 마찬가지로 B - E, F의 관계도 부모 - 자식 관계이다. 가장 위에 있는 노드인 A를 루트(Root)노드라 하고, 자식이 없는 노드들(E, F, C, G)를 리프(Leaf)노드라 한다. 위의 트리는 3개의 층으로 되어있는데, 이를 높이가 3인 트리라고 한다. 트리는 서브트리로 나눌 수 있다. 이렇게 나누면 B와 D는 각각의 서브트리에서 루트노드가 된다. 트리의 자식이 연결되어 싸이클이 생기면..
-
[자료구조] LinkedList개발/자료구조와 알고리즘 2022. 1. 24. 01:07
LinkedList 대표적으로 C같은 경우 선형 자료구조인 Array가 있다. 그러나 이 배열의 경우는 시작부터 크기를 지정해주어야하고, 새로운 요소를 추가하거나, 배열 안의 요소를 제거할 때 비용(시간)이 많이 든다. 이를 개선하기 위해서 구조체를 만드는데, 이 구조체에는 하나의 요소 값과, 다음 구조체의 정보를 가진다. 이 구조체를 연결하여 만드는 리스트가 바로 LinkedList이다. LinkedList를 사용함으로써 크기가 유동적인 자료형을 만들 수 있고, 삽입, 제거에 시간이 적게 든다. 특히 값을 탐색하다가 데이터를 추가, 제거하기에 용이하다. 단점으로는 index가 없어 값을 앞에서부터 탐색해야 한다. -> 탐색에 시간이 많이 소요된다. 종류로는 단순(Single), 양방향(Double)이 ..
-
[책 리뷰] 팩트풀니스 - 한스 로슬링리뷰/책 리뷰 2022. 1. 23. 03:26
팩트풀니스 - 한스 로슬링 세상이 얼마나 바뀌었는지, 우리의 인식이 얼마나 예전에 머물러 있으며, 얼마나 편협한 지에 대해서 보여준다. 거기에 더해서 이러한 우리의 인식은 본능 때문이라고 말하며 총 10개의 본능을 예로 들어 우리의 인식을 설명하며 깨달음(?)을 주는 책. 여러가지 수치를 들어 설명하여 신뢰감을 준다. 문장 브라질에서는 상위 10%의 부유층이 전체 소득의 41%를 벌어들인다. 언론은 보통 상위 10%가 아니라 0.1%에 해당하는 슈퍼리치와 그들이 소유한 것들의 모습을 보여주며 대중의 인식을 부채질한다. 그러나 그 반대편의 수치도 그리 낮지는 않다. 브라질 사람 대부분은 극빈층에서 탈출했다. → 대부분의 인식을 가장 먼저 부숴주는 부분 일반화 본능 억제 - 사람들은 바보가 아니라고 생각하라..
-
[Kaggle] Titanic - Machine Learning from Disaster개발/머신러닝-딥러닝 2022. 1. 23. 02:29
이제 케글도 정리하고 싶어서 시작한다. 첫번째 글은 모두가 아는 타이타닉 생존자 예측. 0. 목표 데이터는 타이타닉호의 승객들에 대한 정보와 생존 유무가 있으며, TrainSet의 생존 유무를 label로 하여 학습한 후에, TestSet의 승객정보를 통해 생존 유무를 예측하는 것이 목표이다. 1. 전체 데이터 확인 총 12개의 feature가 있고, 이 중 Survived를 제외한 나머지 정보들을 이용해 Survived를 예측하는 것이 목표이다. 이 데이터에는 대부분 결측치가 없으나, 선실을 나타내는 Cabin에 결측이가 많이 있다. 총 891개의 데이터 중 687개의 결측치는 굉장히 크다. 또 Age에도 꽤 많은 결측값들이 있다. 숫자 데이터간 상관계수 확인. Survived와 상관계수가 높은 데이터..
-
[책 리뷰] 군주론 - 마키아 밸리리뷰/책 리뷰 2022. 1. 22. 00:26
군주론 - 마키아 밸리 진정한 군주란 어떠한 행동을 해야하며 어떠한 마음가짐을 가져야하는가에 대한 마키아벨리의 직언을 적어 놓은 책. 이 책은 여러가지 국가의 유형을 설명하는 것부터 시작해 군대의 유형, 군주가 가져야할 마음가짐, 신하를 어떻게 부리는가 순서로 진행된다. 문장 군주는 국내에서 사려깊은 자들을 선발하여 그들에게만 진실을 말할 수 있는 자유를 주되 그것도 군주가 묻는 문제에 한할 뿐, 다른 일에 대해서는 허용치 말아야한다. 군주는 그가 선임한 사람 외에는 다른 어떤 사람의 의견도 듣지 말아야하며, 군주 스스로가 결정한 것은 실행하되 그 결단은 끝까지 관철시켜야 한다. → 주관이 뚜렷하고 그를 밀고 나갈 수 있는 역량이 있어야한다. 역량이 부족하다면 단번에 망할 것 개인에게 적용해본다면, 자존..