<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by SEO, Wonyoung on Medium]]></title>
        <description><![CDATA[Stories by SEO, Wonyoung on Medium]]></description>
        <link>https://medium.com/@wonyoungseo?source=rss-ddc589776fb8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*WipgWbz7hUBBi3ue6v0PJA.jpeg</url>
            <title>Stories by SEO, Wonyoung on Medium</title>
            <link>https://medium.com/@wonyoungseo?source=rss-ddc589776fb8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 23:42:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@wonyoungseo/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[[KR] Udacity Nanodegree: Machine Learning DevOps Engineer 후기]]></title>
            <link>https://wonyoungseo.medium.com/kr-udacity-nanodegree-machine-learning-devops-engineer-%ED%9B%84%EA%B8%B0-e31f423b24fe?source=rss-ddc589776fb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/e31f423b24fe</guid>
            <category><![CDATA[유다시티]]></category>
            <category><![CDATA[udacity]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[후기]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[SEO, Wonyoung]]></dc:creator>
            <pubDate>Tue, 09 Aug 2022 10:23:11 GMT</pubDate>
            <atom:updated>2022-08-09T10:23:11.382Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cARdThz82GavE40o.png" /><figcaption>출처: Udacity</figcaption></figure><p>Udacity의 MLOps 관련 강의인 Machine Learning DevOps Engineer Nanodegree를 최근에 수료했다. 수강료 할인과 좋은 기회가 있어 수강하기 시작했는데, 중간에 사정이 있어 잠시 수강을 멈췄다가 최근에야 프로젝트를 완료하면서 수료할 수 있게 되었다. MLOps에 관심이 많은 분들은 해당 강의에 대해 궁금하실 것 같아, 강의 컨텐츠와 후기를 정리해보고자 한다.</p><h3>강의 컨텐츠</h3><p>이 강의는 MLOps에 대한 기초를 다루고 있는 만큼, 파이썬은 물론이고 데이터사이언스와 머신러닝 프로젝트에서 자주 사용하는 라이브러리인 Pandas, Numpy, Scikit-Learn 등이 익숙한 사람들을 대상으로 한다.</p><h3>1. Clean Code Principle</h3><p><strong>핵심 내용</strong></p><ul><li>지속가능한 머신러닝 프로젝트와 협업을 고려한 클린 코딩 방법론</li><li>로그 남기기 (logging)</li><li>테스트 코드 작성</li></ul><p><strong>사용하는 라이브러리, 패키지, 툴, 서비스</strong></p><ul><li>AutoPEP8, PyLint, Pytest</li></ul><p><strong>프로젝트 내용</strong></p><ul><li>간단한 Random Forest 모델을 학습하며 logging 패키지를 사용해 로그를 남기고 테스트코드 작성하기</li></ul><h3>2. Building a Reproducible Model Workflow</h3><p><strong>핵심 내용</strong></p><ul><li>MLflow 를 활용해 각 머신러닝 프로젝트의 각 태스크를 파이프라인으로 연결하기</li><li>EDA</li><li>데이터 검증</li><li>모델 개선을 위한 실험 수행</li><li>최종 모델 선택 및 추론 수행</li><li>각 태스크 실행 시 Hydra를 활용한 config 관리</li><li>Weights &amp; Biases (W&amp;B)를 통해 각 모델링 실험 기록 남기고, 관련 artifact 저장하기</li></ul><p><strong>사용하는 라이브러리, 패키지, 툴, 서비스</strong></p><ul><li>Conda, MLflow, Weights &amp; Biases, Hydra</li></ul><p><strong>프로젝트 내용</strong></p><ul><li>Airbnb 데이터셋을 기반으로 렌트 가격 예측하는 ML 프로젝트</li><li>머신러닝 파이프라인을 구성하여 효과적으로 실험을 반복수행하고, 각 실험 결과를 기록 및 저장하는 것이 핵심</li></ul><h3>3. Deploying a Scalable ML Pipeline in Production</h3><p><em>개인적으로는 3장 “Deploying a Scalable ML Pipeline in Production”의 내용이 가장 유익하고, 프로젝트도 난이도가 있었다. </em><em>모델 전처리(+데이터 버저닝) -&gt; 학습(+모델 버저닝) -&gt; API 구축 -&gt; 모델, API 테스트 -&gt; 통합-&gt; 배포 의 큰 사이클을 경험해볼 수 있다.</em></p><p><strong>핵심 내용</strong></p><ul><li>데이터와 모델 버저닝에 대한 개념 소개</li><li>머신러닝 모델 서빙의 개념. RestAPI 소개</li><li>모델의 성능과 편향을 확인하는 기법 중 하나인 Data sclicing 소개</li></ul><p><strong>사용하는 라이브러리, 패키지, 툴, 서비스</strong></p><ul><li>FastAPI, DVC, Github Actions, AWS S3, Heroku</li></ul><p><strong>프로젝트 내용</strong></p><ul><li>인구통계 데이터셋을 통해 개인의 소득 수준을 예측하는 ML 프로젝트</li><li>API 구축</li><li>각기 다른 버전의 데이터셋과 모델의 기록하고 저장하기</li><li>Heroku에 배포하기</li><li>Github Actions를 통해 CI/CD 수행하기</li></ul><h3>4. ML Model Scoring and Monitoring</h3><p><strong>핵심 내용</strong></p><ul><li>데이터의 변화로 인해 발생하는 모델 드리프트(Model drift)에 대한 개념 소개</li><li>지속적인 모델 성능 평가 방법론</li><li>모델 성능 변화에 대한 분석 및 대처방법</li></ul><p><strong>사용하는 라이브러리, 패키지, 툴, 서비스</strong></p><ul><li>Scikit-learn, Seaborn, Crontab, Flask</li></ul><p><strong>프로젝트 내용</strong></p><ul><li>기존의 모델이 학습하지 못한 새로운 데이터에 대한 모델의 모니터링과 성능 평가, 재학습을 하나의 파이프라인으로 구성</li><li>주기적으로 수행할 수 있도록 스케쥴링 설정</li></ul><h3>장점</h3><p>MLOps에 대한 best practice가 정립되지 않은 현재 상태에서 Machine Learning DevOps Engineer Nanodegree는 아주 좋은 입문 강의가 될 수 있다.</p><p>특히 여러가지 도구들을 프로젝트를 통해 찍먹해볼 수 있고, 실제 업무에서 어떤 용도로 사용할 수 있는지 힌트를 얻을 수 있다는 점이 긍정적인 부분이다. 특히 클린코드에 대한 중요성을 강의 도입부에서 강조하고, 반복적인 실험 과정들을 자동화 할 수 있는 방법을 소개하는 부분은 “혼자 고군분투 하는 데이터사이언티스트, 리서쳐” 분들에게 큰 도움이 될 것 같다.</p><h3>단점</h3><p>각 주제들이 각기 다른 강사들에 의해 구성되었기 때문에, 일관성이 다소 (아니 많이) 떨어진다. 예를 들어 3장 “머신러닝 모델 배포” 주제를 담당하는 강사는 서빙 프레임워크로 FastAPI를 다루지만, 4장 “머신러닝 모델 운영 모니터링”의 주제를 다루는 강사는 Flask를 사용한다.</p><p>각 주제들의 컨텐츠가 하나의 통일된 프레임워크와 도구를 쓰면서 유기적으로 구성되었다면 훨씬 완성도 있는 강의가 되지 않았을까? 각기 다른 회사와 단체에서 섭외한 4명의 강사들이 강의를 짜집기했다는 인상을 지울 수 없다.</p><h3>마무리하며</h3><p>앞서 강의 짜집기를 단점으로 꼽았으나, 그럼에도 불구하고 현재 시중에 있는 “다양한 오픈소스 도구 사용 방법” 정도에 머물러 있는 MLOps 강의들 비교했을 때는 가장 완성도가 있다고 평가할 수 있다.</p><p>강의 소개에서 권장하는 수강 기간은 약 4개월이지만, 수강생의 수준에 따라 더 빠른 수료도 가능할 것 같다. Nanodegree의 수강료(3개월 선불 시 120만원대)는 다소 부담이 될 수 있으나, 짧은 시간 안에 집중해서 수료을 목표를 목표로 한다면 월결제를 하는 것이 더 이득이고, 학생 신분일 경우 큰 폭의 할인도 받을 수 있으니 추천한다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e31f423b24fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[KR] Streamlit 앱 정말 쉽게 배포하기 (ft. Streamlit Sharing)]]></title>
            <link>https://wonyoungseo.medium.com/kr-streamlit-%EC%95%B1-%EC%A0%95%EB%A7%90-%EC%89%BD%EA%B2%8C-%EB%B0%B0%ED%8F%AC%ED%95%98%EA%B8%B0-ft-streamlit-sharing-1b87e43afcc9?source=rss-ddc589776fb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b87e43afcc9</guid>
            <category><![CDATA[streamlit]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[streamlit-app-deployment]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[web-applications]]></category>
            <dc:creator><![CDATA[SEO, Wonyoung]]></dc:creator>
            <pubDate>Sat, 09 Oct 2021 12:39:13 GMT</pubDate>
            <atom:updated>2021-10-12T05:22:06.097Z</atom:updated>
            <content:encoded><![CDATA[<p>Streamlit은 파이썬 기반으로 웹어플리케이션을 개발할 수 있는 프레임워크입니다. 이번 포스팅에서는 Streamlit에서 제공하는 서비스를 통해 아주 쉽고 간단하게 내가 개발한 웹을 배포하는 방법에 대해 소개하고자 합니다.</p><h4>웹 어플리케이션 개발 … 그 다음에는?</h4><p>웹개발과 다소 거리가 먼 데이터분석가, 데이터 사이언티스트 분들에게 Streamlit은 분석 결과를 공유하거나, 학습한 모델을 제품으로 프로토타이핑 할 수 있는 아주 강력한 도구로 자리 잡았습니다.</p><p>하지만 나 혼자만 보고 사용하면 무슨 소용일까요…? (도발적인 멘트) 배포를 해야 다른 사람들도 볼 수 있겠죠?</p><p>배포라는 주제는 웹어플리케이션 개발과 별개로 또하나의 장벽으로 느껴질 수 있는데요, Streamlit Sharing 은 Streamlit 어플리케이션을 배포하기 위해 알아야 할 모든 지식과 과정을 극도로 간소화 했습니다. (이 정도로 간소화가 아닌 삭제라고 봐도 무방합니다.)</p><h3>Streamlit Sharing</h3><p>Streamlit Sharing은 Streamlit에서 자체적으로 제공하는 Streamlit 어플리케이션 배포, 관리 및 공유 플랫폼입니다.</p><p>기본적으로 무료 계정의 경우 3개의 어플리케이션까지 배포할 수 있고, public 레포지토리(Github)만 배포가 가능합니다. 또한 하나의 어플리케이션 당 프로비저닝 되는 리소스는 RAM 1GB로 제한됩니다. (그외 소규모 팀단위 플랜과 엔터프라이즈 플랜이 옵션으로 있습니다. 더 자세한 사항은 <a href="https://streamlit.io/cloud">링크 </a>를 참고해주세요)</p><p>Streamlit Sharing에서 웹어플리케이션을 배포하는 과정은 정말정말 단순하고 간단합니다.</p><ol><li>Streamlit Sharing에 가입하고 Github 계정을 연동</li></ol><p>2. 배포하고자 하는 Streamlit 어플리케이션을 설정</p><p>2.1. Github의 repo를 선택</p><p>2.2. 브랜치를 선택</p><p>2.3. 실행하고자 하는 어플리케이션 파일을 선택(app.py)</p><p>3. 어플리케이션을 수정할 경우에는 선택한 브랜치에 git push 만 하면 변경된 사항이 반영</p><p>(참쉽죠1)</p><p>그러면 각 단계를 하나씩 훑어보도록 하겠습니다.</p><h3>1. 가입 및 Github 계정 연동</h3><ol><li><a href="https://share.streamlit.io/">https://share.streamlit.io/</a>에서 Sign in 합니다.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OQjPZggBId49X26R.png" /></figure><p>2. 오른쪽 상단 Settings를 클릭 후 “Sign in with Github”을 통해 Github 계정을 연동합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4gvlzb3tm23WXpNI.png" /></figure><h3>2. Github 레포지토리 연결</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CIkJXInGu2ImhPfa.png" /></figure><p>New app에서 배포하고자 하는 Streamlit 어플리케이션의 Github 레포지토리를 연결합니다.</p><h4>2.1. 레포지토리, 브랜치, 앱파일 선택</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EXo0UO8QVztmdbC1.png" /></figure><p>이번 예제에서 사용할 레포지토리 streamlit_app_stockprice_downloader의 파일 구조는 아래와 같습니다.( <a href="https://github.com/lucaseo/streamlit_app_stockprice_downloader">링크</a>)</p><pre>. <br>├── README.md <br>├── app.py <br>├── prepare_data.py <br>├── requirements.txt <br>├── resource <br>│   ├── stock_list.json <br>│   └── stock_market.json <br>└── utils     <br>    ├── __init__.py     <br>    ├── utils.py     <br>    └── utils_fdr.py</pre><p>아래와 같이 레포지토리와 브랜치, 그리고 실행하고자 하는 파일을 선택합니다.</p><h4>2.2. (Optional) 파이썬 버전, 환경변수 설정하기</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sefUzl4wkTXfduXk.png" /></figure><p>Advanced Settings 를 통해 파이썬의 버전을 선택할 수 있고, 인증이나 DB 관련 민감한 정보를 TOML 포맷으로 하여 환경변수로 설정할 수 있습니다.</p><h4>2.3. 배포하기</h4><p>Deploy 버튼을 클릭하면, Streamlit Sharing에서 자동으로 어플리케이션을 위한 리소스를 할당하고, 연동된 Github 레포지토리 내 requirments.txt에서 정의된 라이브러리를 설치한 후, Streamlit 어플리케이션을 실행시킵니다. (참쉽죠2)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R1uDSaiBu6_vpuVc.png" /></figure><p>예제에서 실행된 웹어플리케이션의 <a href="https://share.streamlit.io/lucaseo/streamlit_app_stockprice_downloader/main/app.py">링크</a> 에서 보실 수 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DplL6KmRTrze8IiP.png" /></figure><h3>3. 배포 후, 재배포</h3><p>어플리케이션을 수정할 경우에는 별다른 과정 없이, 그저 처음에 설정한 브랜치에 git push 만 하면 Streamlit Sharing에서는 continous deployment를 할 수 있습니다. (참쉽죠3)</p><h3>4. 마무리하며</h3><p>Streamlit Sharing이라는 플랫폼을 통해 간단히 Streamlit 기반 웹어플리케이션을 배포하는 과정에 대해 알아보았습니다.</p><p>한 가지 아쉬운 점은 어플리케이션의 규모나 ML모델의 사이즈가 다소 큰 상황일 경우에는 실행하고자 하는 앱에 따라 무료 플랜의 1GB RAM의 리소스가 제한적일 수 있다는 것 입니다.(마찬가지로 Heroku도 기본 무료 플랜은 500MB RAM의 리소스로 제한되어 있습니다)</p><p>따라서 다음 포스팅에서는 Streamlit Sharing이나 Heroku 같은 PaaS가 아닌, 메이저 클라우드 플랫폼에서 웹어플리케이션의 배포와 CI/CD를 하는 과정을 다루어보도록 하겠습니다.</p><h3>코드</h3><ul><li><a href="https://github.com/lucaseo/streamlit_app_stockprice_downloader">Stock price info downloader</a></li></ul><h3>Reference</h3><ul><li><a href="https://blog.streamlit.io/introducing-streamlit-sharing/">Introducing Streamlit Sharing</a></li></ul><p><em>Originally published at </em><a href="https://lucaseo.github.io/posts/2021-10-09-intro-streamlit-sharing/"><em>https://lucaseo.github.io</em></a><em> on October 9, 2021.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b87e43afcc9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[KR] fastpages에서 블로그 시작하기]]></title>
            <link>https://wonyoungseo.medium.com/kr-fastpages%EC%97%90%EC%84%9C-%EB%B8%94%EB%A1%9C%EA%B7%B8-%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0-c8af4a015cf2?source=rss-ddc589776fb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8af4a015cf2</guid>
            <category><![CDATA[fastai]]></category>
            <category><![CDATA[blog]]></category>
            <category><![CDATA[jupyter-notebook]]></category>
            <category><![CDATA[fastpages]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[SEO, Wonyoung]]></dc:creator>
            <pubDate>Sun, 29 Nov 2020 06:00:00 GMT</pubDate>
            <atom:updated>2021-02-26T02:59:27.746Z</atom:updated>
            <content:encoded><![CDATA[<h3>항상 내 맘 같지 않은 기술 블로그</h3><p>개발이 비교적 익숙하지 않은 데이터분석가 또는 데이터사이언티스트가 Github Pages를 활용하여 기술블로그를 운영하기 위해서는 몇 가지 난관이 있습니다. 자료를 찾아보면 주로 Jekyll, Hugo, Hexo, Gatsby.JS 와 같이 낯설고 어려운 프레임워크을 사용해야 합니다. 튜토리얼은 간신히 따라갔다 하더라도, 기존의 테마를 내 입맛에 맞게 커스터마이징을 하거나 기능을 추가하기 위해서는 html, CSS 또는 NodeJS 같은 프레임워크를 알아야 합니다. 마음에 드는 테마가 있어도, 오랜 기간 관리가 되지 않아 Latex 엔진이 제대로 작동하지 않는 경우가 생기기도 하죠. 번거로웠던 적이 많았습니다. 그냥 조용히 다른 쉬운 플랫폼을 선택할 걸 하는 후회가 드는 순간도 있었습니다. 진짜 많은거 바라지 않으니, 가장 심플하게 기본만 딱 하는 테마는 없을까 찾아보기도 했구요. 이러한 와중에 fastpages를 접하게 되었습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5aEfUDtvttYkuWNP.png" /></figure><h3>이번에는 fastpages</h3><h4>장점</h4><p>fast.ai 에서 개발한 fastpages는 Jekyll을 기반으로 하는 툴입니다. 제가 생각하는 fastpages의 장점은 다음과 같습니다.</p><ul><li>디자인이 군더더기 없이 깔끔하다. 부족한 것도 없지만 더 덧붙일 것도 없다. 따라서 코드를 수정할 필요가 없다.</li><li>Latex, Syntax highlighting 모두 깔끔하다.</li><li>Altair, Plotly 와 같은 interactive visualization도 embedd 할 수 있다.</li><li>html을 쓰지 않아도 된다.</li><li>기존의 방식과 같이 markdown(.md) 파일로 블로그 포스트를 작성할 수 있다.</li><li>jupyter notebook(.ipynb) 파일까지도 <strong>그대로</strong> 블로그 포스트로 변환해준다. (!!!!!)</li><li>아마 많이 사용할 일은 없겠지만, word 파일까지도 가능하다고 한다.</li><li>다른 프레임워크 기반 명령어가 따로 필요 없이, 그저 add, commit, push 명령어만으로 포스트를 간편하게 업데이트할 수 있다. 나머지는 Github Action을 배포과정 알아서 진행하기 때문.</li></ul><h4>단점</h4><p>단점은 … 아직까지는 없습니다. 단지, {github username}.github.io 형태의 주소는 지원하지 않고, {github username}.github.io/{user가 생성한 fastpages 블로그 레포지토리 이름} 을 통해서만 블로그가 생성된다는 점이 한계인 것 같네요.</p><h3>그럼 한번 만들어봅시다</h3><h4>1. fastpages 블로그용 레포지토리 생성하기.</h4><ul><li><a href="https://github.com/fastai/fastpages">fastpages 공식 레포지토리</a>에서 Use this template 버튼을 클릭하고 새로운 레포지토리를 생성합니다. 이때, 레포의 이름은 아무것이나 정해되 상관 없되, {계정명}.github.io는 피해야 합니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DdbOaZduc2pXlg7z.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Se22Chb9U8WKcoDe.png" /></figure><ul><li>잠시 기다리면, 아래 화면처럼 “Initial Setup”이라는 새로운 Pull Request가 자동으로 생성된 것을 확인할 수 있습니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xTWo6vqhpbkcbc1k.png" /></figure><h4>2. PR 가이드 따라가기</h4><ul><li>다음 <a href="https://8gwifi.org/sshfunctions.jsp">링크</a>에서 prive key와 public 키를 생성합니다. 이때, 옵션은 RSA와 4069를 선택 후 “Generate SSH-Keys” 버튼을 클릭합니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*z1BqrQrJbfMVISW0.png" /></figure><ul><li>두번째 주어진 링크에서 새 “New repository secret” 버튼을 클릭하고, Value 입력 칸에 앞서 생성한 Private key 전체를 복사하여 붙여넣습니다. Name 입력 칸에는 “SSH_DEPLOY_KEY”라고 입력하고 저장합니다.</li><li>세번째 링크에서는 “Add deploy key” 버튼을 클릭하고, 앞서 생성한 Public key를 복사하여 붙여넣습니다. 이름은 아무렇게나 지정해도 된다고 합니다. 그리고 제일 아래 “Allow write access” 박스를 꼭 체크합니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EAwQNTDrrUxEcIKW.png" /></figure><ul><li>마지막으로 PR을 merge합니다. 이후 fastpages 블로그가 배포되는 과정은 Github actions에서 아래와 같이 확인할 수 있습니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wDwSj69x6Gyp-OQo.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6RkpNdt9YbTBc6kN.png" /></figure><ul><li>완료되면, {github username}.github.io/{레포지토리 이름} 에서 fastpages 기반의 블로그가 배포되었음을 확인할 수 있습니다!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pwtSqKKOQTjyAGFn.png" /></figure><h3>이것만 알아도 블로깅 문제 없다!</h3><p>fastpages를 통해서 블로그를 작성하기 위해서는 다음 파일들에 대해서 알아두어야 합니다. (나머지는 저도 아직 잘 몰라요. 몰라도 크게 상관 없더라구요 …)</p><ul><li>_config.yml: 블로그의 이름, Latex사용 여부, 미리보기 여부, 태그 보여주기 여부 등을 설정할 수 있는 파일입니다. 자신의 SNS계정 버튼도 추가할 수 있고, description, pagination의 갯수 등의 사항들도 설정할 수 있습니다</li><li>index.html: 블로그 메인 페이지에 보여지는 컨텐츠를 작성하는 파일입니다. 저는 아무것도 입력하지 않았기에 디폴트로 작성되어 있던 fastpages 소개 텍스트를 삭제했습니다.</li><li>_pages/about.md: 블로그의 자기소개 페이지 About페이지의 내용을 작성하는 파일입니다. markdown 포맷으로 작성하면 됩니다.</li><li>포스트를 저장하는 디렉토리는 다음 종류에 따라 달라지므로 디렉토리를 구분해서 작성하시면 됩니다. (_notebooks/ , _posts/ , _word/ , images/ )</li></ul><p><strong>주의!</strong> 포스트를 작성할 때는 notebook, markdown, word 파일 포맷에 상관 없이 무조건 YYYY-mm-dd-{아무 이름} 형태로 작성되어야 fastpages가 이를 인식하고 파일을 html로 변환합니다.</p><h3>블로그 로컬에서 확인하기</h3><p>배포 또는 포스트 최종 업로드 전, 내가 작성한 포스트가 블로그에 잘 보여지는 지 확인하고 싶을 때가 있습니다. 이때는 make server 명령어를 칩니다. localhost:4000 에서 블로그가 생성되었음을 확인할 수 있습니다. (단, docker가 작동 중에 있을 때만 가능합니다.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UmafxeiVRJRe8bXt.png" /></figure><h3>마무리하며</h3><p>기술 블로그를 초반에 시작했을 때는 정말 의욕은 많이 앞섰지만, 늘 “이 디자인은 마음에 들지 않아, 이건 이런 기능이 없어, 이건 계속 오류가 생겨”와 같은 쓸데 없는 생각들이 불쑥불쑥 튀어나왔던 것 같습니다. 하지만, 이번 기회에 fastpages가 아주 깔끔하면서도 만족스러워 다짜고짜 블로그를 바꿔버렸습니다. 이제 과거에 작성했던 글들도 슬슬 옮겨놔야할 것 같네요! 새로운 술은 새 포대에 담으라고 했던가요? 새로운 블로그를 만들었으니 글도 술술 써지기를 기대해봅니다!</p><h3>Reference</h3><ul><li><a href="https://github.com/fastai/fastpages">https://github.com/fastai/fastpages</a></li></ul><p>본 글은 제 <a href="https://lucaseo.github.io/">기술 블로그</a>에 포스팅한 글을 옮긴 것입니다. 더욱 다양한 주제와 포스트는 <a href="https://lucaseo.github.io/"><em>https://lucaseo.github.io/</em></a> 를 방문해주세요 !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8af4a015cf2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[KR] Streamlit 웹 어플리케이션 배포하기 (feat. Heroku)]]></title>
            <link>https://wonyoungseo.medium.com/kr-streamlit-%EC%9B%B9-%EC%96%B4%ED%94%8C%EB%A6%AC%EC%BC%80%EC%9D%B4%EC%85%98-%EB%B0%B0%ED%8F%AC%ED%95%98%EA%B8%B0-feat-heroku-40619e933d5a?source=rss-ddc589776fb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/40619e933d5a</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[streamlit]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[web-app-development]]></category>
            <dc:creator><![CDATA[SEO, Wonyoung]]></dc:creator>
            <pubDate>Sun, 29 Mar 2020 05:12:54 GMT</pubDate>
            <atom:updated>2021-04-17T17:56:54.680Z</atom:updated>
            <content:encoded><![CDATA[<p>이번 포스트에서는 <strong>Streamlit</strong>기반 웹 어플리케이션을 <strong>Heroku</strong> 에 배포하는 과정을 다루어 보겠습니다.</p><p>Streamlit 관련 주제의 포스팅 목록은 아래의 리스트를 참조해주세요.</p><ol><li><a href="https://wonyoungseo.medium.com/kr-%ED%8C%8C%EC%9D%B4%EC%8D%AC-%EC%9B%B9%EC%96%B4%ED%94%8C%EB%A6%AC%EC%BC%80%EC%9D%B4%EC%85%98-%EB%A7%9B%EB%B3%B4%EA%B8%B0-feat-streamlit-846937a7438d">파이썬 웹어플리케이션 맛보기 (feat. Streamlit)</a></li><li><a href="https://wonyoungseo.medium.com/kr-streamlit-%EC%9B%B9-%EC%96%B4%ED%94%8C%EB%A6%AC%EC%BC%80%EC%9D%B4%EC%85%98-%EB%B0%B0%ED%8F%AC%ED%95%98%EA%B8%B0-feat-heroku-40619e933d5a">Streamlit 웹 어플리케이션 배포하기 (feat. Heroku)</a></li><li>Streamlit 기반 데이터 QC 툴 개발기 (- -현재 작성 중- -)</li></ol><figure><img alt="Streamlit logo from streamlit.io" src="https://cdn-images-1.medium.com/max/400/0*9uuiLI4tKY-8uiIx.png" /><figcaption>Streamlit logo from streamlit.io</figcaption></figure><p><strong>Streamlit</strong>의 주요 기능을 살펴보았던 <a href="https://medium.com/@lucaseo0147/kr-%ED%8C%8C%EC%9D%B4%EC%8D%AC-%EC%9B%B9%EC%96%B4%ED%94%8C%EB%A6%AC%EC%BC%80%EC%9D%B4%EC%85%98-%EB%A7%9B%EB%B3%B4%EA%B8%B0-feat-streamlit-846937a7438d"><strong>지난 포스트(파이썬 웹어플리케이션 맛보기)</strong></a>에 이어, 이번 포스트에서는 <strong>Streamlit</strong>으로 만든 간단한 웹어플리케이션을 <strong>Heroku</strong> 에 배포하는 과정을 다루어보고자 한다.</p><h3>사전 준비사항</h3><p>들어가기에 앞서 2가지 사전 준비 사항이 있다.</p><h4>사전 준비 1: Streamlit 웹 어플리케이션</h4><p>튜토리얼을 진행하기에 앞서, <strong>Streamlit</strong>기반의 아주 아주 간단한 시각화 웹 어플리케이션을 만들어보았다. 로컬에서 작동시킨 웹 어플리케이션은 다음과 같다. 해당 어플리케이션의 코드는 <a href="https://github.com/lucaseo/streamlit-examples/blob/master/02_streamlit_deployment/app.py">링크</a> 에서 참고 가능하다.</p><ul><li>Main Page: 데이터셋에 대한 설명을 간단히 소개한다.</li><li>Raw Data: 테이블 형태의 데이터셋을 확인할 수 있다.</li><li>Confirmed Map: 1월 22일부터 현재까지 전세계의 확진자 현황을 지도로 시각화한다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3VMClqewnIBhKEbA.png" /></figure><p>(데이터셋은 Johns Hopkins CSSE의 Github에 제공된 <a href="https://github.com/CSSEGISandData/COVID-19">COVID-19 데이터</a> 를 사용하였다.)</p><h4>사전 준비 2: Heroku</h4><p><strong>Heroku</strong> 는 웹사이트나 어플리케이션을 빌드하고 배포할 수 있는 PaaS이다. 파이썬, 자바, 루비, PHP, Node.js, Go 등 여러 언어를 지원하고 있다. 소규모 어플리케이션이라면 무료로도 배포할 수 있다.</p><h4>Heroku 가입</h4><p>Heroku를 통해 배포를 하기 위해서는 우선 계정이 있어야 한다. 아래 링크를 통해 <strong>Heroku</strong> 계정을 생성하자.</p><ul><li><a href="https://www.heroku.com/">https://www.heroku.com/</a></li></ul><h4>Heroku CLI 설치</h4><p>계정을 생성하였다면, 현재 개발 환경에 Heroku Command Line Interface를 설치한다. 아래의 링크에는 각자의 OS에 맞추어 Heroku CLI의 설치 가이드가 제공되어 있다.</p><ul><li><a href="https://devcenter.heroku.com/articles/getting-started-with-python#set-up">https://devcenter.heroku.com/articles/getting-started-with-python#set-up</a></li></ul><h4>CLI를 통한 로그인</h4><p>설치가 완성되었다면, 쉘에서 heroku 커맨드를 사용할 수 있다. 다음 명령어로 <strong>Heroku</strong> 에 로그인 해보자.</p><pre>$ heroku login</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*05emYdBykOarehd2.png" /></figure><p>아래와 같은 결과가 출력되며, 브라우저를 열어 로그인 하도록 한다. <strong>Heroku</strong> 에 대한 준비작업은 이로서 완료되었다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KxxGrscnYC-BKZ5D.png" /></figure><h3>배포를 위한 파일 생성하기</h3><p><strong>Heroku</strong> 에 배포를 하기 위해서는 몇 가지 준비사항이 충족되어야 한다.</p><ol><li>app.py가 위치한 가상환경에서 git init 명령어를 통해 Git Repository를 생성한다.</li><li>배포를 위해 필요한 파일들을 생성한다.</li></ol><h4>파일 #1. requirements.txt</h4><pre>$ pip freeze &gt; requirements.txt</pre><h4>파일 #2. .gitignore</h4><pre>venv<br>*.pyc<br>.DS_Store<br>.env</pre><h4>파일 #3. setup.sh</h4><p>setup.sh에서는 <strong>Streamlit</strong>에 대한 config.toml 파일을 생성한다.</p><pre>mkdir -p ~/.streamlit/<br> <br>echo “\<br>[server]\n\<br>headless = true\n\<br>enableCORS=false\n\<br>port = $PORT\n\<br>“ &gt; ~/.streamlit/config.toml</pre><h4>파일 #4. Procfile</h4><p>Procfile에서는 <strong>Heroku</strong> 로 하여금 웹어플리케이션을 시작시키기 위해 명령어를 순서대로 실행하도록 한다.</p><pre>web: sh setup.sh &amp;&amp; streamlit run app.py</pre><p>( Procfile에 대한 자세한 사항은 다음 <a href="https://devcenter.heroku.com/articles/preparing-a-codebase-for-heroku-deployment">링크</a> 에서 참조할 수 있다.)</p><h3>Heroku에 배포하기</h3><p>배포를 위한 파일이 모두 준비되었다면, 이제 본격적으로 <strong>Heroku</strong> 에 배포를 할 수 있게 되었다.</p><h4>1. Heroku App 생성</h4><pre>$ heroku create {your app name}</pre><p>앞서 Heroku CLI를 생성했을 때와 같은 <strong>Heroku</strong> 로그인 과정을 거쳐, Heroku App이 생성 되었다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dTFuB_GAA9XZnBEr.png" /></figure><p>생성된 App은 <strong>Heroku</strong> 사이트의 대시보드에서도 다음과 같이 확인이 가능하다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TjBVLnUu6SJ0nBsz.png" /></figure><h4>2. Heroku repository 생성 및 배포</h4><pre>$ git add . <br>$ git commit -m &#39;Init app boilerplate&#39; <br>$ git push heroku master</pre><p><strong>Heroku</strong> 는 배포를 위해 Git을 사용하므로, 방식도 같다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9QDI-IpymZpMiuUb.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9EW5jg4F7dcw5nAC.png" /></figure><p><strong>Heroku</strong> 의 프로세스 인스턴스를 1개로 제한하는 것을 권장한다. 프로세스가 많을 수록 유료가 될 수 있기 때문에, 무료인 상태에서 계속 사용하고 싶다면, 아래의 명령어를 실행시켜준다.</p><pre>$ heroku ps:scale web=1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*j7QqEQeL18YzoL4V.png" /></figure><h3>Heroku 배포 확인하기</h3><p>드디어 배포가 완료되었다! 이제 배포된 웹 어플리케이션을 <a href="https://your_app.herokuapp.com/"><strong>https://your_app.herokuapp.com</strong></a> 에서 확인할 수 있다. 본 튜토리얼을 위해 배포된 웹 어플리케이션은 <a href="https://tuto-covid19-map.herokuapp.com/"><strong>https://tuto-covid19-map.herokuapp.com/</strong></a> 에서 확인할 수 있다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5jjRGjHI2Wllb8IA.png" /></figure><h3>마무리하며</h3><p>간단한 과정을 거쳐 웹 어플리케이션을 배포까지 해보았다. <strong>AWS</strong>와 같은 클라우드에 배포하는 과정은 익숙하지 않았고, 현재 <strong>Streamlit</strong>이 자체적으로 특정 배포 방식을 권장하고 있지는 않기에, <strong>Dash</strong>(Plotly에서 개발한 웹어플리케이션 프레임워크)에서 웹어플리케이션을 <strong>Heroku</strong>에 배포하는 가이드를 적용해 보았다. 큰 어려움 없이 배포를 완료하였기에, 많은 분들도 이 과정을 참고하시어 <strong>Streamlit</strong> 을 활용한 다양한 프로젝트를 진행할 수 있으리라 생각된다.</p><h3>코드</h3><ul><li><a href="https://github.com/lucaseo/streamlit-examples/blob/master/02_streamlit_deployment/app.py">Github</a></li></ul><h3>참고자료</h3><ul><li><a href="https://dash.plotly.com/deployment">Dash 공식 페이지</a></li><li><a href="https://github.com/CSSEGISandData/COVID-19">Johns Hopkins CSSE Github Repository</a></li><li><a href="https://medium.com/analytics-vidhya/mapping-the-spread-of-coronavirus-covid-19-d7830c4282e"><em>Mapping the Spread of Coronavirus COVID-19 with python and Plotly</em> by. Babak Fard</a></li></ul><p>본 글은 제 <a href="https://lucaseo.github.io/">기술 블로그</a>에 포스팅한 글을 옮긴 것입니다. 더욱 다양한 주제와 포스트는 <a href="https://lucaseo.github.io/"><em>https://lucaseo.github.io/</em></a> 를 방문해주세요 !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40619e933d5a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[KR] 파이썬 웹어플리케이션 맛보기 (feat. Streamlit)]]></title>
            <link>https://wonyoungseo.medium.com/kr-%ED%8C%8C%EC%9D%B4%EC%8D%AC-%EC%9B%B9%EC%96%B4%ED%94%8C%EB%A6%AC%EC%BC%80%EC%9D%B4%EC%85%98-%EB%A7%9B%EB%B3%B4%EA%B8%B0-feat-streamlit-846937a7438d?source=rss-ddc589776fb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/846937a7438d</guid>
            <category><![CDATA[web-apps]]></category>
            <category><![CDATA[streamlit]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[visualization]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[SEO, Wonyoung]]></dc:creator>
            <pubDate>Fri, 13 Mar 2020 11:07:23 GMT</pubDate>
            <atom:updated>2021-04-17T17:56:49.685Z</atom:updated>
            <content:encoded><![CDATA[<p>데이터사이언스/ML 프로젝트를 간단하게 배포할 수 있는 웹어플리케이션이 관심을 받고 있습니다. 이번 포스트에서는 <strong>Streamlit</strong> 의 간단한 소개와 기본 기능들을 훑어보겠습니다.</p><p>Streamlit 관련 주제의 포스팅 목록은 아래의 리스트를 참조해주세요.</p><ol><li><a href="https://wonyoungseo.medium.com/kr-%ED%8C%8C%EC%9D%B4%EC%8D%AC-%EC%9B%B9%EC%96%B4%ED%94%8C%EB%A6%AC%EC%BC%80%EC%9D%B4%EC%85%98-%EB%A7%9B%EB%B3%B4%EA%B8%B0-feat-streamlit-846937a7438d">파이썬 웹어플리케이션 맛보기 (feat. Streamlit)</a></li><li><a href="https://wonyoungseo.medium.com/kr-streamlit-%EC%9B%B9-%EC%96%B4%ED%94%8C%EB%A6%AC%EC%BC%80%EC%9D%B4%EC%85%98-%EB%B0%B0%ED%8F%AC%ED%95%98%EA%B8%B0-feat-heroku-40619e933d5a">Streamlit 웹 어플리케이션 배포하기 (feat. Heroku)</a></li><li>Streamlit 기반 데이터 QC 툴 개발기 (- -현재 작성 중- -)</li></ol><figure><img alt="Streamlit logo from streamlit.io" src="https://cdn-images-1.medium.com/max/400/0*6VTEo_ZXNEr07TBt.png" /><figcaption>Streamlit logo from streamlit.io</figcaption></figure><p><strong>Streamlit</strong>(스트림릿)은 2019년 하반기에 갑작스레 등장한(?) 파이썬 기반의 웹어플리케이션 툴이다. Medium 플랫폼에서 <strong>Streamlit</strong> 이라는 키워드가 보이는 글이 추천되는 것을 자주 보게 되었는데, “데이터사이언스/머신러닝 프로젝트를 웹 어플리케이션에 배포”하는데 아주 편리한 툴이라는 설명이 눈길을 사로 잡았다.</p><p>나에게 있어 <strong>Streamlit</strong>나 <strong>Dash</strong> 같은 웹어플리케이션의 장점을 꼽자면;</p><p><strong>웹개발을 몰라도 된다.</strong></p><ul><li>웹개발에 대해 아는 것이 전혀 없는 나 같은 사람도 페이지를 띄울 수 있다.</li><li>주로 사내용으로 이용되기 때문에 UI/UX적인 측면에서 뛰어나지 않아도 되기 때문에 일정 수준의 미적인 요소들이 기본적으로 적용되있는 점이 매우 편리하다.</li><li>간결하고 명확한 API 덕분에 다른 웹프레임워크와 비교해서 상대적으로 진입장벽이 낮다. 일정한 수준의 결과를 내기 위해 투자하는 시간이 매우 절약된다.</li></ul><p><strong>전달력이 매우 좋다.</strong></p><p>덕분에 <strong>Streamlit</strong>은 조직 내부적으로 탐색적 데이터 분석(EDA) 결과를 공유하거나, 간단한 ML 모델을 배포하고 테스트를 하는 용도에 부합하는 툴이라고 할 수 있다. <strong>Streamlit</strong> API에서 제공하는 기능들을 간단하게 훑어보자.</p><h3>설치</h3><h3>pip를 통해 설치하기</h3><pre>$ pip install streamlit</pre><h3>실행하기</h3><pre>$ streamlit run {your app}.py</pre><pre>You can now view your Streamlit app in your browser.<br>  Local URL: http://localhost:8501<br>  Network URL: http://{your_network}:8501</pre><p><strong>Streamlit</strong>은 8501 포트에 앱이 실행된다. 일단 지금 아무 것도 없는 상황에서는 우측 상단 버튼만 있는 페이지를 볼 수 있다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/0*flyJ0jbkNNUXR07A.png" /></figure><h3>Streamlit 불러오기</h3><pre>import streamlit as st</pre><p><strong>Streamlit</strong>은 st 라는 alias로 불러온다.</p><p>소스에 변경이 생길 경우 경우 상단에 알림이 뜬다. Rerun 을 해주도록 하자.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/0*2DEm-XEicpXJ9m0p.png" /></figure><h3>텍스트 출력</h3><h3>Title, Header &amp; Subheader</h3><ul><li>Header와 Subheader를 다음과 같이 달 수 있다. 다만 Header의 경우 subheader 레벨까지만 가능하다. Title, Header, Subheader이 각각 Header, Subheader, Subsubheader인 것으로 인식하면 될 것 같다.</li></ul><pre>## Title<br>st.title(‘Streamlit Tutorial’)</pre><pre>## Header/Subheader<br>st.header(‘This is header’)<br>st.subheader(‘This is subheader’)</pre><pre>## Text<br>st.text(“Hello Streamlit! 이 글은 튜토리얼 입니다.”)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/0*5xe0qwO3YPKJpz6S.png" /></figure><h3>Markdown</h3><p><strong>Streamlit</strong>도 <strong>Dash</strong> 와 마찬가지로 Markdown을 지원한다.</p><pre>## Markdown syntax<br>st.markdown(&quot;# This is a Markdown title&quot;)<br>st.markdown(&quot;## This is a Markdown header&quot;)<br>st.markdown(&quot;### This is a Markdown subheader&quot;)<br>st.markdown(&quot;- item 1\n&quot;<br>            &quot;   - item 1.1\n&quot;<br>            &quot;   - item 1.2\n&quot;<br>            &quot;- item 2\n&quot;<br>            &quot;- item 3&quot;)<br>st.markdown(&quot;1. item 1\n&quot;<br>            &quot;   1. item 1.1\n&quot;<br>            &quot;   2. item 1.2\n&quot;<br>            &quot;2. item 2\n&quot;<br>            &quot;3. item 3&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*G41m1afvTyzMFf1o.png" /></figure><h3>Latex</h3><p>Latex의 경우 백슬래시(\)를 빈번히 사용되기 때문에, 일반 string 대신 raw string을 붙여주는 편이 좋다.</p><pre>## Latex<br>st.latex(r”Y = \alpha + \beta X_i”)</pre><pre>## Latex-inline<br>st.markdown(r”회귀분석에서 잔차식은 다음과 같습니다 $e_i = y_i — \hat{y}_i$”)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KKtzMwnmYPUeRyiL.png" /></figure><h3>메세지와 에러메세지, 예외처리 메세지</h3><p>기본적으로 포맷된 메세지 박스 기능을 제공한다.</p><pre>## Error/message text<br>st.success(“Successful”)<br>st.info(“Information!”)<br>st.warning(“This is a warning”)<br>st.error(“This is an error!”)<br>st.exception(“NameError(‘Error name is not defined’)”)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8ZLY0SuR8v3DTOn8.png" /></figure><h3>데이터프레임과 테이블 출력.</h3><p>데이터를 출력하는 방법에는 3가지 방법이 있다.</p><ul><li>st.table: 입력 테이블 전체를 리턴한다.</li><li>st.dataframe: 적절히 10개의 행을 기준으로 스크롤을 통해 데이터를 관찰 할 수 있고 각 열마다 정렬도 가능하다. 각 테이블의 우측 상단의 확대 버튼을 통해 테이블을 더 크게 볼 수 있고,</li><li>st.write:st.datafrmae과 똑같은 결과를 리턴한다.</li></ul><pre>## Load data<br>import pandas as pd<br>from sklearn.datasets import load_iris<br>iris = load_iris()<br>iris_df = pd.DataFrame(iris.data, columns=iris.feature_names)<br>iris_df[&#39;target&#39;] = iris[&#39;target&#39;]<br>iris_df[&#39;target&#39;] = iris_df[&#39;target&#39;].apply(lambda x: &#39;setosa&#39; if x == 0 else (&#39;versicolor&#39; if x == 1 else &#39;virginica&#39;))<br><br>## Return table/dataframe<br># table<br>st.table(iris_df.head())<br><br># dataframe<br>st.dataframe(iris_df)<br>st.write(iris_df)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mrHuJD_mrjj6zofm.png" /></figure><h3>이미지, 오디오, 비디오 파일 출력.</h3><p>이미지, 영상, 오디오 파일을 열어서 재생할 수 있다.</p><ul><li>st.image : 파이썬 이미지 라이브러리와 함께 쓸 수 있다.</li><li>st.video : 파일의 포맷을 지정해야 하며, 디폴트로는 video/mp4가 설정되어 있다.start_time 변수를 통해 재생시작점을 조절할 수 있다.</li><li>st.audio : 파일 포맷은 audio/wav 가 디폴트로 설정되어 있다.마찬가지로 start_time 변수를 통해 재생시작점을 조절할 수 있다.</li></ul><pre>##Show image<br>from PIL import Image<br>img = Image.open(“files/example_cat.jpeg”)<br>st.image(img, width=400, caption=”Image example: Cat”)</pre><pre>## Show videos<br>vid_file = open(“files/example_vid_cat.mp4”, “rb”).read()<br>st.video(vid_file, start_time=2)</pre><pre>## Play audio file.<br>audio_file = open(“files/loop_w_bass.mp3”, “rb”).read()<br>st.audio(audio_file, format=’audio/mp3&#39;, start_time=10)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-NZDTOG-AooBQHiO.png" /></figure><h3>위젯</h3><h3>st.checkbox - 체크박스</h3><pre>## Checkbox<br>if st.checkbox(“Show/Hide”):<br> st.write(“체크박스가 선택되었습니다.”)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2Rbps0YEef5oYhda.png" /></figure><h3>st.radio - 라디오버튼</h3><pre>## Radio button<br>status = st.radio(&quot;Select status.&quot;, (&quot;Active&quot;, &quot;Inactive&quot;))<br>if status == &quot;Active&quot;:<br>    st.success(&quot;활성화 되었습니다.&quot;)<br>else:<br>    st.warning(&quot;비활성화 되었습니다.&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*riiKMIBOrdDIUrtp.png" /></figure><h3>st.selectbox - 드랍다운 선택</h3><pre>## Select Box<br>occupation = st.selectbox(“직군을 선택하세요.”,<br> [“Backend Developer”,<br> “Frontend Developer”,<br> “ML Engineer”,<br> “Data Engineer”,<br> “Database Administrator”,<br> “Data Scientist”,<br> “Data Analyst”,<br> “Security Engineer”])<br>st.write(“당신의 직군은 “, occupation, “ 입니다.”)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PcLbUHy1Atn34QIl.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*k3zZRaJ4n5j6udMr.png" /></figure><h3>st.multiselect - 드랍다운 다중 선택</h3><pre>## MultiSelect<br>location = st.multiselect(&quot;선호하는 유투브 채널을 선택하세요.&quot;,<br>                          (&quot;운동&quot;, &quot;IT기기&quot;, &quot;브이로그&quot;,<br>                           &quot;먹방&quot;, &quot;반려동물&quot;, &quot;맛집 리뷰&quot;))<br>st.write(len(location), &quot;가지를 선택했습니다.&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cA2v9GWr6YcESmsz.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JLQykUP5EriFwBjt.png" /></figure><h3>st.slider - 슬라이더</h3><pre>## Slider<br>level = st.slider(&quot;레벨을 선택하세요.&quot;, 1, 5)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MrC9l23H-becHbdX.png" /></figure><h3>st.button - 버튼</h3><pre>## Buttons<br>if st.button(“About”):<br> st.text(“Streamlit을 이용한 튜토리얼입니다.”)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7NvefEc3Gbutnzdn.png" /></figure><h3>텍스트 입력</h3><pre># Text Input<br>first_name = st.text_input(&quot;Enter Your First Name&quot;, &quot;Type Here ...&quot;)<br>if st.button(&quot;Submit&quot;, key=&#39;first_name&#39;):<br>    result = first_name.title()<br>    st.success(result)<br><br><br># Text Area<br>message = st.text_area(&quot;메세지를 입력하세요.&quot;, &quot;Type Here ...&quot;)<br>if st.button(&quot;Submit&quot;, key=&#39;message&#39;):<br>    result = message.title()<br>    st.success(result)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ciqusZqaLHhaniBi.png" /></figure><h3>날짜와 시간 입력</h3><pre>## Date Input<br>import datetime<br>today = st.date_input(&quot;날짜를 선택하세요.&quot;, datetime.datetime.now())<br>the_time = st.time_input(&quot;시간을 입력하세요.&quot;, datetime.time())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BQEuQL9BoIZs5Ook.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dij1OgOwAWCE00vj.png" /></figure><h3>코드와 JSON 출력</h3><p>with st.echo(): 이하의 코드는 코드블럭으로 출력된다.</p><pre>## Display Raw Code — one line<br>st.subheader(“Display one-line code”)<br>st.code(“import numpy as np”)</pre><pre># Display Raw Code — snippet<br>st.subheader(“Display code snippet”)<br>with st.echo():<br> # 여기서부터 아래의 코드를 출력합니다.<br> import pandas as pd<br> df = pd.DataFrame()</pre><pre>## Display JSON<br>st.subheader(“Display JSON”)<br>st.json({‘name’ : ‘민수’, ‘gender’:’male’, ‘Age’: 29})</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xYAguSfkavqgMWTX.png" /></figure><h3>사이드바</h3><p>st.sidebar에서도 대부분의 위젯을 지원하므로, 다양하게 사이드바를 구성할 수 있다. (단, st.echo, st.spinner, st.write제외)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y5dtLT3xD4kktaOq.png" /></figure><h3>차트 그리기</h3><p><strong>Streamlit</strong>은 자체 내장된 기본적인 차트 외 matplotlib, plot.ly, altair, vega_ilte, bokeh, deck_gl, pydeck, graph_viz 등 다양한 시각화 패키지를 지원한다.</p><p>(<strong>Streamlit</strong>은 EDA 용도로 많이 사용되는 만큼, 시각화 부분은 따로 다룰 계획이다.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zIviKf5oPr4ORIba.png" /></figure><h3>마무리</h3><p><strong>Streamlit</strong>의 API를 훑어보면서, 전체적으로 많은 부분이 간결하고, 쉽다고 느껴졌다. Flask나 Django로 개발하는 개발자 입장에서 <strong>Streamlit</strong> 같은 프레임워크는 자유도가 제한된다고 느껴질 수도 있겠다. 하지만 등장한지 얼마 안 되는 만큼 커뮤니티 포럼에서는 활발한 토론과 기능 추가에 대한 요청이 이어지고 있는 중이다. <strong>Streamlit</strong> 개발자들이 적극적으로 피드백을 반영하는 모습을 보이고 있으므로, 앞으로의 발전이 더 기대된다.</p><p>이번 소개 글에 이어, 개인적으로 <strong>Streamlit</strong> 으로 개발하면서 얻은 팁이나, 클라우드 또는 Heroku에 배포하는 과정, 데이터사이언스 프로젝트를 위해 웹어플리케이션을 구성하는 팁 등을 시리즈로 작성할 예정이다. 나처럼 웹개발은 모르지만 데이터분석 결과를 그럴 듯하게 구성하고 싶은 분들께 도움이 되었으면 한다.</p><h3>코드</h3><p><a href="https://github.com/lucaseo/streamlit-examples/blob/master/01_intro_to_streamlit/app.py">Github</a></p><h3>Reference</h3><p><a href="https://www.streamlit.io/">Streamlit 공식 페이지</a></p><p>본 글은 제 <a href="https://lucaseo.github.io/">기술 블로그</a>에 포스팅한 글을 옮긴 것입니다. 더욱 다양한 주제와 포스트는 <a href="https://lucaseo.github.io/"><em>https://lucaseo.github.io/</em></a> 를 방문해주세요 !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=846937a7438d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[KR] Pandas 1.0.0 Major Release ! 바뀐 점을 알아봅시다]]></title>
            <link>https://wonyoungseo.medium.com/kr-pandas-1-0-0-major-release-%EB%B0%94%EB%80%90-%EC%A0%90%EC%9D%84-%EC%95%8C%EC%95%84%EB%B4%85%EC%8B%9C%EB%8B%A4-8fe13a9d4fa1?source=rss-ddc589776fb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/8fe13a9d4fa1</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pandas]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[SEO, Wonyoung]]></dc:creator>
            <pubDate>Sun, 26 Jan 2020 05:28:48 GMT</pubDate>
            <atom:updated>2021-02-26T02:59:45.483Z</atom:updated>
            <content:encoded><![CDATA[<h3>[KR] Pandas 1.0.0 Major Release ! 바뀐 점을 알아봅시다</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*K2Y5D2-sWIhCyed5wLpGUw.jpeg" /><figcaption>Pandas major release. Now it’s giant.</figcaption></figure><p>import pandas as pd로 우리에게 익숙한 Pandas. 데이터 분석을 위한 라이브러리라는 사실을 모르는 사람은 거의 없을 것입니다. 하지만 부끄럽게도 저는 판다스의 버전조차 모른 상태로 여태껏 공식 문서와 Stackoverflow를 통해서만 사용하고 있었는데요. 마침 1월 9일 Pandas 1.0.0이 배포되었고, 이번 기회에 1.0.0에서 평소 자주 썼던 부분들을 위주로 중요한 업데이트들을 훑어보고 정리해보고자 합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*uzPFMuJTzAzFzkbmCJrF2w.png" /><figcaption>Pandas logo from <a href="https://github.com/pandas-dev/pandas">https://github.com/pandas-dev/pandas</a></figcaption></figure><h4>dataframe.info() 깔끔해진 DataFrame summary</h4><p>DataFrame 요약 기능이 조금 보기 좋은 형태로 개선되었습니다.</p><p>다음과 같은 예제 DataFrame이 있다고 할 때,</p><pre>df = pd.DataFrame({<br> ‘A’: [1,2,3], <br> ‘B’: [“goodbye”, “cruel”, “world”], <br> ‘C’: [False, True, False]<br>})</pre><pre>df.info()</pre><p><strong>결과물 출력 비교</strong></p><p>pandas 0.x.x</p><pre>&lt;class ‘pandas.core.frame.DataFrame’&gt;<br>RangeIndex: 3 entries, 0 to 2<br>Data columns (total 3 columns):<br>A 3 non-null int64<br>B 3 non-null object<br>C 3 non-null bool<br>dtypes: bool(1), int64(1), object(1)<br>memory usage: 179.0+ bytes</pre><p>pandas 1.0.0</p><pre><br>df.info()<br>&lt;class ‘pandas.core.frame.DataFrame’&gt;<br>RangeIndex: 3 entries, 0 to 2<br>Data columns (total 3 columns):<br> # Column Non-Null Count Dtype<br> — — — — — — — — — — — — — — -<br> 0 A 3 non-null int64<br> 1 B 3 non-null object<br> 2 C 3 non-null object<br>dtypes: int64(1), object(2)<br>memory usage: 200.0+ bytes</pre><h4>.to_markdown() : DataFrame을 Markdown 형식으로</h4><p>DataFrame을 바로 Markdown 형식으로 출력할 수 있게 되었습니다. 문서화 작업을 할 때 항상 markdown table generator 같은 도구를 썼었는데, 매우 반갑고 편리한 기능이네요!</p><pre>df = pd.DataFrame({“A”: [1, 2, 3], “B”: [1, 2, 3]}, index=[‘a’, ‘a’, ‘b’])</pre><pre>print(df.to_markdown())</pre><p><strong>결과물 출력</strong></p><pre>| | A | B |<br>|: — -| — — :| — — :|<br>| a | 1 | 1 |<br>| a | 2 | 2 |<br>| b | 3 | 3 |</pre><h4>ignore_index: index reset 파라미터 추가</h4><p>기존에는 정렬이나 중복값 제거 후 .reset_index(drop=True)를 추가적으로 해줘야 했으나, ignore_index 파라미터를 통해 index를 리셋할 수 있게 되었습니다. default 설정은 False. index reset은 다음 기능들에서 찾아볼 수 있습니다.</p><ul><li>.sort_values()</li><li>.sort_index()</li><li>.drop_duplicates</li></ul><h4>pd.NA : 새로운 missing value의 실험</h4><p>기존에 Pandas에서 missing value를 처리할 때는 np.nan이나 None이라는 싱글턴이 사용되었습니다. 그러나 data type이 float일 때는 np.nan, object일 경우에는 np.nan이나 None, datetime일 경우에는 np.NaT가 사용되었죠. 데이터타입마다 Null 데이터의 표현이 각기 달랐기 때문에, pd.NA는 datatype이 각기 달라도 missing data를 통일되게 표현할 수 있기 위해 도입되었습니다. 현재는 pd.NA는 data type 중 integer, boolean, 그리고 새로 도입된 string에서 사용 가능합니다. pd.NA 값은 &lt;NA&lt;로 리턴됩니다. 실험적으로 도입했다고 하니, 지켜보면 좋을 듯 합니다.</p><h4>string : 새로운 data type 도입</h4><p>기존에는 object 이라는 data type으로 뭉뚱그려진 느낌이 있었으나, string 이라고 Z따로 지정할 수 있게 됨으로서 EDA나 wrangling 측면에서 더욱 편해질 것 같네요. (pd.NA도 확인 가능합니다)</p><pre>pd.Series([‘abc’, None, ‘def’], dtype=pd.StringDtype())<br><br><br>0 abc<br>1 &lt;NA&gt;<br>2 def<br>Length: 3, dtype: string</pre><h4>bool : missing value 표현 가능</h4><p>기존에 boolean은 True / False 만 표기가 가능했으나, Pandas 1.0.0 에서는 missing value도 가능합니다. (pd.NA도 가능!)</p><pre>pd.Series([True, False, None], dtype=pd.BooleanDtype())<br><br>0 True<br>1 False<br>2 &lt;NA&gt;<br>Length: 3, dtype: boolean</pre><h4>글을 마치며</h4><p>이 밖에도 Major release를 통해 업데이트 된 사항이 아주 많다고 합니다. 이번 글에서는 자주 쓰는 기능, 편리할 것이라 예상되는 기능 위주로 소개를 드렸지만, 더 궁금한 사항이 있으신 경우 아래의 공식 문서를 통해 찾아보시는 것을 추천 드립니다.</p><h3>Reference</h3><ul><li><a href="https://pandas.pydata.org/pandas-docs/version/1.0.0/whatsnew/v1.0.0.html">https://pandas.pydata.org/pandas-docs/version/1.0.0/whatsnew/v1.0.0.html</a></li></ul><p>본 글은 제 <a href="https://lucaseo.github.io/">기술 블로그</a>에 포스팅한 글을 옮긴 것입니다. 더욱 다양한 주제와 포스트는 <a href="https://lucaseo.github.io/"><em>https://lucaseo.github.io/</em></a> 를 방문해주세요 !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8fe13a9d4fa1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>