<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by INSEO LEE on Medium]]></title>
        <description><![CDATA[Stories by INSEO LEE on Medium]]></description>
        <link>https://medium.com/@dlstj1506?source=rss-10405706ba8c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*OluVZSNJX1Bfzqsoc1yWWQ.jpeg</url>
            <title>Stories by INSEO LEE on Medium</title>
            <link>https://medium.com/@dlstj1506?source=rss-10405706ba8c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 18:37:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dlstj1506/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Artist_Classification_Project]]></title>
            <link>https://medium.com/@dlstj1506/artist-classification-project-0475f351ce47?source=rss-10405706ba8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/0475f351ce47</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[cv]]></category>
            <category><![CDATA[패스트캠퍼스]]></category>
            <dc:creator><![CDATA[INSEO LEE]]></dc:creator>
            <pubDate>Sat, 23 Dec 2023 01:10:42 GMT</pubDate>
            <atom:updated>2023-12-23T01:10:42.552Z</atom:updated>
            <content:encoded><![CDATA[<h4>월간 데이콘 예술 작품 화가 분류 AI 경진대회</h4><p>패스트캠퍼스 AI 부트캠프 6기의 트랙학습 팀 프로젝트 주제로 아래의 Closed 대회를 선정하였다.</p><p><a href="https://dacon.io/competitions/official/236006/overview/description">월간 데이콘 예술 작품 화가 분류 AI 경진대회</a></p><blockquote>대회소개</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*H7kAf21KeX48qpqDNCnVkA.png" /></figure><p>그림의 일부분(약1/4)을 보고 화가를 분류하는 AI모델 개발하기</p><blockquote>DATA</blockquote><p>Train Data : 5911장의 그림 데이터</p><p>Test Data : 12670장의 그림 일부분(약 1/4)</p><blockquote>진행 방식</blockquote><p>4명의 팀원이 <a href="https://dacon.io/competitions/official/236006/codeshare/6675?page=1&amp;dtype=recent">Dacon에서 제공하는 Baseline</a>을 기준으로 각각의 파트를 담당하여 실험을 진행하기로 하였다.</p><p><strong><em>목표 Score는 Private Score 0.8</em></strong>이며, <strong><em>Baseline Private Score는 0.5</em></strong>이다.</p><blockquote>Data Augmentation</blockquote><p>나는 이번 프로젝트에서 Data파트를 담당하였다. CV의 Data파트에서 중요한 부분은 무엇일까 고민을 해보았고 이미지 데이터를 직접적으로 변형 시켜 Model에 학습시키는 Data augmentation이 학습 성능에 가장 큰 영향을 끼친다고 생각하여 이 부분을 중점으로 몇 가지 실험을 진행해보았다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*pES1DwWVSjWoUYMlnF4fNg.png" /></figure><p>첫 번째 실험은 RandomResizedCrop이다. 학습 데이터는 전체 이미지를 제공 받으나, 테스트 데이터는 이미지에서 약 ¼ 정도를 제공 받기에 학습과 테스트의 환경이 다르다.</p><p>그래서 학습 데이터를 처음부터 약 1/4로 줄인 후, 학습하도록 하여 학습 환경과 테스트 환경을 동일하게 세팅해보았다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*45WGW8GXJ46d1RcrxXnJuw.png" /></figure><p>결과적으로 결과는 대 성공이었다. 하나의 조건만 바꾸어 주었는데 public, private Score 모두 약 0.2정도 상승하였다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*F8fOtDtHYN8vdpYEAY6r7g.png" /></figure><p>성능이 좋게 나왔던 RandomResizedCrop을 베이스로 여러가지 Augmentation들을 추가해보았으나 오히려 RRC 단독 적용보다 떨어지는 결과를 얻게 되었다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/331/0*YunsCIN1xfATFFfE" /><figcaption><a href="https://arxiv.org/pdf/1905.04899.pdf">https://arxiv.org/pdf/1905.04899.pdf</a></figcaption></figure><p>그러던 도중 CutMix 논문을 읽다 알게된 것이, 새로운 Augmentation이 적용되었을 때 Epoch 초반에는 오히려 성능이 안 좋게 나올 수 있다는 것이다. 이 전의 실험의 경우 Epoch를 10으로 고정하여 실험 했기에 충분히 가능성 있는 가설이었다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*zlPpjLXdkm6s33qTYTr86A.png" /></figure><p>그래서 Epoch 50으로 늘려 학습을 다시 진행한 결과 RRC단독 적용 상태에서는 Epoch 10 보다 성능이 떨어지고 Augmentation을 추가하여 학습한 경우 성능이 상승하는 것을 확인할 수 있었다.</p><blockquote>Augmentation Conclusion</blockquote><h4>1. Train Data와 Test Data를 최대한 유사하게 만들어 주어야 한다.</h4><p>학습 데이터와 테스트 데이터 간의 형태 차이가 있다는 것 자체가 이미 모델 성능 저하의 큰 원인이라고 생각을 한다. 이는 근본적으로 학습을 하는 이유가 테스트 데이터를 정확하게 맞추기 위함이기 때문이다.</p><h4>2. Augmentation이 복잡해지면 Epoch를 늘려보자</h4><p>일반적으로 Model이 커지면 Epoch을 늘려 학습을 많이 했을 때 성능이 잘 나온다고 알려져 있다. Augmentation이 Hard해지는 것도 Model이 커지는 것과 비슷한 원리가 아닐까? 추론해본다.</p><blockquote>Class Imbalance</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/0*mUfG_mEbA5XkKkVH" /></figure><p>Test Data에는 위 사진에서 보이는 것 처럼 Class Imbalance가 있었다. 그래서 팀에서 WeightedSampler, Focal Loss등을 이용해 보았지만 큰 성능 향상은 얻을 수 없었다. 그래서 우리가 얻은 결론은 아래와 같다.</p><blockquote><strong><em>“Class imbalance를 꼭 해결해야 할 필요가 없다!”</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*KWr9Gmtjz9BUOSOC2mE6wA.png" /></figure><p>우리가 제안하는 가설은 Train의 Class Imbalane가 Test Data에도 비슷하다는 것이다. 미술품이 소실되거나 하는 사유들로 인해 이는 충분히 발생할 수 있는 일이고 그것이 사실이라면 Imbalance한 Data를 그대로 학습하는 것이 더 좋은 성능을 보이는 것이 타당하다는 결론이다.</p><blockquote>Team Conclusion</blockquote><p>이번 프로젝트를 하면서 <strong><em>Data Augmentation을 통해 Train Data의 형태를 Test Data와 동일하게 맞추어 줄때 성능이 향상</em></strong>되는 것과 <strong><em>Train Data의 Imbalane를 해결하지 않았을 때 성능이 더 높아지는 경험</em></strong>을 통해</p><blockquote><strong><em>“Train환경과 Test환경을 최대한 유사하게 가져가는 것이 학습에 도움에 준다는 근본적인 상황”</em></strong></blockquote><p>을 직접 경험해볼 수 있어서 좋았다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0475f351ce47" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[15주차] 패스트 캠퍼스 AI 부트캠프 6기 학습일지]]></title>
            <link>https://medium.com/@dlstj1506/15%EC%A3%BC%EC%B0%A8-%ED%8C%A8%EC%8A%A4%ED%8A%B8-%EC%BA%A0%ED%8D%BC%EC%8A%A4-ai-%EB%B6%80%ED%8A%B8%EC%BA%A0%ED%94%84-6%EA%B8%B0-%ED%95%99%EC%8A%B5%EC%9D%BC%EC%A7%80-8449da10a5ab?source=rss-10405706ba8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/8449da10a5ab</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[국비지원]]></category>
            <category><![CDATA[부트캠프]]></category>
            <category><![CDATA[패스트캠퍼스]]></category>
            <dc:creator><![CDATA[INSEO LEE]]></dc:creator>
            <pubDate>Tue, 31 Oct 2023 07:55:38 GMT</pubDate>
            <atom:updated>2023-10-31T07:55:38.165Z</atom:updated>
            <content:encoded><![CDATA[<h4>패스트 캠퍼스 AI 부트캠프 6기</h4><h3>DL 프로젝트 기본 이론 : 딥러닝</h3><ul><li><a href="https://medium.com/@dlstj1506/deep-learning-basic-of-deep-learning-620bd3cda677">[Deep Learning] Basic of Deep Learning</a></li><li><a href="https://medium.com/@dlstj1506/deep-learning-cnn-f666767e988e">[Deep Learning] CNN</a></li><li><a href="https://medium.com/@dlstj1506/deep-learning-rnn-lstm-gru-e2cc1436b5c1">[Deep Learning] RNN, LSTM, GRU</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8449da10a5ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Deep Learning] RNN, LSTM, GRU]]></title>
            <link>https://medium.com/@dlstj1506/deep-learning-rnn-lstm-gru-e2cc1436b5c1?source=rss-10405706ba8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2cc1436b5c1</guid>
            <category><![CDATA[lstm]]></category>
            <category><![CDATA[gru]]></category>
            <category><![CDATA[rnn]]></category>
            <dc:creator><![CDATA[INSEO LEE]]></dc:creator>
            <pubDate>Tue, 31 Oct 2023 07:54:43 GMT</pubDate>
            <atom:updated>2023-10-31T07:54:43.173Z</atom:updated>
            <content:encoded><![CDATA[<h4>패스트 캠퍼스 AI 부트캠프 6기</h4><blockquote>RNN</blockquote><p>sequential data, time-sereis data 등을 처리할 수 있는 Neural Network</p><blockquote>RNN 구조</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9XSa9HAtH68qQw3za2wKUw.png" /></figure><p>기본적인 NN 구조처럼 <strong><em>Input Layer, Hidden Layer, Output Layer</em></strong>로 구성되어 있다. 하지만 이때<strong><em> Hidden Layer</em></strong>가 <strong><em>자신을 참고하는 Recurrent Layer</em></strong>인 것이 기존 NN과의 차이점이라고 할 수 있다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_JzgLESOSwaBqqwHPg0gTA.png" /><figcaption>cs231n, lecture note 10</figcaption></figure><p>위 그림은 RNN의 Hidden Layer를 확대한 이미지 이다. 하나의 <strong><em>인풋이 들어오면</em></strong> <strong><em>이전의 hidden state와 가중치</em></strong>, <strong><em>인풋과 가중치</em></strong> 그리고<strong><em> bias</em></strong>가 합쳐져서 <strong><em>새로운 hidden state를 생성</em></strong>하고 이것이 <strong><em>다음 인풋에 영향</em></strong>을 끼친다. <strong><em>이전의 값이 이후에 값에 영향</em></strong>을 주면서 계속해서 자신을 참고하는 과정이 지나면 output 값을 출력한다.</p><blockquote>LSTM</blockquote><p>RNN의 경우 단기 기억(최근 input)의 영향을 많이 받는다. 이러한 문제를 해결한 것이 Long-Short Term Memory 이다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FCmdtrDii27NH-jDC1c6bQ.png" /><figcaption>cs231n, lecture note 10</figcaption></figure><p>LSTM 의 전체적인 구조는 RNN과 동일하게 Cell 단위로 구성되어 있다. RNN에서는 각 Cell에서 hidden state만 출력되었다면 LSTM에서는 Cell stae, hidden state 2가지를 출력한다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ULjr2aJh-d01NWc_rwSx4g.png" /><figcaption>cs231n, lecture note 10</figcaption></figure><p>위 그림을 보면 굉장히 어지럽다.. 중요한 것은 이전 cell state와 hidden state 그리고 input을우측의 식을 통하여 계산하면 단기, 장기 기억이 잘 조합된 output을 출력할 수 있다는 것이다~</p><blockquote>GRU</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FjWNMLKImTvb9ncf_BG__A.png" /><figcaption>cs231n, lecture note 10</figcaption></figure><p>LSTM의 연산을 efficient하게 하는 알고리즘!!</p><blockquote>Multi-Layer LSTM</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8hAC23etI1qnHl-uPiMWBA.png" /><figcaption>Reducing Exchange Rate Risks in International Trade: A Hybrid Forecasting Approach of CEEMDAN and Multilayer LSTM</figcaption></figure><p>Hidden Layer 영역에 LSTM Layer가 여러층 있는 알고리즘</p><p>Input Layer →LSTM Layer → fc Layer → output Layer</p><blockquote>Bidirectional LSTM</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VLahsWaqcp3xbDNtB13JyQ.png" /><figcaption><a href="http://www.gabormelli.com/RKB/Bidirectional_LSTM_(BiLSTM)_Model">http://www.gabormelli.com/RKB/Bidirectional_LSTM_(BiLSTM)_Model</a></figcaption></figure><p>문장의 빈칸을 채우는 Language Model에 많이 이용된다. many-to-many, ont-to-many 등의 알고리즘으로 확장될 수 있음</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2cc1436b5c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Deep Learning] CNN]]></title>
            <link>https://medium.com/@dlstj1506/deep-learning-cnn-f666767e988e?source=rss-10405706ba8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f666767e988e</guid>
            <category><![CDATA[cnn]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[INSEO LEE]]></dc:creator>
            <pubDate>Thu, 26 Oct 2023 03:52:24 GMT</pubDate>
            <atom:updated>2023-10-26T03:52:24.392Z</atom:updated>
            <content:encoded><![CDATA[<h4>패스트 캠퍼스 AI 부트캠프 6기</h4><blockquote>Convolutinal Neural Network</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gRDPY7Aol9X7VjG1zlRQKQ.png" /><figcaption><a href="https://towardsdatascience.com/a-comprehensive-guide-to-convolutional-neural-networks-the-eli5-way-3bd2b1164a53">https://towardsdatascience.com/a-comprehensive-guide-to-convolutional-neural-networks-the-eli5-way-3bd2b1164a53</a></figcaption></figure><p><strong><em>이미지의 특징을 잘 파악하는 Neural Network</em></strong>로 크게 이미지 처리 영역과 NN영역으로 나뉜다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*umAmKIdivYOIUL0E5YmK8Q.png" /></figure><p><strong><em>이미지 처리 영역</em></strong>이 CNN의 큰 특징이라고 할 수 있다. 위 과정은 <strong><em>고차원의 데이터</em></strong>를 <strong><em>embedding module의 Convolution, Pooling을 통해</em></strong> NN가 학습하기 좋은 <strong><em>저차원 데이터</em></strong>로 만들어준다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7BW44uOxUtIprqBfvaL7ng.png" /></figure><p>이후 NN영역에서 <strong><em>저차원 데이터</em></strong>를 Vector형태로 변환 후 <strong><em>MLP를 통해 학습하여 CNN 모델</em></strong>을 만든다.</p><blockquote>Convolution Layer</blockquote><p>이미치 처리 영역의 중요한 부분인 Convolution Layer에 대하여 이야기 해보자 <strong><em>Convolution</em></strong>은 <strong><em>이미지에서 특징을 뽑는 방법</em></strong>을 이야기 하고 이것을 수행하는 층을 Convolution Layer라고 이야기 한다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-EV5TUls2bqFD012LyZMrA.png" /></figure><p>Convolution을 하기 위해서는 <strong><em>filter(kernel)</em></strong>가 필요하다. filter는 한 번에 처리할 이미지의 크기를 나타내고 각 pixel마다 weight가 존재하여 <strong><em>weight matrix</em></strong>라고도 이야기 한다.</p><p>위 그림은 이미지를 처리하기 위해 3x3 filter가 움직이는 모습을 보여준다. filter가 1칸(stride)씩 가로, 세로로 이동하며 이미지의 모든 영역을 위 convolution 식을 통해 계산한다.<strong><em> filter가 한 번 이동</em></strong>하면 <strong><em>1개의 output</em></strong>을 출력하는 것!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ps_mrmKZ1A60UhFgp3KzQ.png" /><figcaption>cs231n, lecture notes 5</figcaption></figure><p>이 번에는 조금 더 복잡한 예시를 살펴보자, 위 그림의 왼쪽을 보면 <strong><em>3x32x32</em></strong> 3d tensor가 있다. 이것은 <strong><em>32x32 pixel 크기</em></strong>를 가진 RGB color <strong><em>channel이 3개</em></strong> 있다는 것을 이야기 한다.</p><p>위 이미지에 5x5 filter를 씌워서 convolution을 계산하여 ReLU함수를 통해 결과값을 얻으면 activation map의 한 지점을 작성할 수 있다. 이 때 위 이미지의 경우 3_channels 구조이기 때문에 한 번 filter를 적용할 때 각 channel마다 다른 필터를 사용하여 계산한 3개의 결과값을 더한 하나의 결과값을 activation map에 적용하여야 한다.</p><p>이렇게 <strong><em>한 번 filter를 적용하면 activation maps의 한 channel을 형성</em></strong>할 수 있고 위 예시의 경우<strong><em> filter를 6번 적용</em></strong>하였기 때문에 <strong><em>activation maps의 채널이 6</em></strong>으로 형성되는 것이다. 즉 <strong><em>activation maps channel = # of filters</em></strong> 인 것이다.</p><p>마지막으로 <strong><em>activation maps의 크기</em></strong>가 28x28인 이유는 무엇일까? 그것은 이미지 크기 N, filter 크기 F, filter 이동 칸수 stride S에 의해 계산된다. 그 식은 <strong><em>(N-F / S) + 1</em></strong> 이다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*BDqECWXR8nRFoXdA0Sdftg.png" /><figcaption>Convolution을 쉽게 이해할 수 있는 예시</figcaption></figure><blockquote>Pooling Layer (=Subsampling)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Iyn3Hk9PErayo0wOWySqSA.png" /><figcaption>cs231n, lecture notes 5</figcaption></figure><p><strong><em>Pooling</em></strong>은 <strong><em>이미지의 크기를 줄이는 것</em></strong>으로 위 예시는 filter에서 가장 큰 값을 뽑는 max pool 방식을 보여준다.</p><p>Pooling의 경우 <strong><em>weight가 없는 filter</em></strong>를 사용하고 <strong><em>Same channel, Different Size</em></strong>라는 특징을 가진다.</p><blockquote>Vanilla CNN Architecture</blockquote><p>공학에서 Vanilla는 가장 기본이 되는 것을 이야기 한다. 즉 Vanilla CNN Architecture는 가장 기본이 되는 CNN Architecture 인 것이다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NipEEV3ydmHNTPiRee3f5Q.png" /><figcaption>cs231n, lecture notes 5</figcaption></figure><blockquote>Zero padding</blockquote><p>만약 32x32 이미지를 위 Vanilla CNN Architecture에 넣으면 어떻게 될까? 마지막 Pooling 하기도 전에 이미지의 크기가 1x1이 되는 불상사가 발생하게 된다. 왜냐하면 이미지의 크기가 Convolution을 통해 줄어들고 Pooling을 통해 줄어드는 것을 반복하기 때문이다.</p><p>그래서 나타난 것이 Zero padding이다. Zero padding이란 <strong><em>이미지의 모서리에 0을 추가하는 것</em></strong>으로, 이미지 사이즈를 키워서 <strong><em>Convolution으로 인한 사이즈 감소를 없애고 오직 Pooling을 통한 사이즈 감소만 허용</em></strong>하게 해준다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fbTkqu1xcRmiO7VytNBqsw.png" /></figure><p>위 예시를 보면 32x32 이미지에 1pad 만틈 Zero padding하여 34x34이미지를 생성하였고 이를 3x3 filter에 1_stride를 적용하여 convolution하면 이전과 동일한 32x32 activation map을 생성할 수 있다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f666767e988e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Deep Learning] Basic of Deep Learning]]></title>
            <link>https://medium.com/@dlstj1506/deep-learning-basic-of-deep-learning-620bd3cda677?source=rss-10405706ba8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/620bd3cda677</guid>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[INSEO LEE]]></dc:creator>
            <pubDate>Tue, 24 Oct 2023 16:33:17 GMT</pubDate>
            <atom:updated>2023-11-10T01:27:35.306Z</atom:updated>
            <content:encoded><![CDATA[<h4>패스트 캠퍼스 AI 부트캠프 6기</h4><blockquote>Deep Learning</blockquote><p>Deep Neural Network를 이용한 Machine Learning</p><blockquote>ML vs DL</blockquote><p>대부분 정형 데이터 → ML (시계열의 경우 DL)</p><p>대부분 비정형 데이터 → DL</p><blockquote>Weak AI, General AI</blockquote><ul><li>Weak AI : <strong><em>특정 기능을 잘 수행</em></strong>하는 인공지능, 우리가 배우는 대부분의 모델이 이 범주에 속함 (ex. AlphaGo, BERT, GPT-3,…)</li><li>General AI : <strong><em>인간과 같은 일반적인 수준의 지능</em></strong>을 가지는 인공지능, Multi modal(multi domain)연구를 중점으로 발전 중(ex. GPT-4, DALLE-3)</li></ul><blockquote>Perceptron</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/0*ImTfswzU2crTTRkK.jpg" /><figcaption><a href="https://www.allaboutcircuits.com/technical-articles/how-to-train-a-basic-perceptron-neural-network/">https://www.allaboutcircuits.com/technical-articles/how-to-train-a-basic-perceptron-neural-network/</a></figcaption></figure><p>인간의 neuron을 컴퓨터에서 사용할 수 있는 형태로 구현한 artifitial neuron</p><p>Vector 형태로 들어온 <strong><em>각 input에 weight(가중치)를 부여</em></strong>하여 <strong><em>Linear한 형태의 식</em></strong> 만든 후 <strong><em>Activation function에 대입</em></strong>하여 <strong><em>output</em></strong>을 얻는 구조</p><blockquote>Multi-Layer Perceptron</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/0*Fn5JCf2yaSjFII_s.png" /><figcaption><a href="https://www.nomidl.com/natural-language-processing/what-is-multilayer-perceptron/">https://www.nomidl.com/natural-language-processing/what-is-multilayer-perceptron/</a></figcaption></figure><p><strong><em>Perceptron의 한계를 극복는 MLP(다층퍼셉트론)</em></strong></p><p>Input node의 갯수 → 차원의 갯수</p><p>Hidden layer가 1개인 경우 <strong><em>ShallowNN</em></strong>, 2개 이상인 경우 <strong><em>DeepNN</em></strong></p><p>각 <strong><em>Hidden layer와 Output layer </em></strong>에는 다양한 <strong><em>함수(Activation Function)를 적용</em></strong>할 수 있다. <strong><em>(ex. linear function, sigmoid, Tanh, ReLU)</em></strong> 이러한 함수들은 y가 최소가 되는 weight를 구하기 위해 미분이 가능한 것이 좋다.</p><p>Output layer에 적용하는 Output function의 종류는 task에 따라서 선택할 수 있다. (ex. Classifier or Regressor)</p><blockquote>Activation Function</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3pFSehHQ2E8pZef4mi2Prg.png" /><figcaption><a href="https://www.v7labs.com/blog/neural-networks-activation-functions">https://www.v7labs.com/blog/neural-networks-activation-functions</a></figcaption></figure><p>Percetron에 적용할 수 있는 대표적인 활성함수 3가지</p><p><strong><em>Sigmoid, Tanh</em></strong>의 경우 미분했을 때 x가 과하게 크거나 작을 때 <strong><em>gradient vanishing problem</em></strong>이 발생할 수 있다.</p><p><strong><em>ReLU</em></strong>의 경우 요즘 <strong><em>가장 많이 사용</em></strong>되는 activation function으로 x가 0이하인 경우 모두 0을 출력하는 것으로 인해 <strong><em>Dying ReLU Problem</em></strong>이 발생할 수 있는데 이를 <strong><em>Leaky ReLU를 통해 해결</em></strong>할 수 있다.</p><blockquote>Output function</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZYXdNB9nKrObyY0j.png" /><figcaption><a href="https://ljvmiranda921.github.io/notebook/2017/08/13/softmax-and-the-negative-log-likelihood/">https://ljvmiranda921.github.io/notebook/2017/08/13/softmax-and-the-negative-log-likelihood/</a></figcaption></figure><p><strong><em>Softmax</em></strong>의 경우 <strong><em>Multi-class classification</em></strong>에 사용되는 Output Function 이다.</p><p>3개의 input을 3-class로 분류하는 예시를 보자. Softmax 함수를 통과함으로 인해 <strong><em>각 input마다 각 class가 될 수 있는 확률을 확인</em></strong>할 수 있다. <strong><em>하나의 input에 대한 결과 값들은 모두 더했을 때 1</em></strong>이 되며(normalize) 이를 통해 특정 Class의 확률을 부풀려 눈에 띄게 해준다.</p><blockquote>Loss function</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3FHNPwmZe23htuiullT2ow.png" /><figcaption><a href="https://fmorenovr.medium.com/sparse-categorical-cross-entropy-vs-categorical-cross-entropy-ea01d0392d28">https://fmorenovr.medium.com/sparse-categorical-cross-entropy-vs-categorical-cross-entropy-ea01d0392d28</a></figcaption></figure><p>Cross-entropy는 분류의 예측값이 틀린 정도를 계산하는 Loss Function으로 다범주 분류에서 softmax와 함께 사용된다. multi-class의 경우 CE Loss, binary class의 경우 BCE Loss라고 이야기 한다.</p><p>이 외로는 MSE 등이 Loss function으로 이용된다.</p><blockquote>Optimizer</blockquote><p><strong><em>Loss를 weight에 update하는 방법</em></strong>을 Optimizer라고 이야기 한다. 대표적으로 ML때 학습했던 <strong><em>Gradient Descent Algorithm</em></strong>이 존재하고 위 방법이 발전하여 <strong><em>SGD, Momentum, Adam, AdamW</em></strong> 등이 개발 되었다.</p><blockquote>Mini-batch Training</blockquote><p>일반적인 <strong><em>GD(Gradient Descent)</em></strong>의 경우 <strong><em>한 번에 모든 데이터를 feed-forward하고 평균 Loss를 계산하여 update</em></strong>한다. → <strong><em>memory가 부족</em></strong>할 수 있다 → <strong><em>data의 일부만 이용</em></strong>해야 한다.</p><p><strong><em>Stochastic GD</em></strong>의 경우 <strong><em>한 번에 데이터 하나를 feed-forward를 하고 Loss를 계산하여 update</em></strong>한다 → 빠른 속도 그러나 성능은 떨어질 수 있다.</p><p><strong><em>mini-batch GD</em></strong>는 위 두개의 알고리즘 사이에 있는 것으로 <strong><em>한 번에 m개의 데이터를 feed-forward해서 평균 Loss를 계산하여 update</em></strong>한다. m은 2의 거듭제곱을 주로 사용 → 적당한 속도와 좋은 정확도</p><blockquote>Learning Rate Scheduling</blockquote><p>적당한 Learning Rate(성능)와 Batch(속도) 설정이 모델에 큰 영향을 끼친다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ti3TF4zUJIhg008JqBgGg.png" /><figcaption>cs231n lecture notes</figcaption></figure><p><strong><em>Learning Rate를 iteration에 따라 조절</em></strong>하는 것을 <strong><em>Learning Rate Decay</em></strong>라고 이야기 한다. Step방식과 Cosine 방식이 있으며 Cosine 방식을 많이 사용한다. 위 그래프를 보면 <strong><em>Epoch(학습 반복 횟수)가 증가할 수록 Learning Rate를 감소</em></strong>시켜 <strong><em>Loss를 감소</em></strong>시키는 것을 확인할 수 있다.</p><blockquote>Transfer Learning</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jMw0jnxVQEFo25ujmmiMLQ.png" /></figure><p>일반적으로 <strong><em>random initial weight부터 시작</em></strong>하여 모델의 <strong><em>weight update training</em></strong>을 하는 것을 <strong><em>from-scratch</em></strong> 라고 이야기 한다. 이러한 방법은 <strong><em>들어가는 리소스가 많다</em></strong>.</p><p>이러한 단점을 줄이기 위해 우리는<strong><em> fine-tuning</em></strong>방식을 통한 weight update training을 할 수 있다. fine-tuning 방식은 <strong><em>pretrained model의 weight와 architecture를 가져와서 이용</em></strong>하는 것으로 학습에 들어가는 리소스를 줄일 수 있다.</p><p>내가 가진 데이터를 <strong><em>이미 학습된 모델의 weight와 architecture를 이용</em></strong>하여 학습 후 그것을 <strong><em>output layer와 연결하는 학습만 진행</em></strong>하면 되는 것, 위 그림의 Strategy 3를 이야기 한다.</p><p>이 외에도<strong><em> Pretrained model의 weight와 architecture를 가져와서 해당 부분의 일정 부분까지</em></strong> unfreeze하게 되면 해당 부분까지 <strong><em>Back Propagation이 가능</em></strong>하여 <strong><em>학습하는 영역이 늘어</em></strong>나고 <strong><em>모델 성능도 향상</em></strong>될 수 있다. 위의 Strategy 2를 이야기 한다.</p><blockquote>Back-propagation</blockquote><p>Deep Neural Network가 loss를 효율적으로 업데이트 하는 방법</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FIlg3gGewQ5U%3Flist%3DPLZHQObOWTQDNU6R1_67000Dx_ZCJB-3pi&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DIlg3gGewQ5U&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FIlg3gGewQ5U%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/150db99acb050f013c5dc6dd06083ccb/href">https://medium.com/media/150db99acb050f013c5dc6dd06083ccb/href</a></iframe><p>위 영상을 여러 번 보면서 그 느낌을 이해하도록 하자..3Blue1Brown 최고!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=620bd3cda677" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[11–12주차] 패스트 캠퍼스 AI 부트캠프 6기 학습일지]]></title>
            <link>https://medium.com/@dlstj1506/11-12%EC%A3%BC%EC%B0%A8-%ED%8C%A8%EC%8A%A4%ED%8A%B8-%EC%BA%A0%ED%8D%BC%EC%8A%A4-ai-%EB%B6%80%ED%8A%B8%EC%BA%A0%ED%94%84-6%EA%B8%B0-%ED%95%99%EC%8A%B5%EC%9D%BC%EC%A7%80-6c36cd0f093d?source=rss-10405706ba8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c36cd0f093d</guid>
            <category><![CDATA[부트캠프]]></category>
            <category><![CDATA[국비지원]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[패스트캠퍼스]]></category>
            <dc:creator><![CDATA[INSEO LEE]]></dc:creator>
            <pubDate>Sun, 08 Oct 2023 15:42:04 GMT</pubDate>
            <atom:updated>2023-10-08T15:42:04.916Z</atom:updated>
            <content:encoded><![CDATA[<h4>패스트 캠퍼스 AI 부트캠프 6기</h4><h3>ML 프로젝트 기본 이론 : 머신러닝</h3><p><strong><em>9월25일</em></strong> 실시간 강의</p><p><a href="https://medium.com/@dlstj1506/machine-learning-ml-data-split-d6887c5f15d3">[Machine Learning] ML Data Split</a></p><p><strong><em>9월26일</em></strong> 실시간 강의</p><ul><li><a href="https://medium.com/@dlstj1506/machine-learning-linear-regression-8d0c6c5fd826">[Machine Learning] Linear Regression</a></li><li><a href="https://medium.com/@dlstj1506/machine-learning-logistic-regression-3871772fb390">[Machine Learning] Logistic Regression</a></li></ul><p><strong><em>9월27일</em></strong> 실시간 강의</p><ul><li><a href="https://medium.com/@dlstj1506/machine-learning-linear-classifie-4f666eaae330">[Machine Learning] Linear Classifie</a></li><li><a href="https://medium.com/@dlstj1506/machine-learning-decision-tree-cart-45a7055d4a7">[Machine Learning] Decision Tree(CART)</a></li><li><a href="https://medium.com/@dlstj1506/machine-learning-random-forest-edb7ae1b7d1d">[Machine Learning] Random Forest</a></li></ul><p><strong><em>10월4일</em></strong> 실시간 강의</p><ul><li><a href="https://medium.com/@dlstj1506/machine-learning-clustering-k-means-hierarchical-9fd9e3dc4e72">[Machine Learning] Clustering (K-means, Hierarchical)</a></li><li><a href="https://medium.com/@dlstj1506/machine-learning-boosting-ada-boost-gradient-boosting-machine-xgboost-lightgbm-catboost-d8750ac415ed">[Machine Learning] Boosting(Ada Boost, Gradient Boosting Machine, XGboost, LightGBM, CatBoost)</a></li></ul><p><strong><em>10월5일</em></strong> 실시간 강의</p><ul><li><a href="https://medium.com/@dlstj1506/machine-learning-eda-and-feature-engineering-for-machine-learning-fa188b949bde">[Machine Learning] EDA and Feature Engineering for Machine Learning</a></li><li><a href="https://medium.com/@dlstj1506/machine-learning-training-ml-model-for-good-performance-grid-search-random-search-k-fold-cv-f45c615455a3">[Machine Learning] Training ML Model for good performance (Grid search, Random Search, K-Fold CV)</a></li></ul><p><strong><em>10월6일</em></strong> 실시간 강의</p><p>Optuna 설명 및 ML 실습</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c36cd0f093d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Machine Learning] Training ML Model for good performance (Grid search, Random Search, K-Fold CV)]]></title>
            <link>https://medium.com/@dlstj1506/machine-learning-training-ml-model-for-good-performance-grid-search-random-search-k-fold-cv-f45c615455a3?source=rss-10405706ba8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f45c615455a3</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[k-fold-cross-validation]]></category>
            <category><![CDATA[gridsearchcv]]></category>
            <category><![CDATA[random-search]]></category>
            <dc:creator><![CDATA[INSEO LEE]]></dc:creator>
            <pubDate>Fri, 06 Oct 2023 05:33:11 GMT</pubDate>
            <atom:updated>2023-10-06T05:33:11.391Z</atom:updated>
            <content:encoded><![CDATA[<h4>패스트 캠퍼스 AI 부트캠프 6기</h4><blockquote>“Hyper-parameter tuning”</blockquote><p>Machine Learning Model이 좋은 성능을 가지기 위해서는 Hyper-param를 잘 설정해야 한다. 하나 하나 직접 설정해줄 수도 있지만 다양한 방법을 통해 최적의 parameter를 찾을 수 있다.</p><blockquote>“Grid Search VS Random Search”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*vSzM8Hb8T5m7PTSnYQqUpQ.png" /><figcaption><a href="https://www.researchgate.net/publication/341691661_A_Kernel_Design_Approach_to_Improve_Kernel_Subspace_Identification">https://www.researchgate.net/publication/341691661_A_Kernel_Design_Approach_to_Improve_Kernel_Subspace_Identification</a></figcaption></figure><p><strong><em>Grid Search</em></strong>의 경우 <strong><em>분석가가 지정한 파라미터들의 모든 조합을 modeling</em></strong>하며 <strong><em>그 안에서의 최고의 성능</em></strong>을 찾는다. 그렇기 때문에 <strong><em>가장 최적의 성능을 보이는 파라미터를 못 찾을 수도 있다</em></strong>.</p><p>반면에<strong><em> Random Search</em></strong> 같은 경우 <strong><em>특정 Range(범위)와 n_trials(시행횟수)안에서 Random하게 파라미터</em></strong>를 찾는다. 이론적으로 <strong><em>Random Search가 최적의 파라미터를 찾기에 유리</em></strong>하지만 <strong><em>데이터 수가 많아지면 굉장히 오랜시간이 걸리는 단점</em></strong>이 있다.</p><p>앞으로 배울 <strong><em>Optuna</em></strong>가 앞서 이야기한 <strong><em>Random Search와 Bayesian Optimization을 결합</em></strong>한 것</p><blockquote>“K-Fold Cross Validation”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Aes_YPDq57Xrr7sv.png" /><figcaption><a href="https://welcome-to-dewy-world.tistory.com/7">https://welcome-to-dewy-world.tistory.com/7</a></figcaption></figure><p>지금까지 우리가 학습을 할 때는 Original Set을 Training, Test로 나눈 후 다시 Training data를 Training, Validation으로 나누어서 사용하였다. (<a href="https://medium.com/@dlstj1506/machine-learning-ml-data-split-d6887c5f15d3">Data split에 대한 설명</a>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/0*4bTehiqmedATr6vt.png" /><figcaption><a href="https://jonsyou.tistory.com/23">https://jonsyou.tistory.com/23</a></figcaption></figure><p>이러한 <strong><em>Training data를 더 효율적으로 사용</em></strong>할 수 있는 것이 <strong><em>K-fold CV</em></strong> 이다.</p><h4>K-fold Cross Validation Flow</h4><ol><li>Training data를 K개의 fold로 분할</li><li><strong><em>하나의 fold를 Validation data</em></strong>로 <strong><em>나머지 fold를 Training data</em></strong>로 사용하여 <strong><em>modeling</em></strong>을 진행한다.</li><li><strong><em>서로 다른 K개의 model(모두 동일한 Hyper-param)</em></strong>에 이전에 사용되지 않은 fold를 Validation data로 그리고 나머지 fold를 Training data로 사용하는 modeling을 진행하여 <strong><em>총 K개의 P_val</em></strong>을 뽑아낸다.</li><li>K개의 P_val 평균이 가장 높은 Hyper-parameter를 찾는 것이 목표!!</li></ol><h4><strong><em>Model finalization</em></strong></h4><ol><li>최적의 파라미터를 적용한 하나의 model에 모든 Training data를 학습 → 가장 많이 사용하는 방법</li><li>K-Fold Prediction 사용(앙상블과 같음!!) → 이전에 사용한 K개의 model들을 그대로 사용한다는 의미</li></ol><h4>Out of Fold prediction (OOF Prediction)</h4><p>Model finalization 을 통해 만들어진 model에 Test data(Out of Fold)를 적용하여 p_test 측정!</p><p>K개의 P_val 성능과 P_test 성능이 모두 좋으면 그 모델이 좋다는 아이디어!</p><blockquote>“Optuna(AutoML Framework)”</blockquote><p>자동으로 Hyper-parameter tuning을 해주는 Framework</p><p>이 외의 AutoML Framework → Pycaret, autogluon, autokeras, …</p><p><strong><em>Human research, Grid research, Optuna 모두할 수 있어야 한다!</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f45c615455a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Machine Learning] EDA and Feature Engineering for Machine Learning]]></title>
            <link>https://medium.com/@dlstj1506/machine-learning-eda-and-feature-engineering-for-machine-learning-fa188b949bde?source=rss-10405706ba8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa188b949bde</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[feature-engineering]]></category>
            <dc:creator><![CDATA[INSEO LEE]]></dc:creator>
            <pubDate>Thu, 05 Oct 2023 12:58:12 GMT</pubDate>
            <atom:updated>2023-10-05T12:58:12.742Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>패스트 캠퍼스 AI 부트캠프 6기</em></h4><blockquote>“EDA for Machine Learning”</blockquote><p>EDA, 탐색적 데이터 분석을 통해 <strong><em>ML에 적합한 통계량을 파악</em></strong>해야 한다.</p><h4>일반적인 고려 사항</h4><ul><li>row, column, memory size 등의 데이터 크기 확인</li><li>pandas info()를 통한 column별 정보 확인</li><li>columns별 결측치 확인</li><li>Categorical feature는 없는지 확인</li></ul><p>→ <strong><em>ML을 하기 위해</em></strong>서는 <strong><em>결측치</em></strong>가 없어야 하고 <strong><em>String value</em></strong>, <strong>Categorical feature</strong> <strong><em>등이 없어야</em></strong> 하기에 EDA를 통한 확인이 필요하다.</p><h4>결측치 처리</h4><p>결측치는 0이 아니다. 데이터 자체가 존재하지 않는 것!!, 결측치를 지우거나 채워주어야 한다.</p><blockquote><em>결측치가 많은 경우(50% 이상)</em></blockquote><ul><li>ML을 하기에 의미 있는 Column이면 결측치를 채우고</li><li>ML을 하기에 의미 없는 Column이면 Column 삭제</li></ul><blockquote>결측치가 많지 않은 경우</blockquote><ul><li>분석에 많은 영향을 주는 경우 ground value(0, -1000, …)으로 채운다.</li><li>분석에 많은 영향을 주는 경우 채우는 로직을 다양하게 Test 해본다.</li></ul><blockquote><em>결측치 채우기</em></blockquote><ul><li>평균으로 채우기</li><li>ground value로 채우기</li><li>near values로 채우기 ex. interpolation methods</li><li>model approach : 결측치를 예측 target으로 정하여 ML을 통해서 결측치를 찾는 것</li></ul><blockquote><em>Model approach (ML 기법을 통해 결측치를 채우는 것)</em></blockquote><p>KNN Imputation : <strong><em>결측치를 포함하는 데이터와 비슷한 K개의 데이터</em></strong>를 찾아서 <strong><em>K개의 평균값으로 결측치를 채우는 것</em></strong> → KNN Regressor를 수행한 것과 도일한 결과를 볼 수 있다.</p><p>Random Forest Imputation: RF로 결측치를 에측하여 사용하게 되면 <strong><em>Overfitting이나 Underfitting</em></strong>이 발생할 수 있어서 잘 사용하지 않는다.</p><blockquote>“Feature Engineering”</blockquote><p><strong><em>데이터를 분석 목적에 맞게 가공</em></strong>하는 과정, <strong><em>분석에 필요한 feature를 추출</em></strong>하여 모델링에 사용, 어떤 피처를 추출할지는 <strong><em>모델링을 통한 피드백(P_test)</em></strong> 혹은 <strong><em>분석가의 직관(domain knowledge, domain literacy)</em></strong>에 의해 결정된다.</p><h4>차원의 저주(Curse of Dimensionality)</h4><p><strong><em>고차원 데이터에 취약한 머신러닝</em></strong> 문제(고차원의 기준은 대량 100차원 이상)</p><p>차원이 커질 수록 예측 성능 저하, 저차원에서의 거리값이 차원이 커지며 무의미 , 유의미한 패턴을 찾을 수 없어 overfitting 가능성, 공간이 커지는 양이 정보가 늘어나는 양 보다 크다(space grow exponentially)</p><p><strong><em>차원 축소 기법(dimensionality reduction)을 통해 저차원 공간으로 변환</em></strong>이 필요하다 → <strong><em>PCA, AutoEncoder</em></strong></p><h4>상관관계 분석</h4><ul><li>input feature 사이의 상관관계 분석을 통해 corr ≥ 0.9 이상의 경우 둘 중 하나의 피쳐만 모델링에 사용</li><li>X와 target value 사이의 상관관계 분석을 통해 feature가 target에 끼치는 영향을 파악할 수 있음</li></ul><h4>Feature Scaling</h4><p>feature의 단위가 다르다면 (Ex. 몸무게와 학점) 모델링에 문제가 생길 수 있다. <strong><em>Scaling을 통해 단위를 맞추어 주어야 올바른 modeling이 가능</em></strong></p><p>ex. Min-Max Scaling, Standard Scaling, Robust Scaling 등</p><p>**** <strong><em>Tree 모델들은 스케일과 무관하게 modeling</em></strong> 할 수 있음!!! (Best split point를 찾을 때 각 Column 별로 살펴보기에 가능!!)</p><h4>Encoding Categorical Features</h4><p>One-hot encoding : 보통 nominal feature (ex. Sex)</p><p>Ordinal encoding : 보통 Ordinal feature (ex. 학력, 선호도)</p><p>만약 학력의 차이가 모델의 결과에 영향을 끼치지 않는다고 판단되면 nominal feature처럼 One-hot encoding을 해도 상관 없음!</p><h4>Feature Selection with Feature Importance</h4><p>각 피처의 중요도에 따라서 피처를 선택하여 modeling에 사용</p><p>Level-wise tree growth의 경우 낮은 레벨의 노드일수록 데이터 분해에 영향을 많이 준다. Leaf-wise tree growth에서는 node split을 수행하는 node가 성능에 큰 영향을 준다.</p><p>Feature selection 방법</p><ol><li>Top k feature selection : 중요도 상위 k개의 피처 선택</li><li>threshold이용 ex. relative importance 10 이상인 피처!</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa188b949bde" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Machine Learning] Boosting(Ada Boost, Gradient Boosting Machine, XGboost, LightGBM, CatBoost)]]></title>
            <link>https://medium.com/@dlstj1506/machine-learning-boosting-ada-boost-gradient-boosting-machine-xgboost-lightgbm-catboost-d8750ac415ed?source=rss-10405706ba8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8750ac415ed</guid>
            <category><![CDATA[ensemble-learning]]></category>
            <category><![CDATA[boosting]]></category>
            <category><![CDATA[machine]]></category>
            <category><![CDATA[xgboost]]></category>
            <category><![CDATA[lightgbm]]></category>
            <dc:creator><![CDATA[INSEO LEE]]></dc:creator>
            <pubDate>Wed, 04 Oct 2023 16:17:36 GMT</pubDate>
            <atom:updated>2023-10-05T12:07:19.844Z</atom:updated>
            <content:encoded><![CDATA[<h4>패스트 캠퍼스 AI 부트캠프 6기</h4><blockquote>“Boosting”</blockquote><p>약한 분류기들을 조합하여 성능이 좋은 강한 분류기를 만드는 것</p><blockquote>“AdaBoost”</blockquote><p>이전 트리를 보완하는 방식으로 학습되는 앙상블 기법</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Dyzq2F_UJczG6I7C.png" /><figcaption><a href="https://en.wikipedia.org/wiki/Boosting_(machine_learning)%23/media/File:Ensemble_Boosting.svg">https://en.wikipedia.org/wiki/Boosting_(machine_learning)#/media/File:Ensemble_Boosting.svg</a></figcaption></figure><ol><li>Original Data를 통하여 model을 생성한 후 데이터를 분류</li><li>분류하지 못한 데이터에 가중치를 더한 Weighted data를 생성</li><li>Weighted data를 통하여 model을 생선한 후 데이터를 분류</li><li>분류하지 못한 데이터에 가중치를 더한 Weighted data를 생성</li><li>위 과정을 반복한 후 각 model을 통해 얻은 y_hat의 최빈값을 선택</li></ol><blockquote>“Gradient Boosting Machine (GBM)”</blockquote><p>Boosting + Gradient Descent Algorithm</p><h4>Train</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gXWwFGf7x0WR3W9IzzFg4w.png" /></figure><ol><li>tree 1 : 실제 데이터를 학습한 model f_1을 만든 후 오차 R_1 계산</li><li>tree 2 : 오차 R_1을 학습한 model f_2를 만든 후 R_1과의 차를 계산</li><li>…</li><li>계속해서 오차를 학습한 모델을 생성</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iiio3lJkAJaAG2Jaic-bgg.png" /></figure><p>Residual(오차)를 그대로 사용하면 Overfitting 될 수 있기에 각 <strong><em>Residual에 a(Learning Rate)를 곱한 Seudo residual</em></strong>을 modeling에 사용해야 한다. 이를 <strong><em>regularization</em></strong> 이라고 한다.</p><h4>Predict</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/251/0*lfPkinBg9Ji2WiUL.png" /></figure><p>새로운 데이터 x_i를 각 model에 넣은 값을 모두 더하면 예측값 y_i를 얻을 수 있다.</p><blockquote>“XGBoost”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/0*WzKSx7iQZgvm3d_Q.png" /><figcaption><a href="https://en.wikipedia.org/wiki/XGBoost">https://en.wikipedia.org/wiki/XGBoost</a></figcaption></figure><p>GBDT(GBM)의 학습 시간이 오래 걸리는 문제를 하드웨어 최적화를 통해서 해결 (ex. Cache, Parallelized tree building)</p><p>Kaggle과 같은 데이터 분석 대회에서 가장 많이 사용하는 모델</p><p>Alogithm적으로 결측치를 모델 자체에서 처리해준다 → 그러나 분석하는 사람이 직접 전처리 하는 것이 모델 이해에 더욱 좋음</p><p>System적인 작업 : Parallelization, Tree Pruning, Hardware Optimization</p><h4>parameters (1000 ≤ n ≤ 30,000 을 가정)</h4><p>Tree ensemble 관련</p><ul><li>n_estimators : 50~2000</li><li>learning_rate : 0.3~0.01 (model이 작으면 learning rate도 작게 → n_estimators와 같이 가라는 의미)</li><li>tree_method : exact, gpu_hist 주로 사용 : best split을 찾을 때 데이터를 사용하는 방법</li><li>random_state</li><li>early_stopping_rounds : eval_metric, validation_data 함께 설정 필요</li></ul><p>CART 관련</p><ul><li>max_depth : 5~15</li><li>colsample_bynode : Local randomization과 같음 : 0.5~0.8</li><li>reg_lambda : regularization parameter : 0.5~5.0 (learning rate와 다름)</li></ul><blockquote>“LightGBM(LGBM)”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/0*OcRtHxjpO57geEA8.png" /><figcaption><a href="https://en.wikipedia.org/wiki/LightGBM">https://en.wikipedia.org/wiki/LightGBM</a></figcaption></figure><p>XGBoost보다 가볍고 빠른 GBM 모델, Kaggle과 같은 데이터 분석 대회에서 가장 많이 사용하는 모델 (By MicroSoft)</p><p>이전의 Binary Tree 기반 모델들이 Level-wise tree growth(left, right 순서로 tree 생성)였다면, LightGBM은 <strong><em>Leaf-wise tree growth(성능 개선에 도움이 되는 leaf node를 split)</em></strong>라는 새로운 방식으로 <strong><em>split point를 찾음</em></strong>으로 <strong><em>효율을 극대화, 작은 메모리로 빠르고 성능이 좋은 트리</em></strong>를 만든다. (data가 10000개 이하라면 Overfitting 되기 쉬움)</p><h4>parameters (30,000 ≤ n 을 가정)</h4><p>Tree ensemble 관련</p><ul><li>n_estimators : 50~</li><li>learning_rate : 0.3~0.001</li><li>silent : -1 (= verbose) : log 없애기</li><li>random_state</li></ul><p>CART 관련</p><ul><li>max_depth : 15~25</li><li>num_leaves : max(# of leaf nodes) 제한</li><li>min_child_samples : min_samples_leaf와 같음 : 1~100</li><li>colsample_bytree : Global randomization과 같음 : 0.5~0.8</li></ul><blockquote>“CatBoost(CAT)”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/120/0*Cb0COvALLDcUKMez.png" /><figcaption><a href="https://en.wikipedia.org/wiki/CatBoost">https://en.wikipedia.org/wiki/CatBoost</a></figcaption></figure><p>Kaggle과 같은 데이터 분석 대회에서 가장 많이 사용하는 모델, GBDT가 <strong><em>Categorical feature에 대해서 학습이 잘 되도록 설계</em></strong> 되어있다. <strong><em>자동으로 범주형 변수 인코딩</em></strong>을 해준다! parameter tuning이 쉽고 GPU 최적화가 잘 되어있다.</p><h4>parameters (feature의 50% 이상이 categorical일 때)</h4><p>Parameter Tuning</p><ul><li>iterations : n_estimators와 같음, # of trees : 50~50,000</li><li>learning_rate : 0.3~0.001</li><li>depth : max_depth와 같음 : 5~25</li><li>border_count : n개씩 데이터를 묶어주는 것, 데이터를 간략화!, n이 클수록 모델 속도가 빨라지나 성능은 낮아짐</li></ul><p>Speeding up the training</p><ul><li>rsm : random_subsapce_method를 이야기 함 : local randomization을 의미 : 0.5~0.8</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8750ac415ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Machine Learning] Clustering (K-means, Hierarchical)]]></title>
            <link>https://medium.com/@dlstj1506/machine-learning-clustering-k-means-hierarchical-9fd9e3dc4e72?source=rss-10405706ba8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fd9e3dc4e72</guid>
            <category><![CDATA[clustering]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[k-means]]></category>
            <category><![CDATA[hierarchical-clustering]]></category>
            <dc:creator><![CDATA[INSEO LEE]]></dc:creator>
            <pubDate>Wed, 04 Oct 2023 15:15:48 GMT</pubDate>
            <atom:updated>2023-10-04T15:15:48.224Z</atom:updated>
            <content:encoded><![CDATA[<h4>패스트 캠퍼스 AI 부트캠프 6기</h4><blockquote>“Clustering”</blockquote><p>Unsupervised(비지도) Classification(분류) model, 비슷한 <strong><em>데이터끼리 묶어주는 것</em></strong>을 이야기 함</p><blockquote>“K-Means Clustering”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*tr_itOJJYoytars3.png" /><figcaption><a href="https://towardsdatascience.com/k-means-a-complete-introduction-1702af9cd8c">https://towardsdatascience.com/k-means-a-complete-introduction-1702af9cd8c</a></figcaption></figure><p>대표적인 Clustering 방법, <strong><em>평균(mean)을 기준으로 데이터들을 묶어주는 것</em></strong></p><h4>Clustering 방법</h4><ol><li>랜덤하게 K개의 데이터 선택</li><li>선택하지 않은 모든 데이터에 대해서 K개의 데이터중 가장 가까운 데이터를 탐색</li><li>가깝다고 정해진 데이터끼리 묶어서 클러스터 형성</li><li>클러스터에 속하는 데이터의 평균을 구함(Centroid) → 새로운 K개의 기준</li><li>위 과정을 반복</li><li>새로 업데이트 되는 데이터가 없다면 종료</li></ol><h4>Objective function</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/0*JH10zPG2rjzUce0t.png" /><figcaption><a href="https://www.saedsayad.com/clustering_kmeans.htm">https://www.saedsayad.com/clustering_kmeans.htm</a></figcaption></figure><p>각 <strong><em>클러스터의 중심과 클러스터 내에 있는 데이터간의 euclidian distance</em></strong>를 <strong><em>모두 더하는 것</em></strong>을 Objective function이라고 한다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bG2iua-iFL_753PxpI7G2w.png" /></figure><p><strong><em>K가 증가할 수록 Objective function은 감소</em></strong>하는 경향을 보이는데, 이때 <strong><em>K가 증가하며 objective function이 급격하게 감소</em></strong>하는 부분을 <strong><em>elbow method</em></strong>라고 하면 이 지점이 <strong><em>최적의 K</em></strong>이다.</p><h4>K-Means Clustering의 한계점</h4><ul><li>초기에 선택되는 K에 따라 성능 편차가 크다.</li><li>평균이 의미 없는 categorical feature에는 효과가 없다.</li><li>outlier에 민감하여 결과가 치우친다.</li><li>데이터 분포가 구형이 아니면 클러스터 생성이 어려움 → HAC를 통해 해결</li></ul><blockquote>“Hierarchical Agglomerative Clustering”</blockquote><p>HAC, 데이터 계층 구조를 파악하는 클러스터링 방법</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5FoRbE5gnudXLGlN.png" /><figcaption><a href="https://www.datanovia.com/en/lessons/agglomerative-hierarchical-clustering/">https://www.datanovia.com/en/lessons/agglomerative-hierarchical-clustering/</a></figcaption></figure><p>비슷한 데이터 끼리 묶어가면서 모든 클러스터들을 묶는다, 작은 클러스터에서 시작하여 큰 클러스터를 만드는 상향식 방법(Agglomerative)</p><h4>Clustering 방법</h4><ol><li>모든 데이터를 하나의 클러스터로 세팅</li><li>가장 가까운 두 데이터를 묶는다.</li><li>그 다음 가까운 데이터를 묶는다. 클러스터와 데이터가 묶이는 경우 하나의 클러스터로 통합한다.</li><li>상향식으로 클러스터를 합치다가 제시한 클러스터 개수가 되면 멈춘다.</li></ol><p>거리함수와 연결 방식에 따라 다른 방식으로 작동함</p><p>→ 연결 방식 : single, average, complete, ward</p><p>데이터 사이의 모든 거리를 계산해서 시간이 오래 걸림 O(N³)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fd9e3dc4e72" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>