<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>kbc-1315.log</title>
        <link>https://velog.io/</link>
        <description>AI, Security</description>
        <lastBuildDate>Thu, 19 Feb 2026 06:51:10 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <image>
            <title>kbc-1315.log</title>
            <url>https://velog.velcdn.com/images/kbc-1315/profile/319b28d1-959d-4899-ba96-83065e78fcb1/image.png</url>
            <link>https://velog.io/</link>
        </image>
        <copyright>Copyright (C) 2019. kbc-1315.log. All rights reserved.</copyright>
        <atom:link href="https://v2.velog.io/rss/kbc-1315" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[3. Oxford Cybersecurity Program : 후기]]></title>
            <link>https://velog.io/@kbc-1315/3.-Oxford-Cybersecurity-Program-%ED%9B%84%EA%B8%B0</link>
            <guid>https://velog.io/@kbc-1315/3.-Oxford-Cybersecurity-Program-%ED%9B%84%EA%B8%B0</guid>
            <pubDate>Thu, 19 Feb 2026 06:51:10 GMT</pubDate>
            <description><![CDATA[<h1 id="세-줄-요약">세 줄 요약</h1>
<ul>
<li>영국에서, 그것도 Oxford에서 살아볼 수 있는 좋은 기회</li>
<li>학술적으로는 그닥 얻은건 없다</li>
<li>한국은 생각보다 살기 좋은 나라다</li>
</ul>
<h1 id="프로그램-전반">프로그램 전반</h1>
<ul>
<li><code>아무래도 첫번째다 보니</code> 로 모든 사항들에 대한 공지가 시작되고 알림이 시작된다.  첫번째 프로그램이라 준비 사항들이 부족한건 알겠지만, 이건 부족해도 너무 부족했다. 수업이 진행될 장소, 일정, 시간들이 학생들은 물론이거니와 수업을 진행할 교수진도 몰라서 교수진이 학생들한테 와서 물어보는건 충격이었다.</li>
<li>학생들은 아무 권한이 없어 이러한 문제나 건의사항이 발생을 하여도 켈로그 측과 사업단 측에 전달을 하여도 뭐 어떻게 진행이 되는지 알 수가 없고, 서로 핑퐁하다가 증발해버린게 많았다.</li>
<li>영국식 일처리(업무 삼켜버리기, 닥칠때까지 안하기) + 한국식 일처리(서명 증빙, 문서를 통한 증빙)의 조합은 중간에 있는 학생들만 힘들게했다.</li>
</ul>
<h2 id="수업-관련">수업 관련</h2>
<ul>
<li>모듈 수업이 3개로 파견 당시에 <code>관련 역량이 뛰어난 학생들만 보내라</code>는 카더라가 있었기에 굉장히 배울게 많을 것으로 기대하고 갔다.</li>
<li>본인은 경제학 전공에 AI 대학원 전공중이라 전공 지식이 부족하고 보안 수업을 수강한적이 없었지만, 높은 수준의 수업은 커녕 전에 사용했던 슬라이드 재활용에 배울수 있는 점은 없었다. 뭇 전공자들은 교양 정도의 수업 수준이라고 했다.</li>
<li>수업 후반 왜 있는지 모를 프로젝트를 한다. 대부분 PPT 발표를 팀프로젝트 형식으로 진행하는데, 시간이 촉박해서 실험 같은 부분은 불가해서 대부분 조사 정도만 해서 발표하는 식으로 끝난다. 1팀에 6명이라 무임승차자들이 발생을 하고 서로 사이만 안좋아지는 좋은 기회가 된다.</li>
<li>결국에 남은건 참가자들끼리 서로 무슨 연구를 하고 어떤 공부를 하고 나눈게 가장 크게 남았다.</li>
</ul>
<h2 id="프로젝트-관련">프로젝트 관련</h2>
<ul>
<li>주제는 AI + 보안이었다. 근데 이제 문제는 프로그램 참가자 대부분이 AI에 대한 지식이 많이 있지 않고, 무엇보다도 AI 학습을 진행할 컴퓨팅 자원은 제공이 안된다는 점이다. 그리고 주어지는 기간도 턱없이 부족하다.</li>
<li>따라서 대부분의 프로젝트는 LLM을 활용해 그냥 AI를 연결해서 이용해봤다 정도로 그치고, 기존 연구실 서버 등을 활용해 프로젝트는 진행이 되었다.</li>
<li>프로젝트 담당 박사님은 굉장히 열성적이었지만, 마찬가지로 1팀 6명이라는 인원 분배 덕분에 많은 무임승차자가 발생하여 쉽지 않았다.</li>
</ul>
<h2 id="생활-관련">생활 관련</h2>
<ul>
<li>여러분이 받을 수 있는 체재비는 월세를 내면 끝이다. 생활비는 알아서 개인이 조달해야한다. 기숙사가 있긴 하지만, 8월은 한국과 달리 영국 학기 기준으로 학생들이 그리 많이 나가지도 들어가지도 않는 시즌이다. 따라서 저렴하게 지낼 수 있고 가까운 기숙사들은 구하는게 힘들다. 따라서 조금 거리가 있는 숙소를 구할 수 밖에 없다.</li>
<li>버스도 비싸고 해서 자전거를 타는 사람도 많았는데, 굉장히 위험하다. 한국과 달리 자동차 취급을 받고 또 좌측 통행이기 때문에 사고가 굉장히 잦고 길을 지나다니다 보면 꽃 장식된 자전거를 쉽게 볼 수 있다. 거기서 사망사고가 있었다는 뜻이라고 한다.</li>
<li>가능하면 숙소를 개별적으로 구하기보단 한국인들끼리 뭉쳐서 Flat이라던가 구하는 것도 좋은 방법이다. 관건은 개별 욕실인지, 주방을 쉐어하는지 그리고 위치를 살펴보는게 좋다. 외국인들과 함께 주방, 욕실 쉐어를 한다는게 정말 쉽지 않다. 단체로 모여서 Flat 전체를 계약하거나 하는 식으로 진행하는게 좋다. 독채 렌트는 영국 부동산법으로 인해 영국 거주하는 또는 일하는 보증인이 있어야 하기 때문에 불가하다(컬리지 측에서는 보증 안해준다).</li>
</ul>
<h1 id="건의사항">건의사항</h1>
<ul>
<li><strong>프로그램 초기 참가자간 세미나 개최</strong><ul>
<li>서로에 대해 잘 알아야 프로젝트 조직을 하든, 모듈 팀 구성을 하든 모든게 수월하고 또 서로 진행하는 연구와 학술적인 교류가 정말 유익하고 중요했다</li>
<li>따라서, 기왕 프로그램을 진행할거라면 초기에 바로 수업을 진행하는것보단 참가자들이 서로 무슨 연구를 하고 혹은 연구실에서 뭘 진행하고 뭘 공부를 하는지 그런 사항에 대한 공유가 필요하다.</li>
<li>본 프로그램에서는 자원을 받아 자체적으로 세미나를 진행하였으며 PPT를 최대한 재활용하는 식으로 혹은 간단한 자료(노션 등)을 이용하는 방향으로 진행했다.
<img src="https://velog.velcdn.com/images/kbc-1315/post/466e91fe-2cd8-4dda-aa92-4a422013e97f/image.png" alt=""></li>
</ul>
</li>
<li><strong>옥스퍼드 랩 인턴 컨택</strong><ul>
<li>참가자들이 진정으로 원하는건 학술적인, 연구적인 경험이다.</li>
<li>영국 교수진들에게 메일을 했을때 답장 받기란 정말 어려웠다. 연구실에 컨택을 정말 많이 해봤지만 답장 조차 오지 않았다.</li>
<li>따라서, 프로그램 차원에서 협조를 구해 연구실 컨택을 도와준다면 더 연구 경험을 잘 살릴 수 있는 기회가 될 듯 하다.</li>
</ul>
</li>
<li><strong>보여주기 모듈 수업에서 각 랩 특화 연구 수업으로</strong><ul>
<li>하나도 배울거 없는 모듈 수업보다는 모듈 3 마지막에 진행했던 실제로 교수님께서 했던 프로젝트를 소개해줬는데 모든 수업보다 그게 더 재밌었다.</li>
<li>옥스퍼드에서만 들을 수 있는, 각자 연구실에서 진행하는 연구에 대한 소개 혹은 가능하다면 수업이 훨씬 더 좋을듯 하다.</li>
</ul>
</li>
<li><strong>참가자 리더 임명 및 권한 부여</strong><ul>
<li>프로그램 참가자 학생들은 아무런 권한이 없어 문제 사항이나 건의 사항이 발생하면 컬리지나 사업단 측에 의견을 전달하고 그 답변을 받을 때까지 하염없이 기다려야 한다.</li>
<li>프로그램 내내 자체적으로 뭐가 언제 시작하는지 수업 당일인데도 장소가 여기가 맞는지 참가자 내에서 서로 서로 물어가며 진행을 했었다.</li>
<li>따라서, 파견 전 조 편성 및 리더를 선발하고 어드밴티지(월 15만원)를 부여하고 그 인원에게 학교측과 혹은 사업단 측과 이야기하도록 권한과 의무를 부여하여 연락 창구와 업무 담당을 하도록 하면 더 좋을 것이다.</li>
</ul>
</li>
</ul>
<h1 id="참여-소감">참여 소감</h1>
<ul>
<li>이 프로그램 아니면 언제 영국에서 그것도 옥스포드에서 공부를 해보겠다? 라는 생각으로 다녀왔다. 연구를 하고 싶었지만 환경이 여의치 않아 그냥 커리어 단절 대학원생만 된 기분이지만, 어떻게든 연구는 다시 시작해야하고 다음 기수를 위해 글을 작성해본다. 학술적인, 연구적인 수확은 없었지만, 6개월 유럽 살이라는 낭만만은 충족한 프로그램이었다. 그리고 한국은 생각보다 살기 좋은 나라다.</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[Text-to-SQL 활용 LLM 기반 가상 회사 챗봇 템플릿]]></title>
            <link>https://velog.io/@kbc-1315/Text-to-SQL-%ED%99%9C%EC%9A%A9-LLM-%EA%B8%B0%EB%B0%98-%EA%B0%80%EC%83%81-%ED%9A%8C%EC%82%AC-%EC%B1%97%EB%B4%87-%ED%85%9C%ED%94%8C%EB%A6%BF</link>
            <guid>https://velog.io/@kbc-1315/Text-to-SQL-%ED%99%9C%EC%9A%A9-LLM-%EA%B8%B0%EB%B0%98-%EA%B0%80%EC%83%81-%ED%9A%8C%EC%82%AC-%EC%B1%97%EB%B4%87-%ED%85%9C%ED%94%8C%EB%A6%BF</guid>
            <pubDate>Mon, 12 Jan 2026 13:17:11 GMT</pubDate>
            <description><![CDATA[<h1 id="talking-potato-sql--llm-기반-회사-챗봇-서비스">Talking Potato: SQL + LLM 기반 회사 챗봇 서비스</h1>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/843b338a-62ac-4a79-931b-3b189118e4ad/image.png" alt=""></p>
<h2 id="개요">개요</h2>
<p>이 프로젝트는 SQL 데이터베이스와 대형 언어 모델(LLM)을 결합 : Text-to-SQL
가상 회사 정보를 생성하고 자연어 질의응답이 가능한 챗봇 서비스를 구현한 프로젝트임.
Streamlit 기반 웹 UI로 구성됨</p>
<h2 id="왜-만들었나">왜 만들었나</h2>
<ul>
<li>구조화된 SQL 데이터와 자연어 질의를 연결하기 위함</li>
<li>가상 회사 데이터를 생성하고 이를 기반으로 질의응답 실험 목적</li>
<li>교육 및 프로토타입용 챗봇 구조 예제로 활용 가능함</li>
</ul>
<h2 id="사용-기술">사용 기술</h2>
<ul>
<li>Python 3.9+</li>
<li>Streamlit</li>
<li>SQLite</li>
<li>OpenAI API</li>
</ul>
<h2 id="설치-및-실행">설치 및 실행</h2>
<pre><code># 1. 저장소 클론
git clone https://github.com/KBC-1315/Talking_Potato

# 2. 라이브러리 설치
pip install -r requirements.txt

# 3. OpenAI API 키 설정
환경 변수 또는 Streamlit UI에서 직접 입력

# 4. 실행
streamlit run app.py</code></pre><h2 id="주요-기능">주요 기능</h2>
<p>1) 설정 탭</p>
<ul>
<li>회사 정보 입력</li>
<li>LLM 기반 가상 회사 데이터 생성</li>
<li>SQLite DB 저장</li>
<li>기본 관리자 계정 생성</li>
</ul>
<p>2) DB 상태 탭</p>
<ul>
<li>테이블별 데이터 개수 확인</li>
<li>저장된 샘플 데이터 확인</li>
</ul>
<p>3) 챗봇 탭</p>
<ul>
<li>DB 기반 질의응답</li>
<li>대화 문맥 유지</li>
<li>시스템 프롬프트 수정 가능</li>
<li>Agent 기반 응답 흐름 구성</li>
</ul>
<h2 id="프로젝트-구조">프로젝트 구조</h2>
<pre><code>app.py        : Streamlit 앱 진입점
core/         : 주요 로직 모듈
data/         : SQLite DB 저장 경로
requirements.txt : 의존성 목록</code></pre><h2 id="활용-방안">활용 방안</h2>
<ul>
<li>사내 문서 질의응답 챗봇</li>
<li>FAQ 자동 응답 시스템</li>
<li>SQL 기반 검색 인터페이스 실험</li>
</ul>
<h2 id="정리">정리</h2>
<p>Talking Potato는 SQL과 LLM을 결합한 챗봇 구조를 이해하기 좋은 예제 프로젝트임.
Streamlit과 OpenAI API 연동 흐름을 한 번에 파악할 수 있음.</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[Reverse Shell, VPC 활용 인바운드 차단 서버 우회]]></title>
            <link>https://velog.io/@kbc-1315/Reverse-Shell-VPC-%ED%99%9C%EC%9A%A9-%EC%9D%B8%EB%B0%94%EC%9A%B4%EB%93%9C-%EC%B0%A8%EB%8B%A8-%EC%84%9C%EB%B2%84-%EC%9A%B0%ED%9A%8C</link>
            <guid>https://velog.io/@kbc-1315/Reverse-Shell-VPC-%ED%99%9C%EC%9A%A9-%EC%9D%B8%EB%B0%94%EC%9A%B4%EB%93%9C-%EC%B0%A8%EB%8B%A8-%EC%84%9C%EB%B2%84-%EC%9A%B0%ED%9A%8C</guid>
            <pubDate>Sat, 10 Jan 2026 17:30:12 GMT</pubDate>
            <description><![CDATA[<p><img src="https://velog.velcdn.com/images/kbc-1315/post/951f1464-0d68-45fb-a48e-8e4a60113ed4/image.png" alt=""></p>
<ul>
<li>GPT 이미지생성 활용</li>
</ul>
<h1 id="연구-목적으로-작성한-글-사이버-공격이-될-수-있으니-무분별한-사용의-책임은-본인에게-있음을-명심">연구 목적으로 작성한 글, 사이버 공격이 될 수 있으니 무분별한 사용의 책임은 본인에게 있음을 명심.</h1>
<h2 id="목표">목표</h2>
<ul>
<li>인바운드 포트가 차단된 서버에 외부에서 안정적으로 SSH/VSCode 접속함</li>
<li>Reverse SSH Tunnel을 사용함</li>
<li>외부 VPS를 단일 진입 허브로 사용함</li>
</ul>
<h2 id="구조">구조</h2>
<pre><code>[Local PC]
    |
    | SSH / VSCode
    v
[VPS (공인 IP, 인바운드 허용)]
    ^
    | Reverse SSH (outbound)
    |
[Internal Server]</code></pre><hr>
<h1 id="1-vps-기본-설정">1. VPS 기본 설정</h1>
<hr>
<p>VPS 생성함 - Oracle, AWS 등 상용 서비스 : AWS Lightsail 사용하였음</p>
<ul>
<li>Linux (Ubuntu LTS)</li>
<li>공인 IP 할당됨</li>
</ul>
<p>방화벽에서 아래 포트 허용함</p>
<ul>
<li>TCP 22</li>
<li>TCP 2222</li>
</ul>
<hr>
<h1 id="2-vps-ssh-설정">2. VPS SSH 설정</h1>
<hr>
<p><code>/etc/ssh/sshd_config</code> 수정함</p>
<pre><code>AllowTcpForwarding yes
GatewayPorts yes</code></pre><p>SSH 재시작함</p>
<p><code>sudo systemctl restart ssh</code></p>
<hr>
<h1 id="3-내부-서버에서-reverse-ssh-tunnel-생성">3. 내부 서버에서 Reverse SSH Tunnel 생성</h1>
<hr>
<p>VPS 접속용 키 준비함</p>
<ul>
<li>예: vps_key.pem</li>
<li>권한 600 설정함</li>
</ul>
<p><code>chmod 600 vps_key.pem</code></p>
<p>Reverse SSH 실행함</p>
<p><code>ssh -i vps_key.pem -N -R 2222:localhost:22 vps_user@&lt;VPS_IP&gt;</code></p>
<p>의미</p>
<ul>
<li>VPS의 2222 포트를 내부 서버의 22번 SSH로 연결함</li>
<li>세션 유지 중 명령 종료되지 않음</li>
</ul>
<hr>
<h1 id="4-로컬-pc-ssh-설정">4. 로컬 PC SSH 설정</h1>
<hr>
<p>로컬 PC의 SSH config 작성함</p>
<p>파일 위치</p>
<ul>
<li>Linux/macOS: ~/.ssh/config</li>
<li>Windows: C:\Users&lt;USER&gt;.ssh\config<pre><code>Host vps
  HostName &lt;VPS_IP&gt;
  User vps_user
  IdentityFile ~/.ssh/vps_key.pem
  IdentitiesOnly yes
</code></pre></li>
</ul>
<p>Host internal-server
    HostName localhost
    User internal_user
    Port 2222
    ProxyJump vps</p>
<pre><code>--------------------------------------------------
# 5. 접속 테스트
--------------------------------------------------

ssh internal-server

--------------------------------------------------
# 6. autossh로 터널 자동 유지
--------------------------------------------------</code></pre><p>sudo apt update
sudo apt install -y autossh</p>
<p>autossh -M 0 -N <br>  -o ServerAliveInterval=30 <br>  -o ServerAliveCountMax=3 <br>  -i vps_key.pem <br>  -R 2222:localhost:22 <br>  vps_user@<VPS_IP></p>
<pre><code>--------------------------------------------------
# 7. systemd로 완전 자동화(재부팅시)
--------------------------------------------------

`/etc/systemd/system/reverse-ssh.service`
</code></pre><p>[Unit]
Description=Reverse SSH Tunnel
After=network-online.target
Wants=network-online.target</p>
<p>[Service]
ExecStart=/usr/bin/autossh -M 0 -N <br>  -o ServerAliveInterval=30 <br>  -o ServerAliveCountMax=3 <br>  -i /path/to/vps_key.pem <br>  -R 2222:localhost:22 <br>  vps_user@<VPS_IP>
Restart=always
RestartSec=10</p>
<p>[Install]
WantedBy=multi-user.target</p>
<p>sudo systemctl daemon-reload
sudo systemctl enable reverse-ssh
sudo systemctl start reverse-ssh</p>
<p>systemctl status reverse-ssh
```</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[2-1. Oxford Cybersecurity Program : Silverstone F1]]></title>
            <link>https://velog.io/@kbc-1315/2-1.-Oxford-Cybersecurity-Program-Silverstone-F1-hnhr7ln9</link>
            <guid>https://velog.io/@kbc-1315/2-1.-Oxford-Cybersecurity-Program-Silverstone-F1-hnhr7ln9</guid>
            <pubDate>Wed, 03 Sep 2025 13:03:36 GMT</pubDate>
            <description><![CDATA[<p><img src="https://velog.velcdn.com/images/kbc-1315/post/0936626a-f0a0-4bda-8ea2-4804726e085e/image.png" alt=""></p>
<h1 id="silverstone-circuit">Silverstone Circuit</h1>
<ul>
<li><strong>위치</strong>: 영국 노샘프턴셔(Northamptonshire)와 버킹엄셔(Buckinghamshire) 경계에 위치  </li>
<li><strong>개장</strong>: 1948년, 제2차 세계대전 당시 비행장이었던 RAF 실버스톤을 개조하여 사용  </li>
<li><strong>길이</strong>: 약 5.89 km (현행 Grand Prix Circuit 기준)  </li>
<li><strong>특징</strong>:<ul>
<li>빠른 고속 코너와 긴 직선 구간이 어우러진 레이아웃  </li>
<li>대표적인 코너: Copse, Maggots–Becketts–Chapel, Stowe  </li>
<li>드라이버와 팬 모두에게 &quot;스피드의 성지&quot;로 불림  </li>
</ul>
</li>
<li><strong>주요 이벤트</strong>:<ul>
<li>1950년 최초의 F1 월드 챔피언십 그랑프리 개최  </li>
<li>현재도 매년 F1 영국 그랑프리 개최지로 사용  </li>
<li>MotoGP, FIA WEC 등 다양한 국제 모터스포츠 이벤트 개최  </li>
</ul>
</li>
<li><strong>수용 인원</strong>: 약 150,000명 이상  </li>
</ul>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/6ca8ebb3-1218-4a6d-9560-a73784484516/image.png" alt=""></p>
<p>결국은 <strong>F1 Single Seater</strong> 프로그램으로 하고 왔다. 한화 기준으로 50만원 정도....(이것도 첫타임 할인 풀로 받은거다)</p>
<p>나름 수동 운전도 많이 해봤고 자신 있게 들어갔지만 시동만 3번 꺼먹고왔다. 이게 군용차 민간차랑 다르게 엑셀과 브레이크 압력이 굉장히 많이 필요하다. 다리가 아플정도로... 그리고 굉장히 페달이 예민해서 컨트롤하기 어려웠다</p>
<iframe width="560" height="315"
src="https://www.youtube.com/embed/qbjTlAP-zlc" 
title="YouTube video player" frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe>

<iframe width="560" height="315"
src="https://www.youtube.com/embed/K2LpGuXEZms" 
title="YouTube video player" frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe>

<p><img src="https://velog.velcdn.com/images/kbc-1315/post/2754c35a-bf5d-43df-88fe-c8f1d23e2f0f/image.png" alt=""></p>
<p>숙박은 최고의 시설 Hilton Hotel에서 1박에 20만원 정도 생각보다 저렴하게 이용하고 왔다. F1 영상보면 스타팅 그리드 왼쪽 건물이 힐튼 호텔이었다... 신기...</p>
<p>옥스퍼드로 돌아와야하는데 돌아오는 날 일요일이어서 버스가 운행을 안했다... 그래서 가장 가까운 버스가 다니는 지역으로 우버타고 이동하고 거기서부터 다시 옥스퍼드로 버스타고 복귀했다.</p>
<p>언제 또 F1 서킷을 와보겠나... 후회없는 경험이었다.</p>
<p>가기 전 반드시 박물관 예약은 하시고, 안에 있는 시뮬레이터는 관심이 있으면 하시길, 힐튼 호텔 옆 기념품 샵에 판매하는 가짓수가 더 많지만 특가 상품 제외하고는 온라인 샵이 더 저렴한 편이다.</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[1-5. Oxford Cybersecurity Program : 숙소 구하기]]></title>
            <link>https://velog.io/@kbc-1315/1-4.-Oxford-Cybersecurity-Program-%EC%88%99%EC%86%8C-%EA%B5%AC%ED%95%98%EA%B8%B0</link>
            <guid>https://velog.io/@kbc-1315/1-4.-Oxford-Cybersecurity-Program-%EC%88%99%EC%86%8C-%EA%B5%AC%ED%95%98%EA%B8%B0</guid>
            <pubDate>Tue, 02 Sep 2025 21:50:56 GMT</pubDate>
            <description><![CDATA[<h2 id="oxford-숙소-옵션-총정리">Oxford 숙소 옵션 총정리</h2>
<p>Oxford 체류 준비 중인 사람들을 위해, 다양한 <strong>숙소 타입</strong>별로 링크와 함께 간략히 정리한다. 공식 페이지와 신뢰할 만한 플랫폼을 기반으로 설명한다.  </p>
<h3 id="1-kellogg-college-제공-학내-숙소">1. <strong>Kellogg College 제공 학내 숙소</strong></h3>
<ul>
<li><strong>풀타임, 파트타임, 단기 체류용 숙소</strong>를 모두 제공한다.  <ul>
<li><strong>Full-time Student Accommodation</strong>: 셀프 케이터링(주방, 냉장고, 정수기 등)을 갖추고 있으며 대부분 공유 욕실, 일부 인-스위트 룸도 제공한다. 신청 방법은 [Kellogg College 숙소 페이지]에서 확인한다. (<a href="https://www.kellogg.ox.ac.uk/kellogg-college-experience/accommodation/full-time-accommodation/?utm_source=chatgpt.com">kellogg.ox.ac.uk</a>)  </li>
</ul>
</li>
<li><strong>Short-stay Accommodation</strong>: 단기 방문객이나 alumni에게도 일정 요율로 개방한다. (<a href="https://www.kellogg.ox.ac.uk/kellogg-college-experience/accommodation/?utm_source=chatgpt.com">kellogg.ox.ac.uk</a>)  </li>
<li><strong>Donald Michie House (B&amp;B 스타일)</strong>: Kellogg 캠퍼스 중심부에 위치한 단기 숙소로, 인-스위트 객실과 공용 라운지, 주방, TV, 자전거 보관, Wi-Fi 등을 제공한다. 아침 식사는 포함되지 않는다. (<a href="https://www.universityrooms.com/en-GB/city/oxford/college/kellogg?utm_source=chatgpt.com">universityrooms.com</a>)  </li>
</ul>
<h3 id="2-oxford-university-전체대학-제공-숙소">2. <strong>Oxford University 전체/대학 제공 숙소</strong></h3>
<ul>
<li>대부분의 대학(College)들은 대학원생을 포함해 숙소 옵션을 제공하며, [University Accommodation Office]를 통해 부부나 가족용 숙소도 지원한다. (<a href="https://www.ox.ac.uk/students/life/accommodation?utm_source=chatgpt.com">ox.ac.uk</a>)  </li>
<li>다만, 2018-19년 기준으로 전체 대학원 신입생 중 약 <strong>72%</strong>만이 대학 혹은 대학 측 숙소를 확보했고, <strong>53%</strong> 정도만이 전체 대학원생 수준에서 제공받았다고 한다. 즉, 보장이 완전하지는 않는다. (<a href="https://www.ox.ac.uk/admissions/graduate/after-you-apply/accommodation?utm_source=chatgpt.com">ox.ac.uk</a>)  </li>
</ul>
<h3 id="3-privately-rented-housing-개인-임대">3. <strong>Privately-rented housing (개인 임대)</strong></h3>
<ul>
<li>Oxford 시내에는 많은 <strong>주택/플랫 렌트</strong> 옵션이 있으며, Rightmove, Zoopla, SpareRoom 등이 대표적이다. 주로 <strong>1년 단위 계약</strong>이며 term-time보다 비쌀 수 있다. 종종 term 외 기간에도 머물려는 경우 유리하다. (<a href="https://www.ox.ac.uk/students/life/accommodation?utm_source=chatgpt.com">ox.ac.uk</a>)  </li>
<li><strong>주의사항</strong>: 렌트 시장은 매우 변동성이 크며 외국에서 접근 시 사기 사례가 있으므로 주의해야 한다.</li>
<li>외국에 있는 경우는 현지 에이전트가 대신 집을 봐주는 서비스도 있긴 하지만, 그렇게 믿을 만하지는 않다</li>
<li>단체로 Roomshare를 알아봐서 Flat이나 House, Semi-detached 등의 렌트 방식을 알아봤는데 영국 Regulation에 의해서 외국인의 경우 영국 내 직장인의 보증과 함께 재정 수입원 증명 등의 절차가 필요해서 거의 불가능해 보인다.(<a href="https://www.rightmove.co.uk/">https://www.rightmove.co.uk/</a>)</li>
</ul>
<h3 id="4-에어비앤비">4. 에어비앤비</h3>
<ul>
<li>에어비앤비 플랫폼을 통해 일반 주택을 하우징 포함해서 임대하는 식으로 하는데 이것도 사기도 많고... 역시나 좋은 위치, 가격에는 매물이 없다.</li>
<li>같은 프로그램에 다른 사례를 보면 괜찮은 조건에 에어비앤비 계약을 한 경우도 있으니 에어비앤비를 이용하고자 한다면, 매물을 잘 보고 있어야 할 것 같다.</li>
<li>비용 : 최소 월 200이상</li>
</ul>
<h3 id="5-민간-학생-기숙사">5. 민간 학생 기숙사</h3>
<ul>
<li>현대식 건물 기반의 <strong>공유 플랫, 스튜디오, en-suite</strong> 등이 있는 옵션<ul>
<li><strong>Amber Student</strong>(<a href="https://amberstudent.com/places/search/oxford-1811023030854?utm_source=chatgpt.com">amberstudent.com</a>)  </li>
<li><strong>University Living</strong>(<a href="https://www.universityliving.com/united-kingdom/city/oxford?utm_source=chatgpt.com">universityliving.com</a>) 
<a href="https://nooc.org.uk/">https://nooc.org.uk/</a></li>
</ul>
</li>
<li>입주 경쟁이 치열하므로 <strong>사전에 확보하는 것이 중요하다</strong>.  </li>
<li>비용은 상대적으로 저렴하지만 옵션에 따라 150-250만원까지 올라간다</li>
<li>개인 욕실이 그렇게 흔하지 않다</li>
</ul>
<hr>
<p>컬리지 기숙사, Oxford 대학 기숙사, 민간 기숙사가 모두 자리가 없고, 에어비앤비도 마땅한 매물이 없어 Roomshare를 위해 모인 타대생 6명은 결국 부동산을 뒤져봤다(결국 계약 못함)</p>
<h1 id="렌트-계약-실패">렌트 계약 실패</h1>
<ul>
<li><p>개인 욕실이 있을것</p>
</li>
<li><p>5-6명 수용이 가능할것</p>
</li>
<li><p>타입이 House, Semi-detached, Flat 등 우선</p>
</li>
<li><p>Kellogg College와 거리가 가까울것
<img src="https://velog.velcdn.com/images/kbc-1315/post/3e6e26be-a40e-4d57-a206-c6909fc04497/image.png" alt=""></p>
</li>
<li><p>위 선정기준을 가지고 엄청나게 찾아보고 연락을 돌려봤지만, 결국에는 외국인이라 보증인이 있어야하고 무엇보다 <strong>단기 렌트</strong>는 받지 않는다!</p>
</li>
<li><p>1년부터는 장기, 그 미만은 단기라고 부르는듯 하다.
아래 두 사이트 참고
<a href="https://homelet.co.uk/tenants/tips-for-tenants/tips-for-being-referenced">https://homelet.co.uk/tenants/tips-for-tenants/tips-for-being-referenced</a>
<a href="https://homelet.co.uk/tenants/tips-for-tenants/what-documents-do-you-need-to-rent-a-house-or-flat">https://homelet.co.uk/tenants/tips-for-tenants/what-documents-do-you-need-to-rent-a-house-or-flat</a></p>
</li>
<li><p>결국에는... 부동산 에이전시에도 다이렉트로 문의하고 했지만 못구했다</p>
</li>
</ul>
<hr>
<h1 id="국내-대행-업체-스튜던트-홈즈">국내 대행 업체 스튜던트 홈즈</h1>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/897a8ec0-7056-4ed7-bd75-c0bed80fda6e/image.png" alt=""></p>
<p><a href="https://www.studenthomes.co.kr/">https://www.studenthomes.co.kr/</a></p>
<ul>
<li>하도 사기가 많아서, 초반에는 진짜 못믿었다</li>
<li>그래서 해본 검증은 아래와 같다<ul>
<li>강원도청 창조경제혁신센터 등록 사업이라길래 검색해보니 실제로 혁신 창업가라고 이쪽 대표가 뜸</li>
<li>한국소비자원, 기타 신고하는 사이트에 검색(깨끗함)</li>
<li>리뷰를 죄다 읽어봄</li>
<li>구직 사이트에 채용 공고도 올라와 있음</li>
</ul>
</li>
<li>결국 여길 이용해보기로 하고 못참고 물어봤다<ul>
<li>수수료를 안받고도 사업을 유지할 수 있는 이유는 해외 숙소들에서 비용을 받기 때문에 학생들에게서 별도로 받지 않는다고 함</li>
<li>업체를 이용해도, 하지 않아도 숙소 비용이 동일했음</li>
</ul>
</li>
</ul>
<h1 id="the-park-oxford">The Park, Oxford</h1>
<ul>
<li>그 이후 플랫폼 카카오톡 채널을 이용해 문의 신청을 했고 꽤나 빠르게 답장이 왔다</li>
<li>이부분은 약간 스크립트 느낌이 나기도 하는데 Oxford에 숙소는 한군데 있고, 지금 자리가 많지 않다!</li>
<li>비용은 대략 월 200만원 수준이고, 거리고 꽤나 멀지만(도보 1시간반), 개인 욕실에 시설이 괜찮아보여서 6명이 함께 계약했다.</li>
<li>버스 타고도 50분 걸리는 곳에 숙소가 있다
<img src="https://velog.velcdn.com/images/kbc-1315/post/d383e3c8-5e03-4b73-860e-cf0ee89c4204/image.png" alt="진짜 멀다"></li>
<li>나중에 입주하고 안거지만 미리 스포하자면, 학생들이 여기 대행 업체를 통해 계약하게 되면, 이런 구조가 된다<blockquote>
<p>학생 - 스튜던트홈즈 - Uninst - Almero(숙소 관리)</p>
</blockquote>
</li>
<li>이게 상당히 많은 회사가 껴있다보니 뭔가 좀 버벅이는 느낌이 있긴 하지만 그래도 스튜던트홈즈 측에 의사를 전달하면 진행은 된다.
<img src="https://velog.velcdn.com/images/kbc-1315/post/fd434d91-716d-40ba-821c-1940a2d5860c/image.png" alt=""></li>
<li>여러 정보를 전달하면 메일로 요렇게 확인이 온다.</li>
<li>5,760파운드 = 약 1,100만원... 이것도 150일이고 나머지는 알아서 해야한다.(글쓴이의 경우 같은 숙소에 얼리체크인 결제를 통해 입주함)</li>
<li>시설 등은 홈페이지에서 제공하는 3D 뷰 보기를 이용하면 엄청 사실적으로 볼 수 있다(그거랑 똑같더라구요)
<a href="https://www.theparkoxford.com/">https://www.theparkoxford.com/</a></li>
<li>결과적으로 얼리체크인 155만원 + 정기 입주 비용 1,100만원 포함해서 약 6개월에 1,255만원에 컨택 완료했다...(생활비는 어쩌지)</li>
<li>대부분의 단기 렌트의 경우 숙소 비용을 선불로 요구한다. The Park의 경우에도 거의 선납이었는데, 3번에 나눠 선납을 해야한다.</li>
<li>글쓴이의 경우 400, 400, 200으로 선납 일정이 7월말, 9월초, 10월 중순으로 잡혔다.</li>
<li>이 부분이 가장 부담이 컸다...</li>
<li>부동산 거래시 이렇게 선납을 요구하면 사기가 많다지만, 외국인의 경우 그리 선택지가 많지 않은듯 보인다...</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[1-4. Oxford Cybersecurity Program : 개인 처방약 준비]]></title>
            <link>https://velog.io/@kbc-1315/1-4.-Oxford-Cybersecurity-Program-%EA%B0%9C%EC%9D%B8-%EC%B2%98%EB%B0%A9%EC%95%BD-%EC%A4%80%EB%B9%84</link>
            <guid>https://velog.io/@kbc-1315/1-4.-Oxford-Cybersecurity-Program-%EA%B0%9C%EC%9D%B8-%EC%B2%98%EB%B0%A9%EC%95%BD-%EC%A4%80%EB%B9%84</guid>
            <pubDate>Tue, 02 Sep 2025 20:35:43 GMT</pubDate>
            <description><![CDATA[<blockquote>
<p>세줄 요약</p>
</blockquote>
<ol>
<li>먹는 약이 장기간 처방이 가능한지 반드시 확인</li>
<li>출국 직전 약 처방 받기</li>
<li>영문처방전과 약 설명서 챙기기</li>
</ol>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/7c413286-a58e-4f1d-8484-1b9c2f8c7707/image.png" alt=""></p>
<h1 id="1-먹는-약-장기-처방-가능-여부-확인">1. 먹는 약 장기 처방 가능 여부 확인</h1>
<p>나는 아무 약이나 &quot;6개월 나갈거라 6개월분 처방해주세요!&quot;하면 주는줄 알았다. 근데 웬걸, 내가 먹는 약은 최대 3개월 처방으로 제한이 되어있다는 것이다... 나는 6개월 나가야하는데... 따라서, 반드시 사전에 다니는 병원에 내원하여 상담을 받아보시길 바란다.</p>
<h1 id="2-출국-직전-약-처방-받기">2. 출국 직전 약 처방 받기</h1>
<p>두 가지 방법이 있었다.</p>
<ul>
<li>종합병원(2차병원) 급으로 가서 장기 처방받기</li>
<li>1회에 한해 3개월 | 3개월 2번 처방받기</li>
</ul>
<p>모두 이 방법이 적용 가능한지는 알 수 없으니 반드시 의사선생님께 문의...</p>
<p>출국까지 기간이 많지 않아 검사며 결과며 진료며 기다릴 수 없는 나는 2번 옵션으로 2번 내원하여 3개월분씩 나눠서 처방받았다</p>
<h1 id="3-영문처방전-및-약-설명서-챙기기">3. 영문처방전 및 약 설명서 챙기기</h1>
<p>웬 아시안 남자가 알약을 무더기로 들고가면 수상할까봐 영문처방전이랑 약 영문 설명서를 챙겼다.</p>
<ul>
<li>영문 설명서는 웬만한 약에 같이 있어서 별다른 신경 쓸 필요가 없었다</li>
<li>영문 처방전은 병원 원무과에 요청을 드리니 가물가물하신 기억을 되짚어 일정 비용을 받고 작성해주시고 직인까지 찍어주셨다.</li>
</ul>
<hr>
<p><strong><em>사실 지금 생각하면 입국 심사때 이거 다 안보긴 했다...</em></strong></p>
<p>아무튼 처방약도 6개월치 해결</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[1-3. Oxford Cybersecurity Program : 비자 발급]]></title>
            <link>https://velog.io/@kbc-1315/1-3.-Oxford-Cybersecurity-Program-%EB%B9%84%EC%9E%90-%EB%B0%9C%EA%B8%89</link>
            <guid>https://velog.io/@kbc-1315/1-3.-Oxford-Cybersecurity-Program-%EB%B9%84%EC%9E%90-%EB%B0%9C%EA%B8%89</guid>
            <pubDate>Tue, 02 Sep 2025 20:12:25 GMT</pubDate>
            <description><![CDATA[<blockquote>
<p>세줄 요약</p>
</blockquote>
<ol>
<li>UK ETA 앱을 설치한다</li>
<li>여권에 휴대폰을 가져다 댄다(실물)</li>
<li>결제한다</li>
</ol>
<p>아니 난 학생 비자로 가는줄 알았더니, 영국 학생 비자는 풀타임 아니면 어려우시단다... 그래서 여행 비자를 발급 받기로 했다.
영국의 경우 최근부터 전자 여행 허가제로 변경되어 손쉽게 6개월 미만에 대해 비자를 신청할 수 있다. 웹도 있고 앱도 있는데 앱이 더 쉬워서 앱으로 했다.</p>
<h1 id="1-uk-eta-앱을-설치한다">1. UK ETA 앱을 설치한다</h1>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/5d46dded-1506-43d4-a494-7f53f99c0ee5/image.png" alt=""></p>
<h1 id="2-여권-정보를-등록한다">2. 여권 정보를 등록한다</h1>
<p>실물 여권을 안가지고 여권 사진만 가지고 있어 사진으로 등록하면 되겠지~라는 안일한 생각으로 어림도 없이 인식이 안되고(사실 그냥 이미지로 인식이 잘 안되는듯), Plan B로 여권에 있는 전자칩을 가지고 여권 정보를 등록해야 했다. 이게 휴대폰마다 인식 칩이 있는 위치가 달라서 인식 칩이 있을거라고 생각되는 곳에 대고 가만히 기다리면 등록이 완료된다.(쉽다!)</p>
<h1 id="3-또-결제를-한다">3. 또 결제를 한다</h1>
<p>가격은 16파운드로 환율따라 다르겠지만 대략적으로 3만원 정도 했다. 눈물을 머금고 결제...</p>
<h1 id="4-eta-발급-확인-메일을-받는다">4. ETA 발급 확인 메일을 받는다</h1>
<p>한 2-3일 까먹고 있으면 등록한 메일로 발급되었다는 확인 메일을 받는다. 글쓴이는 이번이 비행기 타고 처음 해외 나가는거라 혹시 몰라서 메일도 프린트해서 갔는데, 이건 안해도 되는듯하다...</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[1-2. Oxford Cybersecurity Program : 항공편]]></title>
            <link>https://velog.io/@kbc-1315/1-2.-Oxford-Cybersecurity-Program-%ED%95%AD%EA%B3%B5%ED%8E%B8</link>
            <guid>https://velog.io/@kbc-1315/1-2.-Oxford-Cybersecurity-Program-%ED%95%AD%EA%B3%B5%ED%8E%B8</guid>
            <pubDate>Tue, 02 Sep 2025 19:56:52 GMT</pubDate>
            <description><![CDATA[<blockquote>
<p><em>세줄 요약</em>
아시아나 앱을 깐다
일정과 좌석을 고르고 결제한다
눈물을 흘리면서 결제한다</p>
</blockquote>
<p>글쓴이는 프로그램에서 항공편 일괄 예약을 받아서 일단 일정과 이용할 항공편은 Fix가 되어있었다. 근데 웬걸 할게 더 있었네, 아래 절차는 <strong>여행사에서 일괄로 예매를 해줬어요!</strong>의 경우에 실시하면 될듯하다.</p>
<h2 id="1-아시아나-앱-설치">1. 아시아나 앱 설치</h2>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/73929eb6-e785-49f5-9005-79899464e47f/image.png" alt="">
아시아나 홈페이지나 어플을 설치한다</p>
<h2 id="2-예약-조회">2. 예약 조회</h2>
<p>예약 조회 탭으로 들어간다.
아마 처음에는 로그인을 해도 항공권이 안뜰건데... 이건 아시아나 회원 번호를 등록을 해줘야한다.</p>
<p>등록을 위해서 항공편 예약 번호를 꼭꼭 미리 알아놔야한다.(e.g. DDD777)</p>
<p>예약 번호랑 필요한 정보를 뚝딱 입력하면 비회원이어도 조회를 할 수 있다.</p>
<h2 id="3-내-계정에-항공권-연동">3. 내 계정에 항공권 연동</h2>
<p>간단하다. 조회된 항공권에 아시아나 계정 연동하는 버튼이 있다. 그거 누르고 마이페이지에서 조회되는 아시아나 회원 번호를 입력하면 연동이 완료된다. 이후에는 내 예약 조회하면 이 항공권이 같이 조회된다.</p>
<h2 id="4-좌석-선택">4. 좌석 선택</h2>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/c427ab0c-d049-4819-ba2c-926c446700e4/image.png" alt="">
요 아름다운 비행기 친구에서 좌석 지정을 미리 해놓아야 한다.</p>
<p>편한 좌석은 돈을 더 내고 예약해야 한다.(2일전인데도 남아있으면 그때부터 무료로 가능)</p>
<ul>
<li>빨리 내리는 좌석(유료)</li>
<li>비상구 좌석(편함 - 유료)</li>
<li>좀 더 넓은 좌석(유료)</li>
</ul>
<p>이런 좌석들이 있다. 싸면 6만원에서 비싸면 16만원 정도까지 추가 결제가 필요하다. 불쌍한 글쓴이는 무료 좌석으로 골라서 예약했다. 가는 항공편에 일행이 있어 가운데 3칸중에 가운데 좌석이 당첨되었다.(멜라토닌 먹고 기절해서 별로 안불편했음)</p>
<hr>
<p>이외에 셀프 체크인은 그닥 필수는 아니어보여서 패스</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[1-1. Oxford Cybersecurity Program : 펀딩 구하기]]></title>
            <link>https://velog.io/@kbc-1315/1-1.-Oxford-Cybersecurity-Program-%ED%8E%80%EB%94%A9-%EA%B5%AC%ED%95%98%EA%B8%B0</link>
            <guid>https://velog.io/@kbc-1315/1-1.-Oxford-Cybersecurity-Program-%ED%8E%80%EB%94%A9-%EA%B5%AC%ED%95%98%EA%B8%B0</guid>
            <pubDate>Tue, 02 Sep 2025 19:40:08 GMT</pubDate>
            <description><![CDATA[<p><img src="https://velog.velcdn.com/images/kbc-1315/post/69473472-ba31-49c9-a880-30937e2f0ef6/image.png" alt=""></p>
<p>2025년 초 메일을 통해 위 프로그램 참여를 지도교수님께 권유받고 신청서, 교수님 추천서, 학업 계획서, 자기소개서 및 기타 서류를 뚝딱 준비해서 신청했다.</p>
<p>그래서 사실, 운이 좋게도 학교 탐색, 펀딩 탐색 등의 단계는 운이 좋게도 넘어갈 수 있었다.</p>
<p><a href="https://icsp.korea.ac.kr/icsp/global/notice.do?mode=view&amp;articleNo=769936&amp;article.offset=0&amp;articleLimit=10&amp;totalNoticeYn=N&amp;totalBoardNo=">공고문 링크</a></p>
<h1 id="1-과기정통부-옥스퍼드-사이버보안-프로그램">1. 과기정통부 옥스퍼드 사이버보안 프로그램</h1>
<p>정식 명칭은 이게 아니긴 한데 편한대로 그냥 줄여서 말하겠다.
큰 분류로는 <strong>디지털혁신인재 단기집중역량강화</strong> 사업인데, 이미 캐나다 토론토 대학, 미국 카네기 멜론 등 시행 중인 학교가 여럿있었다.</p>
<p>근데, <strong>영국 옥스퍼드</strong>는 이번 프로그램이 1회차였다.
개요는 아래와 같다</p>
<blockquote>
</blockquote>
<ul>
<li>프로그램명 : 글로벌 사이버보안 인재 양성 교육프로그램</li>
<li>교육 기간 : 2025년 9월 ~ 2026년 2월(약 6개월) [2025.08.25 ~ 2026.02.10]</li>
<li>선발 인원 : 30명 내외</li>
<li>지원 자격 : 대학원생, 청년 프리랜서, 자립준비청년</li>
<li>지원 항목 : 교육비, 체재비, 항공료, 비자발급 비용, 여행자 보험료(5,500만원 수준)</li>
<li>참여 교수진 : Kellogg College, University of Oxford 소속 Computer Science 교수진</li>
</ul>
<p>아무튼, 영국에 나가서 생활해보는게 인생 버킷리스트 중 하나였고, 박사과정 어차피 의무 인턴도 졸업 요건에 있으니 지원해보기로 했다.</p>
<h1 id="2-선발-과정">2. 선발 과정</h1>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/f979451a-7ea9-419f-8863-0c4b68ff23da/image.png" alt=""></p>
<p>전체적인 흐름은 위와 같다. 글쓴이는 경제학 전공자로(AI 대학원 재학) 정보보안 및 수학에 대한 큰 베이스가 없고, 한번도 수업을 들어본 적이 없는 수준인것을 먼저 밝힌다.</p>
<h2 id="2-1-서류전형">2-1. 서류전형</h2>
<p>크게 신경써야할 부분은 아래와 같았다.</p>
<blockquote>
</blockquote>
<ul>
<li>프로그램 신청서 스캔본(국문)</li>
<li>개인정보 활용 동의서 스캔본</li>
<li>지도교수 추천서</li>
<li>학부 졸업증명서 및 성적증명서(국문)</li>
<li>자기소개서 자유양식(영문)</li>
<li>공인 영어시험 및 기재 내용 증빙</li>
<li>연구계획서(글쓴이의 경우 국문)</li>
<li>대학원 재학증명서(국문)</li>
<li>대학원 성적증명서(국문)</li>
</ul>
<p>일부는 서류전형 때 제출하는것이 아니고 준비해야할 서류를 전체적으로 나열해보았다. 각 전형별로 필요한 서류는 공고문 참고하길 바란다.</p>
<p>다른 행정 서류 및 추천서 등등은 각 시스템별로 상이하기에 언급하지 않겠다.</p>
<p>자기소개서 부분은 아무래도 비전공이기 때문에, 정보보안에 대해 진심이고 이 분야에 대해 연구하게 된 개연성과 준비한 과정 그리고 하고자 하는 연구로 자연스럽게 이어지도록 하는 것을 목표로 작성하였다.</p>
<p><strong>생각도 못했지만 다행히 합격 메일이 왔다</strong></p>
<h2 id="2-2-실기전형-및-면접평가">2-2. 실기전형 및 면접평가</h2>
<p>아니 이미지에는 따로 있던데 왜 같이 있나요? 라고 물으신다면, 역시 같은 날 있어서 그랬다고 답을 드리겠습니다.</p>
<p>덜컥 합격 메일을 받고 나니, 정말 열심히 시험을 준비해야할듯한 부담감이 강했다.</p>
<p>시험 분야는 정보보안 또는 수학(선형대수) 중 한 분야를 골라 주어진 시간 내에 문제를 풀면 되는거였다. 글쓴이는 당연히 문돌이라 정보보안 분야를 골라 지정된 문제 후보(공지사항에 알려주시더라구요)를 풀어보는 식으로 진행했다. 문제 은행 느낌으로 진행했고 뭔가 뭔가, 이렇게 쉬워도 되나? 라는 생각이 들어 개념서 위주로도 암기했다.</p>
<p>정보보안 분야 문제는 정보보안산업기사 수준으로 선택지가 기사보다는 고르기가 훨씬 쉽다. 글쓴이는 정보처리기사, 빅데이터분석기사를 취득했고, 정보보안기사 취득 준비중에 있어 쉬울 수도 있긴 하다.</p>
<hr>
<p>준비가 끝나고 불쌍한 지방러는 고려대 시험 겸 면접장으로 이동했다. 아쉽게도 교통편은 지원이 안되지만 점심은 지원이 되어 도시락을 맛있게 먹었다.</p>
<blockquote>
</blockquote>
<p>시험은 생각보다 쉬웠다...</p>
<p>너무 문제가 쉬워서 당황했다. 실수로 틀리거나 하면 이제 못보겠구나 싶었다.</p>
<p>그래서 이제 <strong>면접에서 갈리겠구나</strong> 싶었다.&#39;</p>
<p>하지만, 애초에 시험을 보러 온 인원이 30명보다 조금 더 많은 수준이라서 그렇게 경쟁이 엄청나진 않아보였다.</p>
<p>오전에 실기 시험을 보고 오후에 바로 면접 평가가 이어지는 구성으로 진행되었다.</p>
<p>운이 좋게도 이른 순번을 배정받아 얼마 기다리지 않고 면접을 보고 일찍 집에 갈 수 있었다.</p>
<p>면접장에는 고려대학교 교수님 2분이 계시고, 전반적으로 영어 실력을 보기 위해 답변은 무조건 영어로 진행했다.</p>
<ul>
<li>자기 소개</li>
<li>지원 동기(경제학 전공했으면서 왜 정보보안 하려는지?)</li>
<li>향후 연구</li>
</ul>
<p>크게는 위 3가지 질문에 대해 영어로 답변을 했고, 글쓴이는 최대한 스크립트 없이 키워드 기반으로 자유롭게 답변하는 스타일이라 주절주절 답변하고 나왔다.</p>
<p>조마조마 몇 주를 기다리다가 다행히도 <strong>합격 메일을 받았다</strong></p>
<h2 id="2-3-오리엔테이션">2-3. 오리엔테이션</h2>
<p>합격하고 한 달 준비하다가, 고려대에서 OT가 있어 다녀왔다(왕복 1회 10만원 ㅠㅠ).</p>
<p>합격자 구성은 절반 정도는 고려대 자대생, 나머지 절반은 타대생으로 구성되어 있었다.</p>
<p>안내 사항은 주로 아래와 같다.</p>
<ul>
<li>프로그램 진행 개요(수업, 프로젝트 등)</li>
<li>생활 안내(숙소, 교통 등)</li>
<li>파견 전 준비 사항 안내</li>
</ul>
<p>교육 프로그램과 같은 경우 현지 Kellogg 컬리지 교수님들께서 강의하시는 수업들과 프로젝트를 함께 하는 구성이었다. 다만, 숙소 컨택이 매우 힘드니 미리미리 알아보라고 안내가 있었다. 그때부터 무서웠다. 마지막으로 파견 전 준비 사항으로 Coursera 강의 수강 후 수료증 증빙하는 프로세스가 필요했다.(Cousera는 강의 듣는건 무료여도 수료증 받으려면 결제를 해야하더라구요...)</p>
<p>숙소 컨택이 사전에 알아봤을때 대부분 가능한 곳이 없어 룸쉐어 관심 있는 학생들을 모아 진행하기로 했다. 이건 숙소 편에서 더 자세히 다루도록 하겠다.</p>
<h2 id="2-4-체재비생활비">2-4. 체재비(생활비)</h2>
<p>가장 큰 부분이 이건데, 사실 프로그램에서 항공편이나 보험, 교육비는 해결해줘서 다행이었다. 다만, 물가가 비싸기로 유명한 영국인지라 밥이라도 안 굶고 다니려면 어떡해야하나 싶었다.</p>
<p>글쓴이는 두 가지 수입원이 있다.</p>
<ul>
<li>본 교육 프로그램에서 지원받는 체재비</li>
<li>원 소속(GIST)에서 연구 프로젝트 참여를 통해 받는 인건비</li>
</ul>
<p>체재비의 규모가 모든 숙소 비용을 포함한 생활비를 감당하기에는 역부족이다. 따라서, GIST에서 진행하던 연구 프로젝트의 인건비를 통해 지도교수님이 배려해주셔서 해결할 수 있었다.</p>
<p>다만, 연구 과제별 담당 기관 및 과제별 수행 가능 요건이 달라 모든 과제 담당자에게 연락하여 수혜 가능 여부를 확인해야 했다. 예를 들어, 어느 과제는 국내 체류를 해야만하거나 그런 제약 조건이 붙어 있으면 수혜가 불가능하다. 글쓴이의 경우 몇몇 과제에 대해 명시적으로 지급이 불가하거나 관련 규정이 없을 경우 그냥 안받고, 문제가 없는 과제에 대해서만 받기로 되었다.</p>
<blockquote>
</blockquote>
<p>고려대 사업단 측에서는 일단 다른 연구과제 측에서 충돌만 나지 않는다면 체재비 지급에는 큰 문제가 없다고 한다</p>
<hr>
<p>아무튼 이렇게 해서, 교육비, 항공편, 보험, 숙소 비용, 생활비 문제는 해결되었다. 아직도 다른 준비할게 엄청 많다...</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[웹 보안] Google은 최고의 해킹 툴]]></title>
            <link>https://velog.io/@kbc-1315/%EC%9B%B9-%EB%B3%B4%EC%95%88-Google%EC%9D%80-%EC%B5%9C%EA%B3%A0%EC%9D%98-%ED%95%B4%ED%82%B9-%ED%88%B4</link>
            <guid>https://velog.io/@kbc-1315/%EC%9B%B9-%EB%B3%B4%EC%95%88-Google%EC%9D%80-%EC%B5%9C%EA%B3%A0%EC%9D%98-%ED%95%B4%ED%82%B9-%ED%88%B4</guid>
            <pubDate>Fri, 25 Jul 2025 08:10:09 GMT</pubDate>
            <description><![CDATA[<p><img src="https://velog.velcdn.com/images/kbc-1315/post/0b3c0db1-ef55-4023-b470-be33d95e6869/image.png" alt=""></p>
<h2 id="1-개요">1. 개요</h2>
<ul>
<li>특정 사이트에서 내부 게시판 자료에 접근할 수 있는지 점검하던 중, <code>로그인 후에만 접근 가능한 게시판 파일</code>을 직접 다운로드할 수 있는 취약점을 발견함</li>
<li>특히 다음과 같은 URL 구조를 통해, 로그인 여부와 관계없이 파일이 다운로드됨을 확인함:</li>
</ul>
<pre><code>https://example.com/api/file/fileDown?file_name=파일명.pdf</code></pre><ul>
<li>이는 <strong>인증 우회 및 직접 접근(Direct Object Reference, IDOR)</strong> 취약점으로 분류될 수 있음</li>
</ul>
<hr>
<h2 id="2-검색-기법">2. 검색 기법</h2>
<ul>
<li>구글 및 Bing과 같은 검색엔진에서 다음과 같은 고급 연산자를 이용하여 탐색</li>
</ul>
<h3 id="파일-다운로드-api-엔드포인트-검색-예시">파일 다운로드 API 엔드포인트 검색 예시</h3>
<pre><code>site:example.com inurl:fileDown</code></pre><ul>
<li><code>fileDown</code>, <code>download</code>, <code>attach</code> 등이 URL에 포함된 페이지를 찾기 위해 <code>inurl:</code> 연산자 사용</li>
</ul>
<h3 id="다운로드-가능-파일-검색-예시">다운로드 가능 파일 검색 예시</h3>
<pre><code>site:example.com (filetype:pdf OR filetype:xlsx OR filetype:hwp) inurl:fileDown</code></pre><ul>
<li>접근 제어 없이 다운로드 가능한 파일 유형을 포괄적으로 탐지 가능</li>
</ul>
<hr>
<h2 id="3-점검-방법">3. 점검 방법</h2>
<ul>
<li>게시판이 로그인 후에만 접근 가능하도록 UI상 제한이 걸려 있어도,</li>
<li>파일 다운로드 링크가 공개되어 있다면 직접 호출할 수 있는지 확인 필요</li>
</ul>
<h3 id="예시-시나리오">예시 시나리오</h3>
<ol>
<li>로그인 없이 URL 직접 접근 시도</li>
<li>접근이 된다면 서버 측 인증 미검증 가능성 존재</li>
<li>파일명을 바꿔가며 다른 내부 문서 접근 가능성 테스트</li>
</ol>
<hr>
<h2 id="4-대응-방안">4. 대응 방안</h2>
<ul>
<li><p>다운로드 API 또는 파일 서버 접근 시 <strong>인증 및 권한 검사</strong> 필수</p>
</li>
<li><p>최소한 다음과 같은 조치 필요</p>
<ul>
<li>파일 다운로드 전 로그인 여부 및 접근 권한 체크</li>
<li>다운로드 링크에 토큰 기반 검증 추가 (예: expiring URL)</li>
<li>접근 로그 및 이상 행위 탐지 시스템 연동</li>
</ul>
</li>
</ul>
<hr>
<h2 id="5-결론">5. 결론</h2>
<ul>
<li>보안은 클라이언트 측 UI 제한만으로는 충분하지 않음</li>
<li>서버단에서의 <strong>인증 및 권한 제어</strong>가 필수적이며,</li>
<li>다운로드 경로 점검은 보안 점검 시 필수 항목으로 고려되어야 함</li>
</ul>
]]></description>
        </item>
        <item>
            <title><![CDATA[[Flutter]포트폴리오 커뮤니티 웹 개발]]></title>
            <link>https://velog.io/@kbc-1315/Flutter-%ED%8F%AC%ED%8A%B8%ED%8F%B4%EB%A6%AC%EC%98%A4-%EC%BB%A4%EB%AE%A4%EB%8B%88%ED%8B%B0-%EC%9B%B9-%EA%B0%9C%EB%B0%9C</link>
            <guid>https://velog.io/@kbc-1315/Flutter-%ED%8F%AC%ED%8A%B8%ED%8F%B4%EB%A6%AC%EC%98%A4-%EC%BB%A4%EB%AE%A4%EB%8B%88%ED%8B%B0-%EC%9B%B9-%EA%B0%9C%EB%B0%9C</guid>
            <pubDate>Fri, 13 Jun 2025 05:07:34 GMT</pubDate>
            <description><![CDATA[<h1 id="flutter-기반-포트폴리오-커뮤니티-웹-개발기">Flutter 기반 포트폴리오 커뮤니티 웹 개발기</h1>
<p><a href="https://porpolio-web-community-f3d4a.web.app/">https://porpolio-web-community-f3d4a.web.app/</a></p>
<h2 id="1-프로젝트-개요24061113">1. 프로젝트 개요(&#39;24.06.11~13)</h2>
<p>Flutter와 Firebase를 활용해 사용자들이 자신의 포트폴리오를 작성하고 공유할 수 있는 <strong>커뮤니티형 포트폴리오 웹앱</strong>을 개발했습니다.
<img src="https://velog.velcdn.com/images/kbc-1315/post/4516aefa-516d-406f-80ce-1d5ca4a2d40c/image.png" alt=""></p>
<p>사용자는 다음과 같은 기능을 수행할 수 있습니다:</p>
<ul>
<li>로그인 및 회원가입 (Firebase Auth)</li>
<li>포트폴리오 블록 추가/편집/삭제 (카테고리/블록/세부 항목 구성)</li>
<li>포트폴리오 조회수 기반 정렬</li>
<li>사용자별 포트폴리오 PDF 다운로드 또는 공유</li>
<li>검색 및 무한 스크롤 탐색 기능</li>
<li>Firestore 기반 실시간 데이터 연동</li>
</ul>
<h2 id="2-주요-기술-스택">2. 주요 기술 스택</h2>
<table>
<thead>
<tr>
<th>구분</th>
<th>사용 기술</th>
</tr>
</thead>
<tbody><tr>
<td>프론트엔드</td>
<td>Flutter (Web/Mobile Responsive)</td>
</tr>
<tr>
<td>상태관리</td>
<td>Provider</td>
</tr>
<tr>
<td>백엔드</td>
<td>Firebase Firestore, Firebase Auth</td>
</tr>
<tr>
<td>배포</td>
<td>Firebase Hosting</td>
</tr>
<tr>
<td>문서 출력</td>
<td><code>pdf</code> 패키지를 이용한 포트폴리오 PDF 생성 및 다운로드</td>
</tr>
</tbody></table>
<hr>
<h2 id="3-핵심-기능-및-구현-방식">3. 핵심 기능 및 구현 방식</h2>
<h3 id="✅-사용자-인증">✅ 사용자 인증</h3>
<ul>
<li>Firebase Authentication을 통해 Email 로그인 지원</li>
<li>로그인한 사용자는 본인의 포트폴리오만 편집 가능</li>
</ul>
<h3 id="✅-포트폴리오-구조">✅ 포트폴리오 구조</h3>
<ul>
<li><code>PortfolioCategory</code> → <code>PortfolioBlock</code> → <code>BlockDetail</code> 계층으로 구성</li>
<li>각 항목은 드래그 앤 드롭 또는 순서 변경 가능</li>
<li>텍스트, <em>이미지</em>(얘는 아직) 타입 지원
<img src="https://velog.velcdn.com/images/kbc-1315/post/5398b6a7-65c7-4418-98ab-42be226a1dd0/image.png" alt=""></li>
</ul>
<h3 id="✅-firestore-연동">✅ Firestore 연동</h3>
<ul>
<li><code>users/{userId}/portfolioCategories</code> 하위에 카테고리 및 블록 저장</li>
<li><code>user_profiles</code>에는 사용자 프로필(name, email, url 등)과 함께 <code>viewCount</code> 저장</li>
<li><code>portfolios/{userId}</code>에는 PortfolioSummary 저장하여 검색 및 탐색에 활용
<img src="https://velog.velcdn.com/images/kbc-1315/post/6a41ff38-07de-44da-90e9-5086ae462a92/image.png" alt=""></li>
</ul>
<h3 id="✅-pdf-생성">✅ PDF 생성</h3>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/a0e6652f-8f49-48ac-8d30-814f5e0777d7/image.png" alt=""></p>
<ul>
<li>사용자 요청 시 <code>pdf</code> 패키지를 이용해 포트폴리오 전체를 PDF로 구성</li>
<li>웹에서는 자동 다운로드, 모바일에서는 공유 메뉴 호출</li>
</ul>
<hr>
<h2 id="4-난관-및-해결-과정">4. 난관 및 해결 과정</h2>
<table>
<thead>
<tr>
<th>문제 상황</th>
<th>해결 방법</th>
</tr>
</thead>
<tbody><tr>
<td>Firebase 데이터 구조 설계</td>
<td>Firestore Subcollection을 활용해 구조화</td>
</tr>
<tr>
<td>모바일/웹의 PDF 처리 차이</td>
<td><code>dart:html</code> vs <code>path_provider + share_plus</code> 플랫폼 분기 처리</td>
</tr>
<tr>
<td>로그인 여부에 따른 편집 권한</td>
<td>Firebase Auth와 userId를 비교하여 조건 분기</td>
</tr>
<tr>
<td>사용자 정의 정렬, 검색</td>
<td>Provider에서 상태 관리 및 필터링 처리</td>
</tr>
</tbody></table>
<hr>
<h2 id="5-향후-계획언제할지는-모르겠음">5. 향후 계획(언제할지는 모르겠음;)</h2>
<ul>
<li>댓글 및 피드백 기능 추가</li>
<li>인기 포트폴리오 자동 랭킹</li>
<li>다국어 지원 (i18n)</li>
<li>SEO 최적화</li>
</ul>
<hr>
]]></description>
        </item>
        <item>
            <title><![CDATA[[강화학습] 1-3. Markov Decision Process]]></title>
            <link>https://velog.io/@kbc-1315/%EA%B0%95%ED%99%94%ED%95%99%EC%8A%B5-1-3.-Markov-Decision-Process</link>
            <guid>https://velog.io/@kbc-1315/%EA%B0%95%ED%99%94%ED%95%99%EC%8A%B5-1-3.-Markov-Decision-Process</guid>
            <pubDate>Thu, 01 May 2025 12:24:03 GMT</pubDate>
            <description><![CDATA[<h1 id="markov-decision-process">Markov Decision Process</h1>
<h2 id="1-모든-state와-action은-random-variable이다">1. 모든 State와 Action은 Random Variable이다</h2>
<p>$$
p(a_1|s_0,a_0,s_1)
$$</p>
<ul>
<li>$s_1$일때 $a_1$을 구하려면 굳이 $s_0$과 $a_0$는 알 필요가 없다.</li>
<li>왜? 이미 $s_1$에 반영이 되어있으니까. 따라서 아래와 같이 다시 표현할 수 있다</li>
</ul>
<p>$$
p(a_1|s_1)
$$</p>
<ul>
<li>그럼 아래와 같은 경우 어떨까
$$
p(s_2|s_0,a_0,s_1,a_1)
$$</li>
<li>$s_2$를 알기 위해서는 $s_1$과 $a_1$이 모두 필요하다</li>
<li>$s_1$에는 $s_0$, $a_0$는 이미 반영이 되어있다</li>
<li>따라서 아래와 같이 다시 표현할 수 있다</li>
</ul>
<p>$$
p(s_2|s_1,a_1)
$$</p>
<ul>
<li>Sufficient Statistics -&gt; <a href="https://velog.io/@kbc-1315/DetnEst-5.-General-MVUE#sufficient-statistics">https://velog.io/@kbc-1315/DetnEst-5.-General-MVUE#sufficient-statistics</a></li>
</ul>
<h2 id="2-policy">2. Policy</h2>
<p>$$
p(a_t|s_t):\text{Policy}
$$</p>
<ul>
<li>상태 $s$에서 어떤 행동 $a$를 하는 분포</li>
</ul>
<p>$$
p(s_{t+1}|s_t,a_t) : \text{Transtition | 전이}
$$</p>
<ul>
<li>얘는 Trainsition or 전이</li>
</ul>
<hr>
<p>강화학습에서는 <code>Return</code>을 Maximize한다 -&gt; 정확히는 <code>Expected Return</code>
$$
\text{Retrun }G_t=R_t+\gamma R_{t+1}+\gamma^2 R_{t+2}+\cdots
$$</p>
<ul>
<li>Action $a_t$를 했을때 넘어간 State에서 받는 Reward : $R_t$</li>
<li>따라서 <code>Expected Return</code>$E[G_t]$을 Maximize하는 <code>Policy</code>를 찾는다</li>
</ul>
<p>원본 출처[혁펜하임 유튜브] : <a href="https://www.youtube.com/watch?v=DbbcaspZATg&amp;list=PL_iJu012NOxehE8fdF9me4TLfbdv3ZW8g&amp;index=3">https://www.youtube.com/watch?v=DbbcaspZATg&amp;list=PL_iJu012NOxehE8fdF9me4TLfbdv3ZW8g&amp;index=3</a></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[강화학습] 1-2. Q-learning]]></title>
            <link>https://velog.io/@kbc-1315/%EA%B0%95%ED%99%94%ED%95%99%EC%8A%B5-1-2.-Q-learning</link>
            <guid>https://velog.io/@kbc-1315/%EA%B0%95%ED%99%94%ED%95%99%EC%8A%B5-1-2.-Q-learning</guid>
            <pubDate>Thu, 01 May 2025 12:01:56 GMT</pubDate>
            <description><![CDATA[<h1 id="q-learning">Q-Learning</h1>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/2a2660a6-44cf-433e-bf3c-6ab01c7e3534/image.png" alt=""></p>
<ul>
<li>내 AI Agent가 맛집을 찾아가게 하고 싶은 상황이다</li>
<li>뭐 랜덤으로 움직이다가 맛집으로 들어갈 수도 있겠지</li>
<li>어쨋든 찾아가게 하고 싶다</li>
</ul>
<h2 id="greedy-action">Greedy Action</h2>
<ul>
<li>각 방향에 대해 점수를 부여한다</li>
<li>각 셀에서는 위, 아래, 왼쪽, 오른쪽으로 갈 수 있다(모서리 제외)
<img src="https://velog.velcdn.com/images/kbc-1315/post/7c2c9ccd-ca52-4531-bac7-1508e2269a65/image.png" alt=""></li>
<li>맛집에 들어가면 R(Reward) 보상을 받게 된다</li>
<li>계속 랜덤하게 움직이다가 어쩌다 보니 맛집으로 들어간다
<img src="https://velog.velcdn.com/images/kbc-1315/post/8f846e39-42d5-4255-9be1-1f9f7959336f/image.png" alt=""></li>
<li>그럼 그 방향으로 갔더니 보상이 지급되었으니까 그 방향의 Q-value를 1로 업데이트한다
<img src="https://velog.velcdn.com/images/kbc-1315/post/e215dc4c-d559-4c19-8b6b-f506089c9b64/image.png" alt=""></li>
<li>그 다음 에피소드에서 빨간 테두리에 있다고 가정해보자 위, 아래, 왼쪽 그리드는 값이 모두 없지만 오른쪽은 다르다, 오른쪽에서 가장 큰 값은 1이다.</li>
<li>빨간 테두리 안의 오른쪽에도 오른쪽 셀의 가장 큰 값인 1로 업데이트 한다</li>
</ul>
<table>
<thead>
<tr>
<th align="center"><img src="https://velog.velcdn.com/images/kbc-1315/post/8dbbc3fc-865d-4e0a-8e0d-145e59927be2/image.png" alt=""></th>
<th align="center"><img src="https://velog.velcdn.com/images/kbc-1315/post/ed49681f-7099-4203-9a91-0bbe1e3e88db/image.png" alt=""></th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://velog.velcdn.com/images/kbc-1315/post/2533617b-9567-456a-9ef4-99d03b2541fe/image.png" alt=""></td>
<td align="center"><img src="https://velog.velcdn.com/images/kbc-1315/post/67b3c7c9-d6e0-472c-8773-d62303b1f54f/image.png" alt=""></td>
</tr>
<tr>
<td align="center">- 나머지도 똑같이 업데이트 한다</td>
<td align="center"></td>
</tr>
<tr>
<td align="center">- 완성된 지금부터는 Q-value가 가장 큰 쪽으로 <code>Greedy Action</code>을 수행할 것이다.</td>
<td align="center"></td>
</tr>
<tr>
<td align="center">- 모든 수행 결과는 동일할 것이다</td>
<td align="center"></td>
</tr>
<tr>
<td align="center">- 하지만 이 결과가 최적인가? 바로 오른쪽으로 가면 더 최단 거리일텐데</td>
<td align="center"></td>
</tr>
</tbody></table>
<h2 id="epsilon-greedy">Epsilon-Greedy</h2>
<p>$$\epsilon\text{-greedy},;\epsilon\sim(0,1)$$</p>
<ul>
<li>$\epsilon$ 값에 따라 <code>Random Action</code>을 하자</li>
<li><code>Exploration</code> : 새로운 전략을 탐험<ul>
<li>새로운 Path를 찾을 수 있다</li>
<li>새로운 맛집을 찾을 수 있다</li>
</ul>
</li>
<li><code>Exploitation</code> : 최적 행동을 수행
<img src="https://velog.velcdn.com/images/kbc-1315/post/eed61282-395c-4156-a305-b426ef614df9/image.png" alt=""></li>
<li><code>Exploration</code>이 없다면 평생 새로운 맛집은 못가고 가던 곳만 갈것이다.</li>
<li>하지만 계속 랜덤 행동을 한다면 최적 전략에서는 멀어질 수 있다</li>
<li>따라서 <strong>Decaying</strong>하는 $\epsilon$ 값을 활용한다
<img src="https://velog.velcdn.com/images/kbc-1315/post/56e78561-9219-4e79-bee5-df756e6cd340/image.png" alt=""></li>
<li>적절히 탐험을 하다가 나중에는 덜 탐험을 하는 식으로 Agent가 행동할 것이다
<img src="https://velog.velcdn.com/images/kbc-1315/post/6297b744-147b-4c5e-adc4-d13a48ec7805/image.png" alt=""></li>
<li>그렇게 우린 새로운 최단 거리 경로를 찾았다.</li>
<li>하지만 우리 Agent는 어디가 더 좋은 경로인지 알지 못한다.</li>
<li>위나 아래나 Q-value가 똑같으니까...</li>
</ul>
<h2 id="discount-factor">Discount Factor</h2>
<ul>
<li>Discount factor : $\gamma$ 는 0보다 크고 1보다 작은 값이다
위와 같이 Discount factor를 적용하면
<img src="https://velog.velcdn.com/images/kbc-1315/post/33f8868a-c590-4084-af5e-a9d6c68109f6/image.png" alt=""></li>
<li>이런식으로 첫번째 시작점에서 $\gamma^2 &gt;\gamma^4$ 이기 때문에 Agent는 오른쪽을 선택할 것이다</li>
<li>따라서 이 Discount rate는<ul>
<li>효율적인 Path 탐색을 할 것이며</li>
<li>현재와 미래의 Reward에 대해 얼마나 비중을 둘 것인지 정할 수 있다</li>
</ul>
</li>
</ul>
<h2 id="q-value-update">Q-value Update</h2>
<p>$$
Q(s_t,a_t) \leftarrow (1-\alpha)Q(s_t,a_t)+\alpha(R_t+\gamma\max_{a_{t+1}}Q(s_{t+1},a_{t+1}))
$$</p>
<ul>
<li>화살표 왼쪽의 Q-값을, 화살표 오른쪽의 값으로 업데이트를 해라</li>
<li>$\alpha$는 0~1의 값 : 새로운 걸 얼마나 받아들일건지?</li>
<li>$(1-\alpha)Q(s_t,a_t)$ : 이쪽은 원래 가지고 있던 Q-value</li>
<li>$\alpha(R_t+\gamma\max_{a_{t+1}}Q(s_{t+1},a_{t+1}))$ : 새로 업데이트 하려는 값</li>
</ul>
<p>원본 출처[혁펜하임 유튜브] : <a href="https://www.youtube.com/watch?v=3Ch14GDY5Y8&amp;list=PL_iJu012NOxehE8fdF9me4TLfbdv3ZW8g&amp;index=2">https://www.youtube.com/watch?v=3Ch14GDY5Y8&amp;list=PL_iJu012NOxehE8fdF9me4TLfbdv3ZW8g&amp;index=2</a></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[Review][스포 있음] 미키17 리뷰]]></title>
            <link>https://velog.io/@kbc-1315/%EC%8A%A4%ED%8F%AC-%EC%9E%88%EC%9D%8C-%EB%AF%B8%ED%82%A417-%EB%A6%AC%EB%B7%B0</link>
            <guid>https://velog.io/@kbc-1315/%EC%8A%A4%ED%8F%AC-%EC%9E%88%EC%9D%8C-%EB%AF%B8%ED%82%A417-%EB%A6%AC%EB%B7%B0</guid>
            <pubDate>Mon, 03 Mar 2025 11:46:39 GMT</pubDate>
            <description><![CDATA[<p><img src="https://velog.velcdn.com/images/kbc-1315/post/c394aea4-682f-422b-90db-13f063068d28/image.png" alt=""></p>
<h1 id="생각하는-만큼-느낄-수-있는-영화">생각하는 만큼 느낄 수 있는 영화</h1>
<p>영화계의 역사도 깊어지며 그 다양성과 깊이 또한 함께 넓고, 깊어져갔다. 그에 따라, 킬링 타임용 영화처럼 감독이 그닥 의도를 숨기지 않고 그대로 내비치어 표현하는 영화도 있는 반면, 숨겨진 의도로 말미암아 관객으로서 그 의도를 음미해보도록 하는 영화 또한 많다. 개인적인 의견이지만 이를 구분짓기는 매우 주관적인 요소로 결정된다고 생각한다. 감독이 &quot;이 영화엔 숨겨져 있는 저의가 많으니 찾아보시길 바랍니다&quot; 라고 말해주지는 않으니까 말이다.
필자는 위 영화에 대한 혹평을 많이 듣고 간 상태에서 오히려 더 재미있는 관람을 약간이나마 비판적인, 비관적인 입장에서 보았기 때문에 할 수 있었지 않나라고 느꼈다. 즉, 많은 노력을 들여 영화의 어느 부분이 까내릴만한가? 이런 부분에 집중해서 많은 노력을 들였지만, 그 숨겨진 재미와 감독의 의도를 찾아내 정말 만족할 만한 영화였음을 밝힌다.</p>
<hr>
<h2 id="필멸의-존재에게-죽음이란">필멸의 존재에게 죽음이란?</h2>
<p>영화에서 계속 주인공에게 던져지는 질문이 있다.</p>
<blockquote>
<p>&quot;죽는 기분은 어때?&quot;</p>
</blockquote>
<p>주인공은 휴먼프린터라는 고도의 기술로 인해 죽지만 다시 생성되어 다른 몸으로 옮겨져 그 삶을 계속 영위해간다. 아니 타의에 의해 이어져 간다고 보는 것이 더 정확하다. 그렇기 때문에 수많은 죽음을 경험한 주인공은 쉽게 그 소감을 이야기할 수 있을 것 같지만, 그렇지 않다. 영화 초반, 그의 인격을 데이터화하고 신체를 다시 프린트할 수 있는 그는 시스템을 믿는다는 것의 증빙으로 자살을 강요받는다. 하지만, 그는 끝끝내 자살하지 못한다. 아마 죽음 뒤에 다시 삶이 돌아온다는 것을 믿지 못한게 아닐까 싶다. 이는 영화 후반부에 가서도 변하지 않는다. 계속되는 죽음 뒤에 그의 이름 뒤에는 17, 18의 번호들이 붙지만, 여전히 그는 물음에 대해 명확하게 답하지 못하고 그저 무섭다고 할 뿐이다. 
<strong>필멸의 존재인 인간에게 죽음은 필수불가결하며 피할 수 없는 존재이며 두려움의 표상이다</strong></p>
<hr>
<h2 id="죽음-앞에-어떻게-살아가야-하는가">죽음 앞에 어떻게 살아가야 하는가?</h2>
<p>영화의 배경인 미래의 지구에서 수많은 사람들이 아니, 인생에서의 패배자들이 인생을 세탁하기 위해 식민지 개척 함선에 자원해 지구를 떠나게 된다. 지구에는 돈을 빌려주고 이를 갚지 못한 사람들을 그저 본인의 유희를 위해 죽이고 그 장면을 즐기는 자산가를 비롯한 정상적이지 않은 삶의 모습을 보여주고 있다. 주인공 또한, 햄버거보다 마카롱을 더 선호하는 시대가 올 것이라는 친구의 꾀임에 넘어가 사채를 써 결국은 본인도 죽을 운명에 마주친 찰나였다. 그런 잔인한 운명 앞에서 주인공은 도망치듯 떠나갔지만, 익스팬더블이라는 복제 가능한 사람으로 함선에 탑승하게 된다.
그런 함선 안에도 다양한 사람들이 살아가고 있다. 합리적이지 않은 , 정치에서 패배해 도망치듯 쫒겨나는 정치인, 엘리트 군인, 채무로부터 도망온 빚쟁이들... 그들 중 투표에서 패배하여 도망쳐온 정치인은 그의 아내, 주변인으로부터의 아첨과 조언으로 움직이며 진중하지 못하고 합리적이지 못한 모습을 보인다. 그는 타인의 뜻으로 움직이며 다른 사람들을 그저 도구 또는 부품 등으로 여길 뿐이며 이를 신의 뜻으로 포장하는 모습을 보인다. 그리고 엘리트 군인 겸 경찰 겸 소방관과 같은 인물 또한 등장한다. 그는 자신의 자리를 지키며 사회를 위해 헌신적으로 일하는 모습을 보인다. 또, 아무 능력이 없으면서도 아첨 하나만으로 독재자 옆을 지키는 사람도, 그저 묵묵히 살아가는 사람도 볼 수 있다.
<strong>각자 삶의 이유를 찾아가며 주어진 삶에 최선을 다하고 있다. 살기 위해서</strong></p>
<hr>
<h2 id="인간은-그-존재-자체로-고귀한가">인간은 그 존재 자체로 고귀한가?</h2>
<p>이 영화에는 세 가지 존재들이 등장한다. 다른 존재들을 그저 자신의 수족, 하수인, 부품 등으로 생각하며 자신들의 안위만을 생각하는 존재들, 사회를 위해 자신의 자리를 묵묵히 지켜 살아가는 존재들, 자신들의 터전을 위해 살아가며 이를 지키려는 존재들. 영화가 진행되며 식민화를 위해 도착한 행성에 <strong>크리퍼</strong>라는 외형이 끔찍한 생명체를 발견한다. 이들은 징그러운 외형으로 인해, 오해를 받고 인간의 공격을 받으며, 한낱 해충에 불과한 존재로 인식된다. <strong>이들을 박멸해야할 존재인가?</strong>
한 인물의 대답으로 이에 대한 감독의 답을 찾을 수 있었다. <strong>그들은 그들의 보금자리를 지키려 할 뿐이다</strong>. 인간은 무슨 권리로 그들의 보금자리를 빼앗으려 하는가? 진정으로 악한 것은 인간이 아닌가? 하는 부분을 생각해 볼 수 있다.
하지만, 인간 사이에서 조차 다른 존재들이 함께 살아가고 있다. 외형은 같으나, 타인을 존중하지 않는 존재들과, 타인을 자신과 같이 존중하는 존재들. 주인공은 죽어도 다시 새로운 몸에 옮겨갈 수 있기에 어느 존재들은 온갖 모진 실험과 어려운 임무들을 부여하여 주인공을 소모시킨다. 하지만, 고통스러워 하는 그의 모습에 함께 고통스러워하며 이를 비난하는 존재들 또한 함께 살아간다.</p>
<p><strong>인간은 태어남과 동시에 고귀함을 부여받는가?</strong></p>
<p>아니면</p>
<p><strong>다른 존재를 본인과 같이 존중함으로서 그 고귀함을 찾아가는가? 또 그 고귀함은 절대적인가?</strong></p>
<p>이런 부분을 생각할 수 있는 기회였다.</p>
<hr>
<h2 id="공동체의-이익-아래-소수의-존엄성은-무시될-수-있는가">공동체의 이익 아래 소수의 존엄성은 무시될 수 있는가?</h2>
<p>위의 모든 물음에 반해, 주인공이 부품처럼 도구처럼 죽어가면서 공동체는 우주 방사선에 대해 더욱 알게 되었으며, 외계 행성의 바이러스를 정복할 수 있었다. <strong>만약 그렇지 않았다면?</strong> 아마도, 끝끝내 행성을 알지 못하고, 바이러스를 알지 못하고 절멸했을 수 있다. 주인공의 희생으로 말미암아 공동체는 효율적으로 생존할 수 있었다.
영화 후반, 휴먼 프린터는 폭파되고 이제 주인공은 더이상 프린팅될 수 없다. 영화에서는 해피 엔딩처럼 외계 생명체와 공존 체제를 갖추고 테라포밍에 성공하는 듯 보였다. 하지만, 새로운 바이러스가 등장한다면, 익스펜더블이 없는 인류는 많은 희생으로서 그 백신을 개발하거나 아예 멸종할 수 있으며, 미지의 위협에 대해 전처럼 효율적으로 대처할 수 없을 것이다.
주인공은 어렸을적 교통사고로 어머니가 돌아가신 사고를 겪었다. 또 그 원인이 본인 때문이라고 생각해 모든 본인의 존엄성을 무시한 죽음을 비롯한 불이익에 대해서 받아들인다. 주인공을 존중하지 않고 부품처럼, 도구처럼 여겨온 과학자들이나 미치광이 지도자는 주인공이 <strong>죽기 위해 존재하는 사람</strong>으로 취급하며 그의 존엄성을 짓이겼지만, 이 행위로 인해 공동체의 더 많은 사람들이 효율적으로 살 수 있었다. 또 주인공의 실수였지만 본인이 자원함으로써 익스펜더블이 되었고 수많은 죽음을 겪었다.</p>
<p><strong>우린 그들을 비난할 수 있나? 그들은 할 일을 한 것 뿐이다</strong></p>
<hr>
<h2 id="결과가-좋으면-그-과정은-아무래도-좋다">결과가 좋으면 그 과정은 아무래도 좋다?</h2>
<p>영화 내내 이상하게도 많이 나오는 소재가 있다. 미치광이 정치인의 아내는 <strong>소스</strong>에 집착하며 나올때마다 본인의 소스가 어떤지 물어본다. 또, 사람들이 먹는 음식에 대해서도 유별나게 잦은 출연이 있었다. 세상에는 정말 다양한 소스들이 있다. 또 다양한 음식들이 있다. 우린 식사를 할 때 만들어진 소스에 만들어진 음식을 별 생각 없이 먹지만, 음식의 식재료를 위해 수 많은 동물들이 죽고, 갖가지 조리법에 의해 조리되고, 소스의 개발을 위해 많은 생명체들이 소모된다. 하지만, 소비자들은 이에 대해 잘 알지 못한다.
미치광이 정치인의 아내는 <strong>소스</strong>에 너무도 집착한 나머지 외계 생명체의 꼬리를 갈아 소스로 만들어버린다. 이때 <strong>소스</strong>라고 부르는 무언가는 피인지, 소스인지 분간할 수 없는 무언가였다. 그녀의 눈에 외계 생명체는 그저 소스의 재료일 뿐이었다. 하지만, 많은 사람들은 그 과정을 보았기에 역겨워 하는 모습이다. 하지만, 다른 소스들 또한 그 제조과정, 개발과정은 비슷한 종류들이 있었을 것이다.</p>
<p><strong>인간의 행복이라는 결과를 위해 그 과정이 어떻듯 상관이 없는 것인가?</strong></p>
<h3 id="영화계를-향한-감독의-비판인가">영화계를 향한 감독의 비판인가?</h3>
<p>개인적인 의견이지만, 소스에 대한 비유는 현 영화계를 향한 감독의 비판일 수도 있다고 생각한다. 영화 후반 주인공의 악몽에서 정치인의 아내는 주인공에게 바닥에 떨어져 있는 빨간 소스를 어떤지 먹어보라고 하지만, 미심쩍었던 주인공은 그녀에게 무엇으로 만들었는지 물어본다. 그 물음에 대해 그녀는 순서가 잘못되었다고 답한다. 먹어보는것이 먼저, 어떻게 만들었는지는 뭐 아무래도 좋다 이거다. 
현재 감독이 몸담고 있는 영화계 또한 비슷하지 않을까 싶다. <strong>관객들</strong>은 영화가 어떻게 만들어졌는지 대다수 관심이 없다. 그저 생각없이 보고 재미있다 또는 없다 판단할 뿐이다. 하지만, 그 영화를 만들기 위한 그 <strong>과정</strong>은 그렇지 않을 수 있다. 영화 관계자의 많은 희생과 노력이 있었을 것이고, 때로 어떤 영화들은 부정과 부패 혹은 범죄와 연류되었을 수도 있다. 또한, <strong>감독</strong>이 영화를 통해 말하고자 하는 <strong>메세지</strong>에 대해서 그닥 궁금해하지 않는다. <strong>그저 누군가 완성된 음식을 떠먹여주기만 기다릴 뿐</strong>
이 영화는 어쩌면 현 영화계를 향한 감독의 비판일 수도 있겠다.</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[운동] 20250107]]></title>
            <link>https://velog.io/@kbc-1315/%EC%9A%B4%EB%8F%99-20250107</link>
            <guid>https://velog.io/@kbc-1315/%EC%9A%B4%EB%8F%99-20250107</guid>
            <pubDate>Tue, 07 Jan 2025 09:09:06 GMT</pubDate>
            <description><![CDATA[<p><img src="https://velog.velcdn.com/images/kbc-1315/post/3404cc83-cc9b-4486-b61b-ff42f41f761a/image.png" alt=""></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[ML&DL] 11. Deep Learning]]></title>
            <link>https://velog.io/@kbc-1315/MLDL-11.-Deep-Learning</link>
            <guid>https://velog.io/@kbc-1315/MLDL-11.-Deep-Learning</guid>
            <pubDate>Sun, 15 Dec 2024 09:56:55 GMT</pubDate>
            <description><![CDATA[<h1 id="deep-learning">Deep Learning</h1>
<h2 id="single-layer-neural-network">Single Layer Neural Network</h2>
<p>$$
f(X)=\beta_0+\sum^K_{k=1}\beta_kh_k(X)\[0.2cm]
=\beta_0+\sum^K_{k=1}\beta_k g(w_{k0}+\sum^p_{j=1}w_{kj}X_j)
$$
<img src="https://velog.velcdn.com/images/kbc-1315/post/acf0ed06-07c0-4bc2-bfdd-afbcf59556be/image.png" alt="">
<img src="https://velog.velcdn.com/images/kbc-1315/post/126f05e8-7e5e-4a7f-b719-28226f5a9984/image.png" alt=""></p>
<ul>
<li>$A_k=h_k(X)=g(w_{k0}+\sum^p_{j=1} w_{kj}X_j)$ are called the <code>activations</code> in the <code>hidden layer</code></li>
<li>$g(z)$ is called the <code>activation function</code>. Popular are the <code>sigmoid</code> and <code>rectified linear</code>, shown in figure</li>
<li>Activation functions in hidden layers are typically <code>nonlinear</code>, otherwise the model collapses to a linear model</li>
<li>So the activations are like derived features - nonlinear transformations of linear combinations of the features</li>
<li>The model is fit by minimizing $\sum^n_{i=1}(y_i-f(x_i))^2$ (e.g. for regression)</li>
</ul>
<h2 id="example--mnist-digits">Example : MNIST Digits</h2>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/6021bcaf-2438-4f84-a87d-52ce61ec2e80/image.png" alt=""></p>
<ul>
<li>Handwritten digits $28\times 28$ grayscale images $60K$ train, $10K$ test images</li>
<li>Features are the $784$ pixel grayscale values $\in (0,255)$</li>
<li>Labels are the digit class $0-9$</li>
</ul>
<hr>
<ul>
<li>Goal : build a classifier to predict the image class</li>
<li>We build a two-layer network with $256$ units at first layer, $128$ units at second layer, and $10$ units at output layer</li>
<li>Along with intercepts (called <code>biases</code>) there are $235,146$ parameters (referred to as <code>weights</code>)
<img src="https://velog.velcdn.com/images/kbc-1315/post/7262f34c-2160-47ed-87cd-f04258ed56a1/image.png" alt=""></li>
</ul>
<hr>
<ul>
<li>Let $Z_m=\beta_{m0}+\sum^{K_2}<em>{l=1}\beta</em>{ml}A_l^{(2)},;m=0,1,\dots,9$ be $10$ linear combinations of activations at second layer</li>
<li>Output activation function encodes the <code>softmax</code> function
$$
f_m(X)=\Pr(Y=m|X)=\frac{e^{Zm}}{\sum^9_{l=0}e^{Zl}}
$$</li>
<li>We fit the model by minimizing the negative multinomial log-likelihood (or cross-entropy)
$$</li>
<li>\sum^n_{i=1}\sum^9_{m=0}y_{im}\log(f_m(x_i))
$$</li>
<li>$y_{im}$ is $1$ if true class for observation $i$ is $m$, else $0$ - i.e. <code>one-hot encoded</code></li>
</ul>
<hr>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/e3a75df8-9ebe-4565-bba7-5b71bd732fd7/image.png" alt=""></p>
<ul>
<li>Early success for neural networks in the 1990s</li>
<li>With so many parameters, regularization is essential</li>
<li>Some details of regularization and fitting will come later</li>
<li>Very overworked problem - best reported rates are &lt; $0.5%$</li>
<li>Human error rate is reported to be aroung $0.2%$</li>
</ul>
<h2 id="convolutional-neural-network---cnn">Convolutional Neural Network - CNN</h2>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/c039d8e2-afc7-4c9b-8cd1-9b13f65dc361/image.png" alt=""></p>
<ul>
<li>Major success story for classifying images</li>
<li>Shown are samples from <code>CIFAR100</code> database</li>
<li>$32\times 32$ color natural images, with $100$ classes</li>
<li>$50K$ training images, $10K$ test images</li>
<li>Each image is a three-dimensional array of <code>feature map</code> : $32\times32\times 3$ array of $8$-bit numbers</li>
<li>The last dimension represents the three color channels for red, green and blue</li>
</ul>
<hr>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/99be66c7-2e01-42ef-a17f-6fb1ccd2a51f/image.png" alt=""></p>
<ul>
<li>The <code>CNN</code> builds up an image in a hierarchical fashion</li>
<li>Edges and shapes are recognized and pieced together to form more complex shapes, eventually assembling the target image</li>
<li>This hierarchical construction is achieved using <code>convolution</code> and <code>pooling</code> layers</li>
</ul>
<h3 id="convolution-filter">Convolution Filter</h3>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/35f96218-079d-4e10-8bb9-ddab9b36d619/image.png" alt=""></p>
<ul>
<li>The filter is itself an image, and represents a samll shape, edge etc.</li>
<li>We slide it around the input image, scoring for matches</li>
<li>The scoring is done via <code>dot-products</code>, illustrated above</li>
<li>If the subimage of the input image is similar to the filter, the score is high, otherwise low</li>
<li>The filters are <code>learned</code> during training
<img src="https://velog.velcdn.com/images/kbc-1315/post/1d32f41f-985a-4a81-a540-9f09e8b697a2/image.png" alt=""></li>
</ul>
<ul>
<li>The idea of convolution with a filter is to find common patterns that occur in differnet parts of the image</li>
<li>The two filters shown here highlight vertical and horizontal stripes</li>
<li><code>The result</code> of the convolution is a <code>new feature map</code></li>
<li>Since images have three colors channels, the filter does as well : one filter per channel, and dot-products are summed</li>
<li>The weights in the filters are <code>learned</code> by the network</li>
</ul>
<h3 id="pooling">Pooling</h3>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/9102a5d6-f67d-43be-a02c-95420453085e/image.png" alt=""></p>
<ul>
<li>Each non-overlapping $2\times 2$ block is replaced by its maximum</li>
<li>This sharpens the feature identification</li>
<li>Allows for locational invariance</li>
<li>Reduces the dimension by a factor of $4$ - i.e. factor of $2$ in each dimension</li>
</ul>
<h3 id="architecture-of-a-cnn">Architecture of a CNN</h3>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/3ad18f59-0879-4a87-975e-bdecb9c0d705/image.png" alt=""></p>
<ul>
<li>Many <code>convolve</code> + <code>pool</code> layers</li>
<li>Filters are typically small, e.g. each channel $3\times 3$</li>
<li>Each filter creates a new channel in convolution layer</li>
<li>As pooling reduces size, the number of filters/channels is typically increased</li>
<li>Number of layers can be very large. E.g. <code>resnet50</code> trained on <code>imagenet</code> 1000-class image data base has $50$ layers</li>
</ul>
<h2 id="document-classification">Document Classification</h2>
<h3 id="featurization--bag-of-words">Featurization : Bag-of-Words</h3>
<ul>
<li>Documents have different lengths, and consist of sequences of words</li>
<li>How do we create features $X$ to characterize a document?</li>
</ul>
<hr>
<ul>
<li>From a dictionary, identify the $10K$ most frequently occurring words</li>
<li>Create a binary vector of length $p=10K$ for each document, and score a $1$ in every position that the corresponding word occurred</li>
<li>With $n$ documents, we now have a $n\times p$ <code>sparse</code> feature matrix $X$</li>
<li>We compare a <code>lasso</code> logistic regression model to a <code>two-hidden-layer</code> neural network on the next slide</li>
<li><code>Bag-of-words</code> are <code>unigrams</code></li>
<li>We can instead use <code>bigrams</code> ( occurrences of adjacent word pairs ), and in general <code>m-grams</code></li>
</ul>
<h3 id="lasso-vs-neural-network">Lasso vs Neural Network</h3>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/4de2f36b-3d2b-4c7e-b802-1583deb208cc/image.png" alt=""></p>
<ul>
<li>Simpler <code>lasso</code> logistic regression model works as well as neural network in this case</li>
</ul>
<h2 id="recurrent-neural-networks">Recurrent Neural Networks</h2>
<ul>
<li>Often data arise as sequences :<ul>
<li>Documents are sequences of words, and their relative positions have meaning</li>
<li>Time-series such as weather data or financial indices</li>
<li>Recorded speech or music</li>
<li>Handwriting, such as doctor&#39;s notes</li>
</ul>
</li>
<li><code>RNN</code>s build models that take into account this sequential nature of the data, and build a memory of the past<ul>
<li>The feature for each observation is a <code>sequence</code> of vectors $X={X_1,\dots,X_L}$</li>
<li>The target $Y$ is often of the usual kind - e.g. a single variable such as <code>Sentiment</code>, or a one-hot vector for multiclass</li>
<li>However, $Y$ can also be a sequence, such as the same document in a differnet language</li>
</ul>
</li>
</ul>
<hr>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/9f9546bd-c9a1-41a3-b4ad-72da29401ee0/image.png" alt=""></p>
<ul>
<li>The hidden layer is a sequence of vectors $A_l$, receiving as input $X_l$ as well as $A_{l-1}$</li>
<li>$A_l$ produces an output $O_l$</li>
<li>The <code>same</code> weights $W$, $U$ and $B$ are used at each step in the sequence - hence the term <code>recurrent</code></li>
<li>The $A_l$ sequence represents an evolving model for the response that is updated as each element $X_l$ is processed</li>
</ul>
<hr>
<ul>
<li>Suppose $X_l=(X_{l1},X_{l2},\dots,X_{lp})$ has $p$ components, and $A_l=(A_{l1},A_{l2},\dots,A_{lK})$ has $K$ components</li>
<li>Then the computation at the $k$th components of hidden unit $A_l$ is
$$
A_{lk}=g\left(w_{k0}+\sum^p_{j=1}w_{kj}X_{lj}+\sum^K_{s=1}u_{ks}A_{l-1,s}\right)\[0.3cm]
O_l=\beta_0+\sum^K_{k=1}\beta_kA_{lk}
$$</li>
<li>Often we are concerned only with the prediction $O_L$ at the last unit</li>
<li>For squared error loss, and $n$ sequence / response pairs, we would minimize
$$
\sum_{i=1}^n (y_i - o_{iL})^2 = \sum_{i=1}^n \left( y_i - \left( \beta_0 + \sum_{k=1}^K \beta_k g \left( w_{k0} + \sum_{j=1}^p w_{kj} x_{iL_j} + \sum_{s=1}^K u_{ks} a_{i, L-1, s} \right) \right) \right)^2
$$</li>
</ul>
<hr>
<h3 id="rnn-and-imdb-reviews">RNN and IMDB Reviews</h3>
<ul>
<li>The document feature is a sequence of words ${W_l}^L_1$</li>
<li>We typically truncate/pad the documents to the same number $L$ of words (we use $L=500$)</li>
<li>Each word $W_l$ is represented as a <code>one-hot encoded</code> binary vector $X_l$ of length $10K$, with all zeros and a single one in the position for that word in the dictionary</li>
<li>This results in an extremely sparse feature representation, and would not work well</li>
<li>Instead we use a lower-dimensional pretrained <code>work embedding</code> matrix $E(m\times 10K)$</li>
<li>This reduces the binary feature vector of length $10K$ to a real feature vector of dimension $m&lt;10K$ (e.g. $m$ in the low hundreds)</li>
</ul>
<h3 id="word-embedding">Word Embedding</h3>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/5bb6ac4f-25f3-49c0-8c89-5dc0b9c77e94/image.png" alt=""></p>
<ul>
<li>Embeddings are pretrained on very large corpora of documents, using methods similar to principal components</li>
<li><code>word2vec</code> and <code>GloVe</code> are popular</li>
</ul>
<hr>
<ul>
<li>After a lot of work, the results are a disappointing $76%$ accuracy</li>
<li>We then fit a more exotic <code>RNN</code> than the one displayed - a <code>LSTM</code> with <code>long and short term memory</code></li>
<li>Here $A_l$ receives input from $A_{l-1}$ (short term memory) as well as from a version that reaches further back in time (long term memory)</li>
<li>Now we get $87%$ accuracy, slightly less than the $88%$ achieved by <code>glmnet</code></li>
<li>These data have been used as a benchmark for new <code>RNN</code> architectures</li>
<li>The best reported result found at the time of writing (2020) was aroung $95%$</li>
<li>We point to a leaderboard</li>
</ul>
<h2 id="time-series-forecasting">Time Series Forecasting</h2>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/2e288956-9bbc-4b1f-9dd4-9b2576a3c946/image.png" alt=""></p>
<h3 id="new-york-stock-exchange-data">New-York Stock Exchange Data</h3>
<ul>
<li>Shown in previous slide are three daily time series for the period $6,051$ trading days<ul>
<li><code>Log trading volume</code> : This is the fraction of all outstanding shares that are traded on that day, relative to a $100$-day moving average of past turnover, on the log scale</li>
<li><code>Dow Jones return</code> : This is the difference between the log of the <code>Dow Jones</code> Industrial Index on consecutive trading days</li>
<li><code>Log volatility</code> : This is based on the absolute values of daily price movements</li>
</ul>
</li>
<li>Goal : predict <code>Log trading volume</code> tomorrow, given it observed values up to today, as well as those of <code>Dow Jones return</code> and <code>Log volatility</code></li>
</ul>
<h3 id="autocorrelation">Autocorrelation</h3>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/cb9840c2-d1a2-41fe-8234-4b4cadcda960/image.png" alt=""></p>
<ul>
<li>The <code>autocorrelation</code> at lag $l$ is the correlation of all paris $(v_t,v_{t-l})$ that are $l$ trading days apart</li>
<li>These sizable correlations give us confidence that past values will be helpful in predicting the future</li>
<li>This is a curious prediction problem : the response $v_t$ is also a feature $v_{t-l}$</li>
</ul>
<h3 id="rnn-forecaster">RNN Forecaster</h3>
<ul>
<li>We only have one series of data</li>
<li>How do we set up for an <code>RNN</code></li>
<li>We extract many short mini-series of input sequences $X={X_1,\dots,X_L}$ with a predefined length $L$ known as the <code>lag</code>
$$
X_1 = 
\begin{pmatrix}
v_{t-L} \
r_{t-L} \
z_{t-L}
\end{pmatrix}, ,
X_2 = 
\begin{pmatrix}
v_{t-L+1} \
r_{t-L+1} \
z_{t-L+1}
\end{pmatrix}, , \cdots, ,
X_L = 
\begin{pmatrix}
v_{t-1} \
r_{t-1} \
z_{t-1}
\end{pmatrix}, , \text{and } Y = v_t
$$</li>
<li>Since $T=6,051$, with $L=5$ we can create $6,046$ such $(X,Y)$ pairs</li>
<li>We use the first $4,281$ as training data, and the following $1,770$ as test data</li>
<li>We fit an <code>RNN</code> with $12$ hidden units per lag step (i.e. per $A_l$)</li>
</ul>
<hr>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/d7478aa0-80eb-4005-a64b-c758aa690626/image.png" alt=""></p>
<ul>
<li>Figure shows predictions and truth for test period</li>
<li>$R^2=0.42$ for <code>RNN</code></li>
<li>$R^2=0.18$ for <code>straw man</code> - use yesterday&#39;s value of <code>Log trading volume</code> to predict that of today</li>
</ul>
<h3 id="autoregression-forecaster">Autoregression Forecaster</h3>
<ul>
<li>The <code>RNN</code> forecaster is similar in structure to a traditional <code>autoregression</code> procedure
$$
\mathbf{y} =
\begin{bmatrix}
v_{L+1} \
v_{L+2} \
v_{L+3} \
\vdots \
v_{T}
\end{bmatrix}
\quad
\mathbf{M} =
\begin{bmatrix}
1 &amp; v_L &amp; v_{L-1} &amp; \cdots &amp; v_1 \
1 &amp; v_{L+1} &amp; v_L &amp; \cdots &amp; v_2 \
1 &amp; v_{L+2} &amp; v_{L+1} &amp; \cdots &amp; v_3 \
\vdots &amp; \vdots &amp; \vdots &amp; \ddots &amp; \vdots \
1 &amp; v_{T-1} &amp; v_{T-2} &amp; \cdots &amp; v_{T-L}
\end{bmatrix}
$$</li>
<li>Fit an <code>OSL</code> regression of $y$ on $M$, giving
$$
\hat{v}<em>t = \hat{\beta}_0 + \hat{\beta}_1 v</em>{t-1} + \hat{\beta}<em>2 v</em>{t-2} + \cdots + \hat{\beta}<em>L v</em>{t-L}.
$$</li>
<li>Known as an <code>order-L autoregression</code> model or $AR(L)$</li>
<li>For the <code>NYSE</code> data we can include lagged version of <code>DJ_return</code> and <code>log_volatility</code> in matrix $M$, resulting in $3L+1$ columns</li>
</ul>
<hr>
<ul>
<li>$R^2=0.41$ for $AR(5)$ model ($16$ parameters)</li>
<li>$R^2=0.42$ for <code>RNN</code> model ($205$ parameters)</li>
<li>$R^2=0.42$ for $AR(5)$ model fit by neural network</li>
<li>$R^2=0.46$ for all model if we include <code>day_of_week</code> of day being predicted</li>
</ul>
<h2 id="non-convex-functions-and-gradient-descent">Non Convex Functions and Gradient Descent</h2>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/1baf9879-7102-4750-a7dc-16bf2e08ddfd/image.png" alt=""></p>
<ol>
<li>Start with a guess $\theta^0$ for all the parameters in $\theta$, and set $t=0$</li>
<li>Iterate until the objective $R(\theta)$ fails to decrease :
2.1. Find a vector $\delta$ that reflects a small change in $\theta$, such that $\theta^{t+1}=\theta^t+\delta$ <code>reduces</code> the objective
2.2. Set $t \leftarrow t+1$</li>
</ol>
<hr>
<ul>
<li>In this sample example we reached the <code>global minimum</code></li>
<li>If we had started a little to the left of $\theta^0$ we would have gone in the other direction, and ended up in a <code>local minimum</code></li>
<li>Although $\theta$ is multi-dimensional, we have depicted the process as one-dimensional</li>
<li>It is much harder to identify whether one is in a <code>local minimum</code> in high dimensions</li>
<li>How to find a direction $\delta$ that point downhill?</li>
<li>We compute the <code>gradient vector</code>
$$
\nabla R(\theta^t) = \left. \frac{\partial R(\theta)}{\partial \theta} \right|_{\theta = \theta^t}
$$</li>
<li>i.e. the vector of <code>partial derivatives</code> at the current guess $\theta^t$</li>
<li>The gradient points uphil, so our update is $\delta =-\rho\nabla R(\theta^t)$ or
$$
\theta^{t+1} \leftarrow \theta^t - \rho \nabla R(\theta^t)
$$
where $\rho$ is the <code>learning rate</code> (typically small, e.g. $\rho=0.001$)</li>
</ul>
<h3 id="gradients-and-backpropagation">Gradients and Backpropagation</h3>
<p>$$
R(\theta)=\sum^n_{i=1}R_i(\theta)
$$
is a sum, so gradient is sum of gradients
$$
R_i(\theta) = \frac{1}{2} \left( y_i - f_{\theta}(x_i) \right)^2 
= \frac{1}{2} \left( y_i - \beta_0 - \sum_{k=1}^K \beta_k g \left( w_{k0} + \sum_{j=1}^p w_{kj} x_{ij} \right) \right)^2
$$</p>
<ul>
<li>For ease of notation, let $z_{ik}=w_{k0}+\sum^p_{j=1}w_{kj}x_{ij}$</li>
<li><code>Backpropagation</code> uses the chain rule for differentitaion
$$
\frac{\partial R_i(\theta)}{\partial \beta_k} 
= \frac{\partial R_i(\theta)}{\partial f_\theta(x_i)} \cdot \frac{\partial f_\theta(x_i)}{\partial \beta_k} 
= - (y_i - f_\theta(x_i)) \cdot g(z_{ik}).\[0.3cm]
\frac{\partial R_i(\theta)}{\partial w_{kj}} 
= \frac{\partial R_i(\theta)}{\partial f_\theta(x_i)} \cdot \frac{\partial f_\theta(x_i)}{\partial g(z_{ik})} \cdot \frac{\partial g(z_{ik})}{\partial z_{ik}} \cdot \frac{\partial z_{ik}}{\partial w_{kj}}
= - (y_i - f_\theta(x_i)) \cdot \beta_k \cdot g&#39;(z_{ik}) \cdot x_{ij}.
$$</li>
</ul>
<h3 id="tricks-of-the-trade">Tricks of the Trade</h3>
<ul>
<li><code>Slow learning</code>
Gradient descent is slow, and a small learning rate $\rho$ slows it even further. With <code>early stopping</code>, this is a form of regularization</li>
<li><code>Stochastic gradient descent</code>
Rather than compute the gradient using <code>all</code> the data, use a small <code>minibatch</code> drawn at random at each step</li>
<li>An <code>epoch</code> is a count of iterations and amounts to the number of minibatch updates such that $n$ samples in total have been processed; i.e. $60K/128 \approx 469$ for <code>MNIST</code></li>
<li><code>Regularization</code>
Ridge and lasso regularization can be used to shrink the weights at each layer. Two other popular forms of regulariztion and <code>dropout</code> and <code>augmentation</code></li>
</ul>
<h2 id="droupout-learning">Droupout Learning</h2>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/d7cf9a7b-8515-4eec-bbac-157d9b005487/image.png" alt=""></p>
<ul>
<li>At each <code>SGD</code> update, randomly remove units with probability $\phi$, and scale up the weights of those retained by $1/(1-\phi)$ to compensate</li>
<li>In simple scenarios like linear regression, a version of this process can be shown to be equivalent to ridge regularization</li>
<li>As in ridge, the other units <code>stand in</code> for those temporaily removed, and their weights are drawn closer together</li>
<li>Similar to randomly omitting variables when growing trees in random forests</li>
</ul>
<h2 id="ridge-and-data-augmentation">Ridge and Data Augmentation</h2>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/929ed083-159b-4067-8290-ec57f11d05aa/image.png" alt=""></p>
<ul>
<li>Make many copies of each $(x_i,y_i)$ and add a small amount of Gaussian noise to the $x_i$ - a little cloud around each observation - but <code>leave the copies of</code> $y_i$ <code>alone</code></li>
<li>This makes the fit robust to small perturbations in $x_i$, and is equivalent to <code>ridge</code> regularization in an <code>OLS</code> setting</li>
</ul>
<h2 id="double-descent">Double Descent</h2>
<ul>
<li>With neural networks, it seems better to have too many hidden units than too few</li>
<li>Likewise more hidden layers better than few</li>
<li>Running stochastic gradients descent till zero training error often gives good out-of-sample error</li>
<li>Increasing the number of units or layers and again training till zero error sometimes gives <code>even better</code> out-of-sample error
<img src="https://velog.velcdn.com/images/kbc-1315/post/3daf37fb-1f5e-4c9a-b069-604bbae2c992/image.png" alt=""></li>
<li>When $d\leq 20$, model is OLS, and we see usual bias-variance trade-off</li>
<li>When $d&gt; 20$, we revert to minimum-norm</li>
<li>As $d$ increases above $20$, $\sum^d_{j=1} \hat \beta_j^2$ <code>decreases</code> since it is easier to achieve zero error, and hence less wiggly solutions</li>
</ul>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/5e925c5c-1908-4a9d-937a-575a5d95cfaf/image.png" alt=""></p>
<ul>
<li>To achieve a zero-residual solution with $d=20$ is a real stretch</li>
<li>Easier for larger $d$</li>
</ul>
<hr>
<ul>
<li>In a wide linear model ($p&gt;n$) fit by least squares, <code>SGD</code> with a small step size leads to a <code>minimum norm</code> zero-residual solution</li>
<li><code>Stochastic gradient flow</code> - i.e. the entire path of <code>SGD</code> solutions - is somewhat similar to ridge path</li>
<li>By analogy, deep and wide neural networks fit by <code>SGD</code> down to zero training error often give good solutions that generalize well</li>
<li>In particular cases with <code>high signal-to-noise ratio</code> - e.g. image recognition - are less prone to overfitting; the zero-error solution is mostly signal</li>
</ul>
<p><a href="https://sundong.kim/">All Contents written based on GIST - Machine Learning &amp; Deep Learning Lesson(Instructor : Prof. sun-dong. Kim)</a></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[ML&DL] 10. Unsupervised Learning]]></title>
            <link>https://velog.io/@kbc-1315/MLDL-10.-Unsupervised-Learning</link>
            <guid>https://velog.io/@kbc-1315/MLDL-10.-Unsupervised-Learning</guid>
            <pubDate>Sat, 14 Dec 2024 14:18:56 GMT</pubDate>
            <description><![CDATA[<h1 id="unsupervised-learning">Unsupervised Learning</h1>
<ul>
<li>Most of this course focuses on <code>supervised learning</code> methods such as regression and classification</li>
<li>In that setting we observe obth a set of features $X_1,X_2,\dots,X_p$ for each object, as well as a response or outcome variable $Y$</li>
<li>The goal is then to predict $Y$ using $X_1,X_2,\dots,X_p$</li>
<li>Here we instead focus on <code>unsupervised learning</code>, we where observe only the features $X_1,X_2,\dots,X_p$</li>
<li>We are not interested in prediction, because we do not have an associated response variable $Y$</li>
</ul>
<h2 id="the-goals-of-unsupervised-learning">The Goals of Unsupervised Learning</h2>
<ul>
<li>The goal is to discover interesting things about the measurements : 
is there an informative way to visualize the data?</li>
<li>Can we discover subgroups among the variables or among the observations?</li>
<li>We discuss two methods<ul>
<li><code>principal components analysis</code>
A tool used for data visulization or data pre-processing before supervised techniques are applied</li>
<li><code>clustering</code>
A broad class of methods for discovering unknown subgroups in data</li>
</ul>
</li>
</ul>
<h2 id="principal-components-analysis">Principal Components Analysis</h2>
<ul>
<li><code>PCA</code> produces a <code>low-dimensional</code> representation of a dataset</li>
<li>If finds a sequence of linear combinations of the variables that have maximal variance, and are mutually uncorrelated</li>
<li>Apart from producing derived variables for use in supervised learning problems, <code>PCA</code> also serves as a tool for data visulization</li>
<li>The <code>first principal components</code> of a set of features $X_1,X_2,\dots,X_p$ is the normalized linear combination of the features
$$
Z_1=\phi_{11}X_1+\phi_{21}X_2+\dots+\phi_{p1}X_p
$$
that has the largest variance. By <code>normalized</code>, we mean that $\sum^p_{j=1}\phi^2_{j1}=1$</li>
<li>We refer to the elements $\phi_{11},\cdots,\phi_{p1}$ as the loadings of the first principal component; together, the loadings make up the <code>principal component loading vector</code>
$$
\phi_1=\left(\phi_{11};\phi_{21};\dots;\phi_{p1}\right)^T
$$</li>
<li>We constrain the loadings so that their sum of squares is equal to one, since otherwise setting these elements to be arbitrarily large in absolute value could result in an arbitrarily large variance
<img src="https://velog.velcdn.com/images/kbc-1315/post/54ff2bb3-e003-4f1a-8d3d-bf93a33fd13f/image.png" alt=""></li>
</ul>
<h2 id="computation-of-pricinpal-components">Computation of Pricinpal Components</h2>
<ul>
<li>Suppose we have a $n\times p$ data set $X$</li>
<li>Since we are only interested in variance, we assume that each of the variables in $X$ has been centered to have mean zero (that is, the column means of $X$ are zero)</li>
<li>We then look for the linear combination of the sample feature values of the form
$$
z_{i1}=\phi_{11}x_{i1}+\phi_{21}x_{i2}+\cdots+\phi_{p1}x_{ip}
$$
for $i=1,\dots,n$ that has largest sample variance, subject to the constraint that $\sum^p_{j=1}\phi^2_{j1}=1$</li>
<li>Since each of the $x_{ij}$ has mean zero, then so does $z_{i1}$(for any value of $\phi_{j1})$</li>
<li>Hence the sample variance of the $z_{i1}$ can be written as $\frac{1}{n}\sum^n_{i=1}z^2_{i1}$</li>
<li>Plugging in (1) the first principal component loading vector solves the optimization problem
$$
\text{maximize}<em>{\phi</em>{11}, \dots, \phi_{p1}} 
\frac{1}{n} \sum_{i=1}^n 
\left( \sum_{j=1}^p \phi_{j1} x_{ij} \right)^2 
\text{subject to } 
\sum_{j=1}^p \phi_{j1}^2 = 1.
$$</li>
<li>This problem can be solved via a singular-value decomposition of the matrix $X$, a standard technique in linear algebra</li>
<li>We refer to $Z_1$ as the first principal component, with realized values $z_{11},\dots,z_{n1}$</li>
</ul>
<h2 id="geometry-of-pca">Geometry of PCA</h2>
<ul>
<li>The loading vector $\phi_1$ with elements $\phi_{11},\phi_{21},\dots,\phi_{p1}$ defines a direction in feature space along which the data vary the most</li>
<li>If we project the $n$ data points $x_1,\dots,x_n$ onto this direction, the projected values are the principal component scores $z_{11},\dots,z_{n1}$ themselves</li>
</ul>
<h2 id="further-principal-components">Further principal components</h2>
<ul>
<li>The second principal component is the linear combination of $X_1,\dots,X_p$ that has maximal variance among all linear combinations that are <code>uncorrelated</code> with $Z_1$</li>
<li>The second principal component scores $z_{12},z_{22},\dots,z_{n2}$ take the form
$$
z_{i2}=\phi_{12}x_{i1}+\dots+\phi_{p2}x_{ip}
$$
where $\phi_2$ is the second principal component loading vector, with elements $\phi_{12},\dots,\phi_{p2}$</li>
<li>It turns out that constraining $Z_2$ to be uncorrelated with $Z_1$ is equivalent to constraining the direction $\phi_2$ to be orthogonal (perpendicular) to the direction $\phi_1$ And so on</li>
<li>The principal component directions $\phi_1,\phi_2,\phi_3$ are the ordered sequence of right singular vectors of the matrix $X$, and the variance of the components are $\frac{1}{n}$ times the squares of the singular values</li>
<li>There are at most $\min(n-1,p)$ principal components<blockquote>
<p>PCA should be performed after standardization</p>
</blockquote>
</li>
</ul>
<h2 id="pca-find-the-hyperplane-closest-to-the-observations">PCA find the hyperplane closest to the observations</h2>
<ul>
<li>The first principal component loading vector has a very special property : it defines the line in $p$-dimensional space that is <code>closest</code> to the $n$ observations (using averae squared Euclidean distance as a measure of closeness)</li>
<li>The notion of principal components as the dimensions that are closest to the $n$ observations extends beyond just the first principal component</li>
<li>For instance, the first two principal components of a data set span the plan that is closest to the $n$ observations, in terms of average squared Euclidean distance</li>
</ul>
<h2 id="scaling-of-the-variables-matters">Scaling of the variables matters</h2>
<ul>
<li>If the variables are in different units, scaling each to have standard deviation equal to one is recommended</li>
<li>If they are in the same units, you might or might not scale the variables
<img src="https://velog.velcdn.com/images/kbc-1315/post/3073f272-9aa2-4eb7-812a-9d055e8e2741/image.png" alt=""></li>
</ul>
<h2 id="proportion-variance-explained">Proportion Variance Explained</h2>
<ul>
<li>To understand the strength of each component, we are interested in knowing the proportion of variance explained (PVE) by each one</li>
<li>The <code>total variance</code> present in a data set (assuming that the variables have been centered to have mean zero) is defined as
$$
\sum^p_{j=1}\text{Var}(X_j)=\sum^p_{j=1}\frac{1}{n}\sum^n_{i=1}x_{ij}^2\[0.2cm]
n:\text{row},\quad j:\text{variables}
$$
and the variance explained by the $m$th principal component is
$$
\text{Var}(Z_m)=\frac{1}{n}\sum^n_{i=1}z^2_{im}
$$</li>
<li>It can be shown that $\sum^p_{j=1}\text{Var}(X_j)=\sum^M_{m=1}\text{Var}(Z_m),;\text{with }M=\min(n-1,p)$</li>
<li>Therefore, the <code>PVE</code> of the $m$th principal component is given by the positive quantity between $0$ and $1$
$$
\frac{\sum^n_{i=1}z^2_{im}}{\sum^p_{j=1}\sum^n_{i=1}x^2_{ij}}
$$</li>
<li>The <code>PVE</code>s sum to one</li>
<li>We sometimes display the cumlative <code>PVE</code>s
<img src="https://velog.velcdn.com/images/kbc-1315/post/bba48a79-3920-450e-a3c1-a42b60f826c5/image.png" alt=""></li>
</ul>
<h2 id="how-many-principal-components-should-we-use">How many principal components should we use?</h2>
<ul>
<li>If we use principal components as a summary of our data, how many components are sufficient?<ul>
<li>No simple answer to this question, as cross-validation is not available for this purpose<ul>
<li>Why not?</li>
<li>When could we use cross-validation to select the number of components?</li>
</ul>
</li>
<li>the <code>scree plot</code> on the previous slide can be used as a guide : we look for an <code>elbow</code></li>
</ul>
</li>
</ul>
<h2 id="matrix-completion-via-principal-components">Matrix Completion via Principal Components</h2>
<ul>
<li>We pose instead a modified version of the approximation criterion
<img src="https://velog.velcdn.com/images/kbc-1315/post/7fbc863d-e370-4196-8426-86bb5fe8ffbb/image.png" alt="">
where $O$ is the set of all <code>observed</code> pairs of indices $(i,j)$ a subset of the possible $n\times p$ pairs</li>
<li>Once we solve this problem :<ul>
<li>we can estimate a missing observation $x_{ij}$ using $\hat x_{ij}=\sum^M_{m=1}\hat a_{im}\hat b_{jm}$, where $\hat a_{im}$ and $\hat b_{jm}$ are the $(i,m)$ and $(j,m)$ elements of the solution matrices $\hat A$ and $\hat B$</li>
<li>we can (approximately) recover the $M$ principal component scores and loadings, as if data were complete</li>
</ul>
</li>
</ul>
<h2 id="iterative-algorithm-for-matirx-completion">Iterative Algorithm for Matirx Completion</h2>
<ol>
<li><code>Initialize</code> : create a complete data matrix $\tilde X$ by filling in the missing value susing mean imputation</li>
<li><code>Repeat</code> : step (a)-(c) until the objective in (c) fails to decreases<ul>
<li>(a)<img src="https://velog.velcdn.com/images/kbc-1315/post/cff809a4-d336-4dc9-9b65-8fd5a7b4543e/image.png" alt="">
by computing the principal components of $\tilde X$</li>
<li>(b) For each missing entry $(i,j)\not \in O,$ set $\tilde x_{ij} \leftarrow \sum^M_{m=1}\hat a_{im}\hat b_{im}$</li>
<li>(c) Compute the objective
<img src="https://velog.velcdn.com/images/kbc-1315/post/70f003e9-093a-4e16-bb66-f3d9c0ca39be/image.png" alt=""></li>
</ul>
</li>
<li>Return the estimated missing entries $\tilde x_{ij},;(i,j)\not \in O$</li>
</ol>
<h1 id="clustering">Clustering</h1>
<h2 id="k-means-clustering">K-means clustering</h2>
<ul>
<li>Note that there is <code>no ordering of the clusters</code>, so that <code>cluster coloring is arbitrary</code></li>
<li>Let $C_1,\dots,C_K$ denotes sets containing the indices of the observations in each cluster</li>
<li>These sets satisfy two properties<ol>
<li>$C_1\cup C_2 \cup \dots\cup C_K={1,\dots,n}$. In other words, each observation belongs to at least one of the $K$ clusters</li>
<li>$C_k \cap C_{k&#39;}=\not 0$ for all $k\neq k&#39;$
In other words, the clusters are non-overlapping : no observation belongs to more than one cluster</li>
</ol>
<ul>
<li>For instnace, if the $i$th observation is in the $k$th cluster, then $i\in C_k$</li>
</ul>
</li>
</ul>
<hr>
<ul>
<li>The idea begind $K$-means clustering is that a good clustering is one for which the <code>within-cluster variation</code> is as small as possible</li>
<li>The within-cluster variation for cluster $C_k$ is a measure $\text{WCV}(C_k)$ of the amount by which the observations within a cluster differ from each other</li>
<li>Hence we wnat to solve the problem
$$
\text{minimize}<em>{C_1,\dots,C_K}\left{\sum^K</em>{k=1}\text{WCV}(C_k)\right}
$$</li>
<li>In words, this formula says that we want to partition the observation into $K$ clusters such that the total within-cluster variation, summed over all $K$ clusters, is as small as possible</li>
</ul>
<h2 id="how-to-define-within-cluster-variation">How to define within-cluster variation</h2>
<ul>
<li>Typically we use Euclidean distance
$$
\text{WCV}(C_k)=\frac{1}{|C_k|}\sum_{i,i&#39;\in C_k}\sum^p_{j=1}(x_{ij}-x_{i&#39;j})^2
$$
where $|C_k|$ denotes the number of observations in the $k$th cluster</li>
<li>Combining (2) and (3) gives the optimization problem that define $K$-means clustering
$$
\text{minimize}<em>{C_1,\dots,C_K}\left{\sum^K</em>{k=1}\frac{1}{|C_k|}\sum_{i,i&#39;\in C_k}\sum^p_{j=1}(x_{ij}-x_{i&#39;j})^2\right}
$$</li>
</ul>
<h2 id="k-means-clustering-algorithm">K-Means Clustering Algorithm</h2>
<ol>
<li>Randomly assign a number, from $1$ to $K$, to each of the observations. These serve as initial cluster assignments for the observations</li>
<li>Iterate until the cluster assignments stop changing
2.1. For each of the $K$ clusters, compute the cluster <code>centroid</code>. The $k$th cluster centroid is the vector of the $p$ feature means for the observations in the $k$th cluster
2.2. Assign each observation to the cluster whose centroid is closest (where <code>closest</code> is defined using Euclidean distance)</li>
</ol>
<h2 id="properties-of-the-algorithm">Properties of the Algorithm</h2>
<ul>
<li>This algorithm is guaranteed to decrease the value of the objective (4) at each step
$$
\frac{1}{|C_k|} \sum_{i,i&#39; \in C_k} \sum_{j=1}^p (x_{ij} - x_{i&#39;j})^2 
= 2 \sum_{i \in C_k} \sum_{j=1}^p (x_{ij} - \bar{x}<em>{kj})^2,
\[0.2cm]
\text{where } \bar{x}</em>{kj} = \frac{1}{|C_k|} \sum_{i \in C_k} x_{ij} \text{ is the mean for feature } j \text{ in cluster } C_k.
$$</li>
<li>however it is not guaranteed to give the global minimum
<img src="https://velog.velcdn.com/images/kbc-1315/post/84f23acc-d8d8-444e-9c06-599d010c157e/image.png" alt=""></li>
</ul>
<h2 id="hierarchical-clustering">Hierarchical Clustering</h2>
<ul>
<li><code>K-means</code> requires us to pre-specify the number of clusters $K$</li>
<li>We describe <code>bottom-up</code> or <code>agglomerative</code> clustering</li>
<li>The approach in words :<ul>
<li>Start with each point in its own cluster</li>
<li>Identify the closest two clusters and merge them</li>
<li>Repeat</li>
<li>Ends when all points are in a single cluster
<img src="https://velog.velcdn.com/images/kbc-1315/post/21ffccff-75ec-4528-892f-b0a202394292/image.png" alt=""></li>
</ul>
</li>
</ul>
<h3 id="linkage">Linkage</h3>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/526094a5-2807-4ba8-a8d2-334ce2ccfb86/image.png" alt=""></p>
<h2 id="choice-of-dissimilarity-measure">Choice of Dissimilarity Measure</h2>
<ul>
<li>So far have used <code>Euclidean distance</code></li>
<li>An alternative is <code>correlation-based distance</code> which considers two observations to be similar if their features are highly correlated</li>
<li>This is an unusual use of correlation, which is noramlly computed betwen variables; here it is computed between the observation profiles for each pair of observations
<img src="https://velog.velcdn.com/images/kbc-1315/post/07103e10-28ac-47ef-b08c-8e94c9dfdb7a/image.png" alt=""></li>
</ul>
<h2 id="practical-issues">Practical issues</h2>
<ul>
<li><code>Scaling of the variable matters</code></li>
<li>Should the observations of features first be standardized in some way?</li>
<li>For instance, maybe the variables should be centered to have mean zero and scaled to have standard deviation one</li>
<li>In the case of hierarchical clustering,<ul>
<li>What dissimilarity measure should be used?</li>
<li>What type of linkage should be used?</li>
</ul>
</li>
<li>How many clusters to choose? ( in both K-means or hierarchical clustering)<blockquote>
<p>Difficult problem</p>
</blockquote>
</li>
<li>No agreed-upon method</li>
<li>Which features should we use to drive the clustering?</li>
</ul>
<p><a href="https://sundong.kim/">All Contents written based on GIST - Machine Learning &amp; Deep Learning Lesson(Instructor : Prof. sun-dong. Kim)</a></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[ML&DL] 9. Survival Analysis]]></title>
            <link>https://velog.io/@kbc-1315/MLDL-9.-Survival-Analysis</link>
            <guid>https://velog.io/@kbc-1315/MLDL-9.-Survival-Analysis</guid>
            <pubDate>Sat, 14 Dec 2024 13:14:52 GMT</pubDate>
            <description><![CDATA[<h1 id="survival-analysis">Survival Analysis</h1>
<ul>
<li><code>Survival analysis</code> concerns a special kind of outcome variable : the <strong>time until an event occurs</strong></li>
<li>For example, suppose that we have conducted a five-year medical study, in which patients have been treated for cance</li>
<li>We would like to fit a model to predict patient survival time, using features such as baseline health measurements or type of treatment</li>
<li>Sounds like a <code>regression problem</code>. But there is an important complication : some of the patients have survived until the end of the study. Such a patient&#39;s survival time is said to be <code>censored</code></li>
<li>We do not wnat to discard this subset of surviving patients, since the fact that they survived at least five years amounts to valuable information</li>
</ul>
<h2 id="non-medical-examples">Non-medical Examples</h2>
<ul>
<li>The applications of survival analysis extend far beyond medicine. For example, consider a company that wishes to model <code>churn</code>, the event when customers cancel subscription to a service</li>
<li>The company might collect data on customers over some time period, in order to predict each customer&#39;s time to cancellation</li>
<li>However, presumably not all customers will have cancelled their subscription by the end of this time period; for such customers, the time to cancellation is censored</li>
<li><code>Survival analysis</code> is a very well-studied topic within statistic. However, it has received relatively little attention in the machine learning community</li>
</ul>
<h2 id="survival-and-censoring-times">Survival and Censoring Times</h2>
<ul>
<li>For each individual, we suppose that there is a true <code>failure</code> or <code>event</code> time $T$, as well as a true censoring time $C$</li>
<li>The <code>survival time</code> represents the time at which the event of interest occurs (such as death)</li>
<li>By contrast, the <code>censoring</code> is the time at which censoring occurs: for example, the time at which the patient drops out of the study or the study ends</li>
</ul>
<hr>
<ul>
<li>We observe either the survival time $T$ or else the censoring time $C$. Specifically, we observe the random variable
$$
Y=\min(T,C)
$$</li>
<li>If the event occurs before censoring (i.e. $T&lt;C$) then we observe the true survival time $T$; if censoring occurs before the event ($T&gt;C$) then we observe the censoring time. We also observe a status indicator
$$
\delta=\begin{cases}1\quad\text{if }T\leq C\0\quad\text{if }T&gt;C\end{cases}
$$</li>
<li>Finally, in our dataset we observe $n$ paris $(Y,\delta)$, which we denote as $(y_1,\delta_1),\dots,(y_n,\delta_n)$</li>
</ul>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/5d775389-276b-4ac6-9ce8-6776a26114bd/image.png" alt=""></p>
<ul>
<li>Here is an illustration of censored survival data</li>
<li>For patients $1$ and $3$, the event was observed</li>
<li>Patient $2$ was alive when the study ended</li>
<li>Patient $4$ dropped out of the study</li>
</ul>
<h2 id="a-closer-look-at-censoring">A Closer Look at Censoring</h2>
<ul>
<li>Suppose that a number of patients drop out of a cancer study early because they are very sick</li>
<li>An analysis that does not take into consideration the reason why the patients dropped out will likely overestimate the true average survival time</li>
<li>Similarly, suppose that males who are very sick are more likely to drop out of the study than females who are very sick</li>
<li>Then a comparison of male and female survival times may wrongly suggest that males survive longer than females</li>
<li>In general, we need to assume that, conditional on the features, the event time $T$ is <code>independent</code> of the censoring time $C$</li>
<li>The two examples above violate the assumption of independent censoring</li>
</ul>
<h2 id="the-survival-curve">The Survival Curve</h2>
<ul>
<li>The survival function ( or curve) is defined as
$$
S(t)=\Pr(T&gt;t)
$$</li>
<li>This decreasing function quantifies the probability of surviving past time $t$</li>
<li>For example, suppose that a company is interested in modeling customer churn</li>
<li>Let $T$ represent the time that a customer cancels a subscription to the company&#39;s service</li>
<li>Then $S(t)$ represents the probability that a customer cancels later than time $t$</li>
<li>The larger the value of $S(t)$, the less likely that the customer will cancel before time $t$</li>
</ul>
<h2 id="estimating-the-survival-curve">Estimating the Survival Curve</h2>
<ul>
<li>Consider the <code>BrainCancer</code> dataset, which contains the survival times for patients with primary brain tumors undergoing treatment with stereotactic radiation methods</li>
<li>Only $53$ of the $88$ patients were still alive at the end of the study</li>
<li>Suppose we&#39;d like to estimate $S(20)=\Pr(T&gt;20)$, the probability that a patient survives for at least $20$ months</li>
<li>It is tempting to simply compute the proportion of patients who are known to have survived past $20$ months, that is, the proportion of patients for whom $Y&gt;20$</li>
<li>This turns out to be $48/88$ or approximately $55%$</li>
<li>However, this does not seem quite right : $17$ of the $40$ patients who did not survive to $20$ months were actually censored, and this analysis implicitly assumes they died before $20$ months</li>
<li>Hence it is probably an underestimate</li>
</ul>
<table>
<thead>
<tr>
<th align="center"><img src="https://velog.velcdn.com/images/kbc-1315/post/d167d333-5fd7-4f94-8113-d82b94327f57/image.png" alt=""></th>
<th align="center"><img src="https://velog.velcdn.com/images/kbc-1315/post/8621e985-db61-4b86-9f5a-6ec638235d7d/image.png" alt=""></th>
<th align="center"><img src="https://velog.velcdn.com/images/kbc-1315/post/50e7f2ed-b785-4a34-acfc-c50a1d1e9eb7/image.png" alt=""></th>
</tr>
</thead>
<tbody><tr>
<td align="center"><img src="https://velog.velcdn.com/images/kbc-1315/post/05754b35-9c24-4a35-a0ab-ec2710be5f74/image.png" alt=""></td>
<td align="center"></td>
<td align="center"></td>
</tr>
</tbody></table>
<h2 id="kaplen-meier-survival-curve">Kaplen-Meier Survival Curve</h2>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/ba31cc56-ad94-48b8-bfec-ebba92aab6ff/image.png" alt=""></p>
<ul>
<li>Each point in the solid step-like curve shows the estimated probability of surviving past the time indicated on the horizontal axis</li>
<li>The estimated probability of survival pas $20$ months is $71%$, which is quite a bit higher than the naive estimate of $55%$ presented earlier</li>
</ul>
<h2 id="the-log-rank-test">The Log-Rank Test</h2>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/58342f50-4a1e-48b3-a830-dabb7f2663b9/image.png" alt=""></p>
<ul>
<li>We wish to compare the survival of males to that of females</li>
<li>Shown are the <code>Kaplan-Meier</code> survival curves for the two groups</li>
<li>Females seem to fare a little better up to about $50$ months, but then the two curves both level off to about $50%$</li>
<li>How can we carry out a formal test of equality of the two survival curves?</li>
<li>At first glance, a two-sample $t$-test seems like an obvious choice : but the presence of censoring again creates a complication</li>
<li>To overcome this challenge, we will conduct a <code>log-rank test</code></li>
</ul>
<hr>
<ul>
<li>Recall that $d_1&lt;d_2&lt;\cdots&lt;d_K$ are the unique death times among the <code>non-censored patients</code>, $r_k$ is the number of patients at risk at time $d_k$, and $q_k$ is the number of patients who died at time $d_k$</li>
<li>We further define $r_{1k}$ and $r_{2k}$ to be the number of patients in groups $1$ and $2$, respectively, who are at risk at time $d_k$</li>
<li>Similarly, we define $q_{1k}$ and $q_{2k}$ to be the number of patients in groups $1$ and $2$, respectively, who died  at time $d_k$</li>
<li>Note that $r_{1k}+r_{2k}=r_k$ and $q_{1k}+q_{2k}=q_k$</li>
</ul>
<h2 id="details-of-the-test-statistic">Details of the Test Statistic</h2>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/fd589fbe-d0f6-494d-80d8-1b83d6114bfe/image.png" alt=""></p>
<ul>
<li>At each death time $d_k$, we construct a $2\times 2$ table of counts of the form shown above</li>
<li>Note that if the death times are unique (i.e. no two individuals die  at the same time), then one of $q_{1k}$ and $q_{2k}$ equals one, and the other equals zero</li>
<li>To test $\mathcal{H}_0:E(X)=0$ for some random variable $X$, one approach is to construct a test statistic of the form
$$
W=\frac{X-E(X)}{\sqrt{\text{Var}(X)}}
$$
where $E(X)$ and $\text{Var}(X)$ are the expectation and variance, respectively, of $X$ under $\mathcal{H}_0$</li>
<li>In order to construct the <code>log-rank</code> test statistic, we compute a quantity that takes exactly the form above, with $X=\sum^K_{k=1}q_{1k}$, where $q_{1k}$ is given in the top left of the table above</li>
</ul>
<hr>
<ul>
<li>The resulting formula for the log-rank test statistic is
$$
W=\frac{\sum^K_{k=1}(q_{1k}-E(q_{1k}))}{\sqrt{\sum^K_{k=1}\text{Var}(q_{1k})}}=\frac{\sum^K_{k=1}\left(q_{1k}-\frac{q_k}{r_k}r_{1k}\right)}{\sqrt{\sum^K_{k=1}\frac{q_k(r_{1k}/r_k)(1-r_{1k}/r_k)(r_k-q_k)}{r_k-1}}}
$$</li>
<li>When the sample size is large, the <code>log-rank test</code> statistic $W$ has approximately a standard normal distribution</li>
<li>This can be used to compute a $p$-value for the <code>null hypothesis</code> that there is no difference between the survival curves in the two groups</li>
</ul>
<hr>
<ul>
<li>Comparing the survival times of females and males on the <code>BrainCancer</code> data gives a <code>log-rank test statistic</code> of
$$
W=1.2
$$
which corresponds to a two-sided $p$-value of $0.2$
Then, can not reject <code>null hypothesis</code></li>
</ul>
<h1 id="regression-models-with-a-survival-response">Regression Models with a Survival Response</h1>
<ul>
<li>We now consider the task of fitting a regression model to survival data</li>
<li>We wish to predict the true survival time $T$</li>
<li>Since the observed quantity $Y=\min(T,C)$ is positive and may have a long right tail, we might be tempted to fit a linear regression of $\log(Y)$ on $X$</li>
<li>But <code>censoring</code> again creates a problem</li>
<li>To overcome this difficulty, we instead make use of a sequential construction, similar to the idea used for the <code>Kaplain-Meier</code> survival curve</li>
</ul>
<h2 id="the-hazard-function">The Hazard Function</h2>
<ul>
<li>The <code>hazard function</code> or <code>hazard rate</code> - also known as the <code>force of mortality</code> - is formally defined as
$$
h(t)=\lim_{\Delta t\rightarrow 0}\frac{\Pr(t&lt;T\leq t+\Delta t|T&gt;t)}{\Delta t}
$$
where $T$ is the (true) survival time</li>
<li>It is the death rate in the instant after time $t$, given survival up to that time</li>
<li>The hazard function is the basis for the <code>Proportional Hazards Model</code></li>
</ul>
<h2 id="the-proportional-hazards-model">The Proportional Hazards Model</h2>
<ul>
<li>The proportional hazards assumprion states that
$$
h(t|x_i)=h_0(t)\exp\left(\sum^p_{j=1}x_{ij}\beta_j\right)
$$
where $h_0(t)\geq 0$ is an <code>unspecified function</code>, known as the <code>baseline hazard</code></li>
<li>It is the hazrard function for an individual with features $x_{i1} = \cdots=x_{ip} = 0$</li>
<li>The name <code>proportional hazards</code> arises from the fact that the hazard function for an individual with feature vector $x_i$ is some unknown function $h_0(t)$ times the factor 
$$
\exp\left(\sum^p_{j=1} x_{ij}\beta_j\right)
$$</li>
<li>The quantity
$$
\exp\left(\sum^p_{j=1}x_{ij}\beta_j\right)
$$
is called the <code>relative risk</code> for the feature vector $x_i=(x_{i1},\cdots,x_{ip})$, realtive to that the feature vector $x_i=(0,\cdots,0)$</li>
<li>What does it mean that the baseline hazard function $h_0(t)$ is unspecified</li>
<li>Basically, we make no assumption about its functional form</li>
<li>We allow the instantaneous probability of death at time $t$, given that one has survived at least until time $t$, to take any form</li>
<li>This means that the hazard function is very flexible and can model a wide range of relationships between the covariates and survival time</li>
<li>Our only assumption is that a one-unit increase in $x_{ij}$ corresponds to an increase in $h(t|x_i)$ by a factor of $\exp(\beta_j)$</li>
</ul>
<hr>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/81531a73-368b-4afa-bf20-4a7dafc0dbab/image.png" alt=""></p>
<ul>
<li>Here is an example with $p=1$ and a binary covariate $x_i \in{0,1}$</li>
<li><code>Top row</code> : the log hazard and the survival function under the model are shown (green for $x_i=0$ and black for $x_i=1$). Because of the proportional hazards assumption, the log hazard functions differ by a constant, and the survival functions do not cross</li>
<li><code>Bottom row</code> : the proportional hazards assumptions does not hold</li>
</ul>
<h2 id="partial-likelihood">Partial Likelihood</h2>
<ul>
<li>Because the form of the baseline hazard is unknown, we cannot simply plug $h(t|x_i)$ into the likelihood and then estimate $\beta=(\beta_1,\dots,\beta_p)^T$ by maximum likelihood</li>
<li>The magic of <code>Cox&#39;s proportional hazard model</code> lies in the fact that it is in fact possible to estimate $\beta$ <strong>without having to specify the form of</strong> $h_0(t)$</li>
<li>To accomplish this, we make use of the same <code>sequential in time</code> logic that we used to derive the <code>Kaplan-Meier</code> survival curve and the log-rank test</li>
<li>Then the total hazard at failure time $y_i$ for the at-risk observations is
$$
\sum_{i&#39;:y_{i&#39;}\geq y_i}h_0(y_i)\exp\left(\sum^p_{j=1}x_{i&#39;j}\beta_j\right)
$$</li>
</ul>
<hr>
<ul>
<li>Therefore, the probability that the $i$th observation is the one to fail at time $y_i$ (as opposed to one of the other observations in the risk set) is
$$
0\leq \frac{h_0(y_i)\exp\left(\sum^p_{j=1}x_{ij}\beta_j\right)}{\sum_{i&#39;:y_{i&#39;}\geq y_i}h_0(y_i)\exp\left(\sum^p_{j=1}x_{i&#39;j}\beta_j\right)}=\frac{\exp\left(\sum^p_{j=1}x_{ij}\beta_j\right)}{\sum_{i&#39;:y_{i&#39;}\geq y_i}\exp\left(\sum^p_{j=1}x_{i
&#39;j}\beta)_i\right)}\leq 1
$$</li>
<li>Notice that the unspecified baseline hazard function $h_0(y_i)$ cancels out of the numerator and denominator</li>
</ul>
<hr>
<ul>
<li>The partial likelihood is simply the product of these probabilities over all of the <code>uncensored observations</code>
$$
\text{PL}(\beta)=\prod_{i:\delta_i=1}\frac{\exp\left(\sum^p_{j=1}x_{ij}\beta_j\right)}{\sum_{i&#39;:y_{i&#39;}\geq y_i}\exp\left(\sum^p_{j=1}x_{i&#39;j}\beta_j\right)}
$$</li>
<li>Critically, the partial likelihood is valid regardless of the true value of $h_0(t)$, making the model very flexible and robust
<img src="https://velog.velcdn.com/images/kbc-1315/post/99b00daa-b8f3-48de-b219-761913051c9d/image.png" alt=""><h2 id="relative-risk-functions-at-each-failure-time">Relative Risk Functions at each Failure Time</h2>
$$
RR_1(\boldsymbol{\beta}) = 
\frac{\exp\left(\sum_{j=1}^p x_{1j} \beta_j \right)}
{\sum_{i&#39;:y_{i&#39;} \geq y_1} \exp\left(\sum_{j=1}^p x_{i&#39;j} \beta_j \right)}\[0.3cm]</li>
</ul>
<p>RR_3(\boldsymbol{\beta}) = 
\frac{\exp\left(\sum_{j=1}^p x_{3j} \beta_j \right)}
{\sum_{i&#39;:y_{i&#39;} \geq y_3} \exp\left(\sum_{j=1}^p x_{i&#39;j} \beta_j \right)}\[0.3cm]</p>
<p>RR_5(\boldsymbol{\beta}) = 
\frac{\exp\left(\sum_{j=1}^p x_{5j} \beta_j \right)}
{\sum_{i&#39;:y_{i&#39;} \geq y_5} \exp\left(\sum_{j=1}^p x_{i&#39;j} \beta_j \right)}
$$</p>
<table>
<thead>
<tr>
<th align="center"><img src="https://velog.velcdn.com/images/kbc-1315/post/7c11f3e7-376d-4662-8890-518ffaec6af1/image.png" alt=""></th>
<th align="center"><img src="https://velog.velcdn.com/images/kbc-1315/post/7a70dbfe-bbad-4fda-89e4-c2d786ea936f/image.png" alt=""></th>
<th align="center"><img src="https://velog.velcdn.com/images/kbc-1315/post/420cf4c4-e887-4ae3-bfc2-dfd367e9d705/image.png" alt=""></th>
</tr>
</thead>
</table>
<p><a href="https://sundong.kim/">All Contents written based on GIST - Machine Learning &amp; Deep Learning Lesson(Instructor : Prof. sun-dong. Kim)</a></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[ML&DL] 8. Support Vector Machines]]></title>
            <link>https://velog.io/@kbc-1315/MLDL-8.-Support-Vector-Machines</link>
            <guid>https://velog.io/@kbc-1315/MLDL-8.-Support-Vector-Machines</guid>
            <pubDate>Sat, 14 Dec 2024 11:36:06 GMT</pubDate>
            <description><![CDATA[<h1 id="support-vector-machines">Support Vector Machines</h1>
<ul>
<li>Here we approach the two-class classification problem in a direct way :<blockquote>
<p>We try and find a plane that seperates the classes in feature space</p>
</blockquote>
</li>
<li>If we cannot, we get creative in two ways :<ul>
<li>We soften what we mean by <code>seperates</code>, and</li>
<li>We enrich and enlarge the feature space so that separation is possible</li>
</ul>
</li>
</ul>
<h2 id="what-is-a-hyperplane">What is a Hyperplane?</h2>
<ul>
<li>A <code>hyperplane</code> in $p$ dimensions is a flat affine subspace of dimension $p-1$</li>
<li>In general the equation for a <code>hyperplane</code> has the form
$$
\beta_0+\beta_1X_1+\cdots+\beta_pX_p=0
$$</li>
<li>In $p=2$ dimensions a <code>hyperplane</code> is a line</li>
<li>If $\beta_0=0,$ the <code>hyperplane</code> goes throught the origin, otherwise not</li>
<li>The vector $\beta=(\beta_1,;\beta_2,\cdots,\beta_p)$ is called the normal vector - it points in a direction <code>orthogonal</code> to the surface of a <code>hyperplane</code></li>
</ul>
<h2 id="separating-hyperplanes">Separating Hyperplanes</h2>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/983cdb90-8f4f-4622-866c-75a87f816a9d/image.png" alt=""></p>
<ul>
<li>If $f(X)=\beta_0+\beta_1X_1+\cdots+\beta_pX_p$, then $f(X)&gt;0$ for points on one side of the <code>hyperplane</code>, and $f(X)&lt;0$ for points on the other</li>
<li>If we code the colored points as $Y_i=\pm1$ for blue, say, and $Y_i=-1$ for mauve, then if $Y_i\cdot f(X_i)&gt;0$ for all $i$, $f(X)=0$ defines a <code>separating hyperplane</code>
$$
d=\frac{|\beta_0+\beta_1X_1+\cdots+\beta_pX_p|}{\sqrt{\beta_1^2+\cdots+\beta_p^2}}
$$</li>
</ul>
<h2 id="maximal-margin-classifier">Maximal Margin Classifier</h2>
<ul>
<li>Among all seperating <code>hyperplanes</code>, find the one that makes the biggest gap or <code>margin</code> between the two classes
<img src="https://velog.velcdn.com/images/kbc-1315/post/7aba5e4f-60fe-45a7-91a7-b12d780e4569/image.png" alt=""></li>
<li>Constrained optimization problem
$$
\text{maximize M}\[0.2cm]
\text{subject to }\sum^p_{j=1}\beta^2_j=1\[0.3cm]
y_i(\beta_0+\beta_1x_{i1}+\cdots+\beta_px_{ip}\geq M,\quad\text{for all }i=1,\dots,N
$$</li>
</ul>
<h2 id="non-separable-data">Non-separable Data</h2>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/8f094cb9-c5f8-47ca-a50b-569311a64625/image.png" alt=""></p>
<ul>
<li>The data are not separable by a linear boundary</li>
<li>This is often the ase, unless $N&lt;p$</li>
</ul>
<h2 id="noisy-data">Noisy Data</h2>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/8ce8300c-908d-4d15-aabd-e16284f6fc16/image.png" alt=""></p>
<ul>
<li>Sometimes the data are separable, but noisy</li>
<li>This can lead to a poor solution for the <code>maximal-margin</code> classifier</li>
<li>The <code>support vector classifier</code> maximizes a <code>soft margin</code></li>
</ul>
<h2 id="support-vector-classifier">Support Vector Classifier</h2>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/8099f893-828c-4694-bf37-a469f1cb377f/image.png" alt="">
$$
\text{maximize M subject to }\sum^p_{j=1}\beta^2_j=1\[0.3cm]
y_i(\beta_0+\beta_1x_{i1}+\cdots+\beta_px_{ip})\geq M(1-\epsilon_i),\[0.3cm]
\epsilon_i\geq0,;\sum^n_{i=1}\epsilon_i\leq C
$$</p>
<ul>
<li>$\epsilon_i$ : slack variable</li>
<li>$C$ : Budget
<img src="https://velog.velcdn.com/images/kbc-1315/post/33120490-0d7d-4aba-bf34-1dac9f1a53f5/image.png" alt=""></li>
</ul>
<h2 id="linear-boundary-can-fail">Linear boundary can fail</h2>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/2555d550-80f2-4399-a175-9ee3b9bd0768/image.png" alt=""></p>
<ul>
<li>Sometimes a linear boundary simply won&#39;t work, no matter what value of $C$</li>
<li>The example on the left is such a case. What to do?</li>
</ul>
<h1 id="featue-expansion">Featue Expansion</h1>
<ul>
<li>Enlarge the space of features by including transformations;
e.g. $X^2_1,X^3_1,X_1X_2,X_1X^2_2,\dots$ Hence go from a $p$-dimensional space to a $M&gt;p$ dimensional space</li>
<li>Fit a <code>support-vector</code> classifier in the enlarged space</li>
<li>This results in <code>non-linear</code> decision boundaries in the original space</li>
<li>Example : Suppose we use $(X_1,X_2,X^2_1,X_2^2,X_1X_2)$ instead of just $(X_1,X_2)$. Then the decision boundary would be of the form
$$
\beta_0+\beta_1X_1+\beta_2X_2+\beta_3X^2_1+\beta_4X^2_2+\beta_5X_1X_2=0
$$</li>
<li>This leads to nonlinear decision boundaries in the original space(quadratic conic sections)</li>
</ul>
<h2 id="cubic-polynomials">Cubic Polynomials</h2>
<ul>
<li>Here we use a basis expansion of cubin polynomials</li>
<li>From $2$ variables to $9$</li>
<li>The <code>support-vector classifier</code> in the enlarged space solves the problem in the lower-dimensional space
<img src="https://velog.velcdn.com/images/kbc-1315/post/14c19c62-628f-4113-9fe1-c8faf1902688/image.png" alt=""></li>
</ul>
<p>$$
\beta_0+\beta_1X_1+\beta_2X_2+\beta_3X^2_1+\beta_4X^2_2+\beta_5X_1X_2+\beta_6X^3_1+\beta_7X^3_2+\beta_8X_1X^2_2+\beta_9X^2_1X_2=0
$$</p>
<h2 id="nonlinearities-and-kernels">Nonlinearities and Kernels</h2>
<ul>
<li>Polynomials (especially high-dimensional ones) get wild rather fast</li>
<li>There is a more elegant and controlled way to introduce nonlinearities in <code>support-vector</code> classifiers - through the use of <code>kernels</code></li>
<li>Before we discuss these, we must understand the role of <code>inner products</code> in <code>support-vector</code> classifiers</li>
</ul>
<h3 id="inner-products-and-support-vectors">Inner products and Support Vectors</h3>
<p>$$
&lt;x_i,x_{i&#39;}&gt;=\sum^p_{j=1}x_{ij}x_{i&#39;j} :\text{inner product between vectors}
$$</p>
<ul>
<li>The linear <code>support vector</code> classifier can be represented as 
$$
f(x)=\beta_0+\sum^n_{i=1}\alpha_i&lt;x,x_i&gt;;:\text{n parameters} 
$$</li>
<li>To estimate the parameters $\alpha_1,\dots,\alpha_n$ and $\beta_0$, all we need are the $\left(\begin{matrix}n\2\end{matrix}\right)$ inner products $&lt;x_i,x_{i&#39;}&gt;$ between all pairs of training observations</li>
<li>It turns out that most of the $\hat \alpha_i$ can be zero :
$$
f(x)=\beta_0+\sum_{i\in S}\hat \alpha_i&lt;x,x_i&gt;
$$</li>
<li>$S$ is the <code>support set</code> of indies $i$ such that $\hat \alpha_i &gt;0$</li>
</ul>
<h3 id="kernels-and-support-vector-machines">Kernels and Support Vector Machines</h3>
<ul>
<li>If we can compute inner-products between observations, we can fit a <code>SV</code> classifier. Can be quite abstract!</li>
<li>Some special <code>kernel functions</code> can do this for us
$$
K(x_i,x_{i&#39;})=\left(1+\sum^p_{j=1}x_{ij}x_{i&#39;j}\right)^d
$$
computes this <code>inner-products</code> needed for $d$ dimensional polynomials - $\left(\begin{matrix}p+d\d\end{matrix}\right)$ basis functions<blockquote>
<p>Try it for $p=2$ and $d=2$</p>
</blockquote>
</li>
<li>The solution has the form
$$
f(x)=\beta_0+\sum_{i \in S}\hat \alpha_i K(x,x_i)
$$</li>
</ul>
<h3 id="radial-kernel">Radial Kernel</h3>
<p>$$
K(x_i,x_{i&#39;})=\exp\left(-\gamma\sum^p_{j=1}\left(x_{ij}-x_{i&#39;j}\right)^2\right)
$$
<img src="https://velog.velcdn.com/images/kbc-1315/post/1baf271d-0a38-4236-8cf3-bad7feb5477a/image.png" alt="">
$$
f(x)=\beta_0+\sum_{i\in S}\hat \alpha_i K(x,x_i)
$$</p>
<ul>
<li>Implict feature space; very high dimensional</li>
<li>Controls variance by squashing down most dimensions severely</li>
</ul>
<h3 id="example--heart-data">Example : Heart Data</h3>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/a355e9ce-7370-4509-baa8-3a44cbc5bbf6/image.png" alt=""></p>
<ul>
<li><code>ROC Curve</code> is obtained by changing the threshold $0$ to threshold $t$ in $\hat f(X)&gt;t$, and recording <code>false positive</code> and <code>true positive</code> rates as $t$ varies</li>
<li>here we see <code>ROC curves</code> on training data
<img src="https://velog.velcdn.com/images/kbc-1315/post/c0875ee5-fe51-4461-9316-97a963917ac1/image.png" alt=""></li>
</ul>
<h1 id="svms--more-than-2-classes">SVMs : more than 2 classes?</h1>
<ul>
<li>The <code>SVM</code> as defined works for $K=2$ classes</li>
<li>What do we do if we have $K&gt;2$ classes?<ul>
<li><code>OVA</code> : One versus All.
Fit $K$ different 2-class <code>SVM classifiers</code> $\hat f_k(x),;k=1,\dots,K;$ each class versus the rest
Classify $x^<em>$ to the class for which $\hat f_k(x^</em>)$</li>
<li><code>OVO</code> : One versus One
Fit all $\left(\begin{matrix}K\2\end{matrix}\right)$ pairwise classifiers $\hat f_{kl}(x)$
Classify $x^*$ to the class that wins the most pairwise competitions</li>
</ul>
</li>
<li>Which to choose? If $K$ is not too large, use <code>OVO</code></li>
</ul>
<h1 id="support-vector-vs-logistic-regression">Support Vector vs Logistic Regression?</h1>
<ul>
<li><p>With $f(X)=\beta_0+\beta_1X_1+\cdots+\beta_pX_p$ can rephrase <code>support-vector</code> classifier optimization as 
$$
\min_{\beta_0,\dots,\beta_p}\left{\sum^n_{i=1}\max\left[0,1-y_if(x_i)\right]+\lambda\sum^p_{j=1}\beta^2_j\right}
$$
<img src="https://velog.velcdn.com/images/kbc-1315/post/d7353bef-d447-45f0-a8c6-30b46e3c381a/image.png" alt=""></p>
</li>
<li><p>This has the form <code>loss plus penalty</code></p>
</li>
<li><p>The loss is known as the <code>hinge loss</code> very similar to <code>loss</code> in logistic regression (negative log-likelihood)</p>
</li>
</ul>
<h2 id="which-to-use--svm-or-logistic-regression">Which to use : SVM or Logistic Regression</h2>
<ul>
<li>When classes are (nearly) separable, <code>SVM</code> does better than <code>LR</code>. So does <code>LDA</code></li>
<li>When not, <code>LR</code> (with ridge penalty) and <code>SVM</code> very similar</li>
<li>If you wish to estimate probabilities, <code>LR</code> is the choice</li>
<li>For nonlinear boundaries, kernel <code>SVM</code>s are popular</li>
<li>Can use kernels with <code>LR</code> and <code>LDA</code> as well, but computations are more expensive</li>
</ul>
<p><a href="https://sundong.kim/">All Contents written based on GIST - Machine Learning &amp; Deep Learning Lesson(Instructor : Prof. sun-dong. Kim)</a></p>
]]></description>
        </item>
        <item>
            <title><![CDATA[[ML&DL] 7. Multiple Hypothesis Testing]]></title>
            <link>https://velog.io/@kbc-1315/MLDL-7.-Multiple-Hypothesis-Testing</link>
            <guid>https://velog.io/@kbc-1315/MLDL-7.-Multiple-Hypothesis-Testing</guid>
            <pubDate>Sat, 14 Dec 2024 10:45:40 GMT</pubDate>
            <description><![CDATA[<h1 id="multiple-hypothesis-testing">Multiple Hypothesis Testing</h1>
<ul>
<li>This session focuses on <code>multiple hypothesis testing</code></li>
<li>A single null hypothesis might look like<blockquote>
<p>$\mathcal{H}_0$ : the expected blood pressures of mice in the control and treatment groups are the same</p>
</blockquote>
</li>
<li>We will now consider testing $m$ null hypotheses, $H_{01},\dots,H_{0m}$ 
where e.g.<blockquote>
<p>$\mathcal{H}_{0j}$ : the expected values of the $j^{th}$ biomarker among mice in the control and treatment groups are equal</p>
</blockquote>
</li>
<li>In this setting, we need to be careful to avoid incorrectly rejecting too many null hypotheses, 
i.e. having too many false positives</li>
</ul>
<h1 id="a-quick-review-of-hypothesis-testing">A Quick Review of Hypothesis Testing</h1>
<ul>
<li>Hypothesis tests allow us to answer simple <code>yes-or-no</code> questions, such as<ul>
<li>Is the true coefficient $\beta_j$ in a linear regression equal to zero?</li>
<li>Does the expected blood pressure among mice in the treatment group equal the expected blood pressure among mice in the control group?</li>
</ul>
</li>
<li>Hypothesis testing proceeds as follows :<ol>
<li>Define the null and alternative hypotheses</li>
<li>Construct the test statistic</li>
<li>Compute the $p$-value</li>
<li>Decide whether to reject the null hypothesis</li>
</ol>
</li>
</ul>
<h2 id="1-define-the-null-and-alternative-hypotheses">1. Define the Null and Alternative Hypotheses</h2>
<ul>
<li>We divide the world into <code>null</code> and <code>alternative</code> hypotheses</li>
<li>The <code>null hypothesis</code> $\mathcal{H}_0$, is the default state of belief about the world. For instance :<ol>
<li>The true coefficient $\beta_j$ equals <code>zero</code></li>
<li>There is no difference in the expected blood pressure</li>
</ol>
</li>
<li>The <code>alternative hypothesis</code> $\mathcal{H}_a$, represents something different and unexpected. For instnace :<ol>
<li>The true coefficient $\beta_j$ is <code>non-zero</code></li>
<li>There is a difference in the expected blood pressure</li>
</ol>
</li>
</ul>
<h2 id="2-construct-the-test-statistic">2. Construct the Test Statistic</h2>
<ul>
<li>The test statistis summarizes the extent to which our data are consistent with $\mathcal{H}_0$</li>
<li>Let $\hat \mu_t/\hat \mu_c$ respectively denote the average blood pressure for the $n_t/n_c$ mice in the treatment and control groups</li>
<li>To test $\mathcal{H}_0$ : $\mu_t=\mu_c$, we use a two-sample $t$-statistic
$$
T=\frac{\hat \mu_t-\hat \mu_c}{s\sqrt{\frac{1}{n_t}+\frac{1}{n_c}}}\[0.3cm]
S:\text{total standard deviation}\[0.3cm]
=\frac{(N_t-1)S_t^2+(N_c-1)S_c^2}{n_t+n_c-2}
$$</li>
</ul>
<h2 id="3-compute-the-p-value">3. Compute the p-value</h2>
<ul>
<li>The $p$-value is the probability of observing a test statistic at least as extreme as the observed statistic, <code>under the assumption that</code> $\mathcal{H}_0$ is true</li>
<li>A small $p$-value provides evidence <code>against</code> $\mathcal{H}_0$</li>
<li>Suppose we compute $T=2.33$ for our test of $\mathcal{H}_0:\mu_t=\mu_c$</li>
<li>Under $\mathcal{H}_0,;T\sim\mathcal{N}(0,1)$ for a two-sample $t$-statistic
<img src="https://velog.velcdn.com/images/kbc-1315/post/6b2f0309-fa46-4cf8-901f-f01779b40fd6/image.png" alt=""></li>
<li>The p-value is $0.02$ because, if $\mathcal{H}_0$ is true, we would only see $|T|$ this large $2%$ of the time</li>
</ul>
<h2 id="4-decide-whether-to-reject-null-hypothesis-part-1">4. Decide Whether to Reject Null Hypothesis, Part 1</h2>
<ul>
<li>A small $p$-value indicates that such a large value of the test statistic is unlikely to occur under $\mathcal{H}_0$</li>
<li>So, a small $p$-value provides evidence against $\mathcal{H}_0$</li>
<li>If the $p$-value is sufficiently small, then we will want to <code>reject</code> $\mathcal{H}_0$</li>
<li>But <strong>how small is small enough?</strong> To answer this, we need to understand the <code>Type 1 Error</code></li>
</ul>
<h2 id="4-decide-whether-to-reject-null-hypothesis-part-2">4. Decide Whether to Reject Null Hypothesis, Part 2</h2>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/8363796d-cd6f-4c3e-98b6-203ecfac4ebe/image.png" alt=""></p>
<ul>
<li>The <code>Type 1 Error rate</code> is the probability of making a <code>Type 1 Error</code></li>
<li>We want to ensure a small <code>Type 1 Error rate</code></li>
<li>If we reject $\mathcal{H}_0$ when the p-value is less then $\alpha$, then the <code>Type 1 Error rate</code> will be at most $\alpha$</li>
<li>So, we reject $\mathcal{H}_0$ when the p-value falls below some $\alpha$ : often we choose $\alpha$ to equal $0.05$ or $0.01$</li>
</ul>
<h1 id="multiple-testing">Multiple Testing</h1>
<ul>
<li>Now suppose that we wish to test $m$ <code>null hypotheses</code>, $H_{01},\dots,H_{0m}$</li>
<li>Can we simply reject all <code>null hypotheses</code> for which the corresponding $p$-value falls below $0.01?$</li>
<li>If we reject all null hypotheses for which the $p$-value falls below $0.01$, then how many <code>Type 1 Error</code> will be make?</li>
</ul>
<h2 id="a-thought-experiment">A Thought Experiment</h2>
<ul>
<li>Suppose that we flip a fair coin ten times, and we wish to test<blockquote>
<p>$\mathcal{H}_0:\text{the coin is fair}$</p>
</blockquote>
<ul>
<li>We&#39;ll probably get approximately the same number of heads and tails</li>
<li>The $p$-value probably won&#39;t be small. We do not reject $\mathcal{H}_0$</li>
</ul>
</li>
<li>But what if we flip $1,024$ fair coins ten times each?<ul>
<li>We&#39;d except one coin (on average) to come up all tails</li>
<li>The $p$-values for the <code>null hypothesis</code> that this particular coin is fair is less than $0.002$!</li>
<li>So we would conclude it is not fair, i.e. we <code>reject null hypothesis</code>, even though it&#39;s a fair coin</li>
</ul>
</li>
<li>If we test a lot of hypotheses, we are almost certain to get one very small $p$-value by chance</li>
</ul>
<h2 id="the-challenge-of-multiple-testing">The Challenge of Multiple Testing</h2>
<ul>
<li>Suppose we test $H_{01},\dots,H_{0m}$, all of which are true, and reject any <code>null hypothesis</code> with a $p$-value below $0.01$</li>
<li>Then we except to falsely reject approximately $0.01\times m$ <code>null hypotheses</code></li>
<li>If $m=10,000$, then we expect to falsely reject $100$ <code>null hypotheses</code> by chance!<blockquote>
<p><strong>That&#39;s a lot of Type 1 Errors, i.e. false positives</strong></p>
</blockquote>
</li>
</ul>
<h2 id="the-family-wise-error-rate">The Family-Wise Error Rate</h2>
<ul>
<li>The <code>family-wise error rate</code> (FWER) is the probability of making <code>at least one</code> Type 1 error when conducting $m$ hypothesis tests</li>
<li>$\text{FWER=}\Pr(V\geq1)$
<img src="https://velog.velcdn.com/images/kbc-1315/post/819be71c-87ac-44ad-a03c-e75134290be9/image.png" alt=""></li>
</ul>
<h2 id="challenges-in-controlloing-the-fwer">Challenges in Controlloing the FWER</h2>
<p>$$
\text{FWER}=1-\Pr(\text{do not falsely reject any null hypotheses})
$$</p>
<ul>
<li>If the tests are <code>independent</code> and all $H_{0j}$ are true then
$$
\text{FWER} = 1-\prod^m_{j=1}(1-\alpha)=1-(1-\alpha)^m
$$
<img src="https://velog.velcdn.com/images/kbc-1315/post/f2272562-a89d-4263-8395-946fb2f1c151/image.png" alt=""></li>
</ul>
<h2 id="the-bonferroni-correction">The Bonferroni Correction</h2>
<p>$$
\text{FWER} = \Pr(\text{falsely reject at least one null hypothesis)}\leq\sum^m_{j=1}\Pr(A_j)
$$</p>
<ul>
<li>Where $A_j$ is the event that we <code>falsely reject</code> the $j$th <code>null hypothesis</code></li>
<li>If we only reject hypotheses when the $p$-value is less than $\alpha/m$, then
$$
\text{FWER}\leq\sum^m_{j=1}\Pr(A_j)\leq\sum^m_{j=1}\frac{\alpha}{m}=m\times\frac{\alpha}{m}=\alpha
$$</li>
<li>This is the <code>Bonferroni Correction</code> : to control <code>FWER</code> at level $\alpha$, reject any <code>null hypothesis</code> with $p$-value below $\alpha/m$</li>
</ul>
<h2 id="holms-method-for-controlling-the-fwer">Holm&#39;s Method for Controlling the FWER</h2>
<ol>
<li>Compute $p$-values, $p_1,\dots,p_m$ for the $m$ <code>null hypotheses</code> $H_{01},\dots,H_{0m}$</li>
<li>Order the $m$ $p$-values so that $p_{(1)}\leq p_{(2)}\leq\cdots\leq p_{(m)}$</li>
<li>Define
$$
L=\min\left{j:p_{(j)}&gt;\frac{\alpha}{m+1-j}\right}
$$</li>
<li>Reject all <code>null hypoteses</code> $H_{0j}$ for which $p_j&lt;p_{(L)}$<ul>
<li>Holm&#39;s method controls the <code>FWER</code> at level $\alpha$ </li>
</ul>
</li>
</ol>
<h2 id="holms-method-on-the-fund-manager-data">Holm&#39;s Method on the Fund Manager Data</h2>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/bdc1f076-2a68-4976-a206-836d093bb424/image.png" alt=""></p>
<ul>
<li>The ordered $p$-values are $p_{(1)}=0.006,;p_{(2)}=0.012,;p_{(3)}=0.601,;p_{(4)}=0.756,;p_{(5)}=0.918$</li>
<li>The <code>Holm procedure</code> rejects the first two <code>null hypotheses</code>, because
$$
p_{(1)}=0.006&lt;0.05/(5+1-1)=0.0100\[0.2cm]
p_{(2)}=0.012&lt;0.05/(5+1-2)=0.0125\[0.2cm]
p_{(3)}=0.601&gt;0.05/(5+1-3)=0.0167
$$</li>
<li><code>Holm</code> rejects $\mathcal{H}_0$ for the <code>first</code> and <code>third</code> managers, but <code>Bonferroni</code> only rejects $\mathcal{H}_0$ for the <code>first</code> manager</li>
</ul>
<h2 id="comparison-with-m10-p-values">Comparison with m=10 p-values</h2>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/f9d6398c-0d60-4e1d-88b3-4a90a6cfd00e/image.png" alt=""></p>
<ul>
<li>Aim to control <code>FWER</code> at $0.05$</li>
<li>$p$-values below the balck horizontal line are rejected by <code>Bonferroni</code></li>
<li>$p$-values below the blue line are rejected by <code>Holm</code></li>
<li><code>Holm</code> and <code>Bonferroni</code> make the same conclusion on the black points, but only <code>Holm</code> rejects for the red point</li>
</ul>
<h2 id="a-more-extreme-example">A More Extreme Example</h2>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/06611762-3e78-42bd-b60e-7b5330fccc0a/image.png" alt=""></p>
<ul>
<li>Now five hypotheses are rejected by <code>Holm</code> but not by <code>Bonferroni</code> ...</li>
<li>even though both control <code>FWER</code> at $0.05$</li>
</ul>
<h1 id="holm-or-bonferroni">Holm or Bonferroni?</h1>
<ul>
<li><code>Bonferroni</code> is simple : reject any <code>null hypothesis</code> with a $p$-value below $\alpha/m$</li>
<li><code>Holm</code> is slightly more complicated, but it will lead to more rejections while controlling <code>FWER</code><blockquote>
<p>So, <code>Holm</code> is a better choice</p>
</blockquote>
</li>
</ul>
<h1 id="the-false-discovery-rate">The False Discovery Rate</h1>
<ul>
<li>Back to this table :
<img src="https://velog.velcdn.com/images/kbc-1315/post/23d9d087-b59d-41a6-8ca0-5dbcacebfd7b/image.png" alt=""></li>
<li>The <code>FWER</code> rate focuses on controlling $\Pr(V&gt;1)$, i.e., the probability of falsely rejecting <code>any</code> null hypothesis</li>
<li>This is a tough ask when $m$ is large. It will cause us to be super conservative(i.e. to very rarely reject)</li>
<li>Instead, we can control the <code>false discovery rate</code>
$$
\text{FDR}=E(V/R)
$$</li>
</ul>
<h1 id="intuition-behind-the--false-discovery-rate">Intuition Behind the  False Discovery Rate</h1>
<p>$$
\text{FDR}=E(V/R)=E\left(\frac{\text{number of false rejections}}{\text{total number of rejections}}\right)
$$</p>
<ul>
<li>A scientist conducts a hypothesis test on each of $m=20,000$ drug candidates</li>
<li>She wants to identify a smaller set of promising candidates to investigate further</li>
<li>She wants reassurance that this smaller set is really <code>promising</code>, i.e. not too many falsely rejected $\mathcal{H}_0$&#39;s</li>
<li><code>FWER</code> controls $\Pr(\text{at least one false rejection})$</li>
<li><code>FDR</code> controls the fraction of candidates in the smaller set that are really false rejections.</li>
</ul>
<h2 id="benjamini-hochberg-procedure-to-control-fdr">Benjamini-Hochberg Procedure to Control FDR</h2>
<ol>
<li>Specify $q$, the level at which to control the <code>FDR</code></li>
<li>Compute $p$-values $p_1,\dots,p_m$ for the <code>null hypotheses</code> $H_{01},\dots,H_{0m}$</li>
<li>Order the $p$-values so that $p_{(1)}\leq\dots\leq p_{(m)}$</li>
<li>Define $L=\max\left{j:p_{(j)}&lt;qj/m\right}$</li>
<li>Reject all null hypotheses $H_{0j}$ for which $p_j\leq p_{(L)}$
Then, <code>FDR</code> $\leq$ $q$</li>
</ol>
<h1 id="a-comparison-of-fdr-vs-fwer">A Comparison of FDR vs FWER</h1>
<p><img src="https://velog.velcdn.com/images/kbc-1315/post/20f9e0b5-c734-4768-b835-84ccd7a2b98b/image.png" alt=""></p>
<ul>
<li>Here, $p$-values for $m=2,000$ <code>null hypotheses</code> are displayed</li>
<li>To control <code>FWER</code> at level $\alpha=0.1$ with <code>Bonferroni</code> : reject hypotheses below green line</li>
<li>To control <code>FDR</code> at level $q=0.1$ with <code>Benjamini-Hochberg</code> : reject hypothese shown in blue</li>
</ul>
<hr>
<ul>
<li>Consider $m=5$ p-values from the Fund data :
$p_1=0.006,;p_2=0.918,;p_3=0.012,;p_4=0.601,;p_5=0.756$</li>
<li>To control <code>FDR</code> at level $q=0.05$ using <code>Benjamini-Hochberg</code> :<ul>
<li>Notice that $p_{(1)} &lt;0.05/5,;p_{(2)}&lt;2\times0.05/5,;p_{(5)}&gt;5\times0.05/5$</li>
<li>So, we reject $H_{01}$ and $H_{03}$</li>
</ul>
</li>
<li>To control <code>FWER</code> at level $\alpha=0.05$ using <code>Bonferroni</code> :<ul>
<li>We reject any <code>null hypothesis</code> for which the $p$-value is less than $0.05/5$</li>
<li>So, we reject only $H_{01}$</li>
</ul>
</li>
</ul>
<h1 id="re-sampling-approaches">Re-Sampling Approaches</h1>
<ul>
<li>So far, we have assumed that we want to test some <code>null hypothesis</code> $\mathcal{H}_0$ with some test statistic $T$, and that we know the distribution of $T$ under $\mathcal{H}_0$</li>
<li>This allows us to compute the $p$-value
<img src="https://velog.velcdn.com/images/kbc-1315/post/7a22087d-138a-4a6c-83a5-d6ba809e2f67/image.png" alt=""></li>
<li>What if this <strong>theoretical null distribution</strong> is unknown?</li>
</ul>
<h2 id="a-re-sampling-approach-for-a-two-sample-t-test">A Re-Sampling Approach for a Two-Sample t-Test</h2>
<ul>
<li>Suppose we want to test $H_0:E(X)=E(Y)$ versus $H_\alpha :E(X)\neq E(Y)$, using $n_X$ independent observations from $X$ and $n_Y$ independent observations from $Y$</li>
<li>The two-sample $t$-statistic takes the form
$$
T=\frac{\hat \mu_X-\hat \mu_Y}{s\sqrt{1/n_X+1/n_Y}}
$$</li>
<li>If $n_X$ and $n_Y$ are large, then $T$ approximately follows a $\mathcal{N}(0,1)$ distribution under $\mathcal{H}_0$</li>
<li>If $n_X$ and $n_Y$ are small, then we don&#39;t know the theorectical null distribution of $T$</li>
<li>Let&#39;s take a <code>permutation</code> or <code>re-sampling</code> approach...</li>
</ul>
<ol>
<li>Compute the two-sample $t$-statistic $T$ on the original data $x_1,\dots,x_{n_X}$ and $y_1,\dots,y_{n_Y}$</li>
<li>For $b=1,\dots,B$(where $B$ is a large number, like $1,000$) :
2.1. <code>Randomly shuffle</code> the $n_X+n_Y$ observations
2.2. Call the first $n_X$ shuffled observations $x^<em>_1,\dots,x^</em><em>{n_X}$ and call the remaining observations $y^<em>_1,\dots,y^</em></em>{n_Y}$
2.3. Compute a two-sample $t$-statistic on the shuffled data, and call it $T^{*b}$</li>
<li>The $p$-value is given by
$$
\frac{\sum^B_{b=1} 1_{(|T^{*b}|)\geq|T|}}{B}
$$
<img src="https://velog.velcdn.com/images/kbc-1315/post/0906295d-b8b7-45fc-909f-12a69538e931/image.png" alt=""></li>
</ol>
<ul>
<li>Theoretical $p$-value is $0.041$. Re-sampling $p$-value is $0.042$
<img src="https://velog.velcdn.com/images/kbc-1315/post/b28c0082-a391-429f-8840-9c22b0c33a4d/image.png" alt=""></li>
<li>Theoretical $p$-value is $0.571$. Re-sampling $p$-value is $0.673$</li>
</ul>
<h2 id="more-on-re-sampling-approaches">More on Re-Sampling Approaches</h2>
<ul>
<li><code>Re-sampling</code> approaches are useful if the theoretical <code>null distribution</code> is unavailable, or requires stringent assumptions</li>
<li>An extension of the re-sampling approach to compute a $p$-value can be used to control <code>FDR</code></li>
<li>This example involved a two-sample $t$-test, but similar approaches can be developed for other test statistics</li>
</ul>
<p><a href="https://sundong.kim/">All Contents written based on GIST - Machine Learning &amp; Deep Learning Lesson(Instructor : Prof. sun-dong. Kim)</a></p>
]]></description>
        </item>
    </channel>
</rss>