<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.2">Jekyll</generator><link href="https://jhmins.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://jhmins.github.io/" rel="alternate" type="text/html" /><updated>2023-01-01T06:25:57+00:00</updated><id>https://jhmins.github.io/feed.xml</id><title type="html">JH_MINS</title><subtitle>Develop, Study and Programing</subtitle><entry><title type="html">InterviewBit 회원가입 문제 해결!</title><link href="https://jhmins.github.io/InterviewBit-ProblemSolve/" rel="alternate" type="text/html" title="InterviewBit 회원가입 문제 해결!" /><published>2022-12-30T00:00:00+00:00</published><updated>2022-12-30T00:00:00+00:00</updated><id>https://jhmins.github.io/InterviewBit-ProblemSolve</id><content type="html" xml:base="https://jhmins.github.io/InterviewBit-ProblemSolve/">&lt;h2 id=&quot;interviewbit-회원가입-문제&quot;&gt;InterviewBit 회원가입 문제&lt;/h2&gt;
&lt;h3 id=&quot;문제가-발생하게-된-계기&quot;&gt;문제가 발생하게 된 계기&lt;/h3&gt;
&lt;p&gt;  누구나 혼자서 공부할 때 책만 보고 주구장창 공부하는 사람은 없을 것입니다. 아주 옛날 시대면 몰라도 기술의 발전으로 인해 요즘에는 학원 및 각종 공부 사이트, 유튜브 등 공부할 수 있는 수단들이 다양해졌기 때문입니다. 저 같은 경우에는 컴퓨터 관련된 공부를 할 때에 책으로만 공부하기에는 너무 딱딱하고 설명을 못하는 경우도 많아서, 주로 책과 유튜브를 병행하는 편입니다. 그리고 관련 사이트들을 이용하여 테스트를 풀면서 제가 공부한 언어나 내용을 한 번 더 확인해보는 편입니다.&lt;/p&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/InterviewBit-SignUp/study.JPG&quot;&gt;&lt;img src=&quot;/images/InterviewBit-SignUp/study.JPG&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; 주로 공부하는데 사용하는 해외 사이트들 &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;  국내 사이트들 같은 경우에는 OKYY, DEVOCEAN, 팔만코딩경 같이 여러 개발자 커뮤니티들이 많으며 백준 알고리즘, 프로그래머스 등 관련 코딩 테스트 사이트들도 잘 활성화되어 있는 편입니다. 물론 저도 이러한 국내 개발자 커뮤니티와 코딩 테스트 사이트들을 이용하는 편이지만, 저는 주로 영어 공부도 같이 할겸 HackerRank, freeCodeCamp, LeetCode들을 이용하는 편입니다. 덤으로 데이터 공부를 위한 Kaggle, 해외 온라인 강좌 플랫폼 Coursera도 이용하지만, 이는 다음 번에 자세히 다루겠습니다.&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;
    &lt;img src=&quot;/images/InterviewBit-SignUp/interviewBit1.JPG&quot; align=&quot;center&quot; width=&quot;49%&quot; /&gt;
    &lt;img src=&quot;/images/InterviewBit-SignUp/interviewBit2.JPG&quot; align=&quot;center&quot; width=&quot;49%&quot; /&gt;
    &lt;figcaption align=&quot;center&quot;&gt; InterviewBit(왼쪽) 그리고 제공하는 면접 자료들(오른쪽) &lt;/figcaption&gt;
&lt;/p&gt;

&lt;p&gt;  어쨌거나 저는 커뮤니티를 통해 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;InterviewBit&lt;/code&gt; 사이트를 알게 되었고, InterviewBit 같은 경우에는 해외 다국적 기업들의 면접 출제 자료들이 많아 면접 대비에 좋다고 알게 되었습니다. 그래서 회원가입을 할려고 했는데 이 사이트는 휴대폰 인증이 필요하더군요? 그래서 제 휴대폰 번호를 통해 인증을 받으려고 했으나, 인증번호가 날아오지가 않더군요ㅠㅠ 그래서 이메일을 통해 고객 센터에 문의를 넣었습니다. 이메일을 넣은 뒤 4시간 뒤에 바로 메일로 답장이 왔습니다.&lt;/p&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/InterviewBit-SignUp/m1.JPG&quot;&gt;&lt;img src=&quot;/images/InterviewBit-SignUp/m1.JPG&quot; /&gt;&lt;/a&gt;
&lt;/figure&gt;

&lt;p&gt;  메일을 확인해보니 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;InterviewBit&lt;/code&gt;는 인도, 미국, 캐나다 이 3군데 나라에서만 접근 가능하고, 다른 나라들은 후에 차차 업데이트 준비중이라고 답장이 왔습니다. 지금와서 생각해보면 해외 사이트이고, 아직 국내외로 널리 알려지지 않아 사용하기 힘들수도 있다는 생각이 들지만, 그 때의 저는 기껏 찾아서 좋은 사이트를 찾았다 싶어 가입하려고 하니, 접근 불가라는… 되게 억울하고 분통한 마음을 담은 답변을 고객 센터에 보내 버리고 말았습니다 ㅎㅎ (・ω&amp;lt;) ~&lt;/p&gt;

&lt;p&gt;답변을 보낸후 한창을 멍때리다가 그냥 원래 하던곳에서나 해야지라는 생각이 들 때즘, 고객 센터에서 답장이 다시 왔습니다!&lt;/p&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/InterviewBit-SignUp/m3.JPG&quot;&gt;&lt;img src=&quot;/images/InterviewBit-SignUp/m3.JPG&quot; /&gt;&lt;/a&gt;
&lt;/figure&gt;

&lt;p&gt;  첫 번째 메일을 받은 이후, 별 기대를 갖고 있지 않았는데 메일 내용을 읽고 너무 기뻐서 그 자리에서 360도 회전 백덤블링을 하며 온갖 난리부르스를 칠 정도였습니다! 확인 작업을 넘겨준 Siddharth Taneja 다시 한번 너무 감사드립니다!&lt;/p&gt;

&lt;p&gt;  특히 해외 사이트 회원가입 도중에 문제가 발생하면 인터넷에 찾아보는 것도 좋지만, 최고의 방법은 해당 사이트 고객 센터에 직접 문의하는 것 입니다! 인터넷에 올라와 있는 글 중에서는 오래되어 새로 업데이트 된 내용들도 많기 때문에, 고객센터에 이메일을 보내보는 등의 방법으로 직접 물어보는 방법이 낫다고 생각합니다. 지금 이 글을 읽고 계시는 분들도 만약 해외 사이트 이용시 문제 발생하면 바로 용기있게 고객센터로 문의할 수 있는 분이 되시면 좋겠습니다~!&lt;/p&gt;

&lt;hr /&gt;
&lt;figure class=&quot;half&quot;&gt;
    &lt;a href=&quot;/images/InterviewBit-SignUp/scaler1.JPG&quot;&gt;&lt;img src=&quot;/images/InterviewBit-SignUp/scaler1.JPG&quot; /&gt;&lt;/a&gt;
    &lt;a href=&quot;/images/InterviewBit-SignUp/scaler2.JPG&quot;&gt;&lt;img src=&quot;/images/InterviewBit-SignUp/scaler2.JPG&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; Scaler Academy(위) 그리고 제공하는 자료들(아래) &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;+) 이 글을 쓴 이후로도 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Scaler Academy&lt;/code&gt; 라는 해외 사이트를 가입할 일이 생겼는데, 알고보니 InterviewBit가 Scaler Academy의 모회사였습니다. 그렇지만 InterviewBit 계정으로 로그인은 안 되더군요. 그래서 새로 회원가입 과정을 거치는데, 서로 비슷한 회사라 그런지 역시나 이번에도 휴대폰 인증이 되지 않았습니다. 또 고객 센터에 물어보고 기다릴 생각을 하니 너무 답답해서, 이번에는 Talkatone 앱을 이용하여 미국 가상 번호를 받고, 그 번호를 통해 인증 받았습니다.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;  이번엔 정 어쩔 수 없이 가상 번호를 통해 인증을 받았지만, 해외 사이트를 가입할 때 해외 가상 번호를 통해 인증 받는 방법도 있다는 점이 있다는 것을 알려드리고 싶네요. 아무래도 몇몇 해외 사이트는 가입할 때 개인 정보 유출 등 보안적으로 취약한 점들도 많기 때문에, 이를 막기 위한 가상 번호를 통한 가입도 한 가지 방법이 될 수 있다고 봅니다.&lt;/p&gt;
&lt;/blockquote&gt;</content><author><name></name></author><category term="Blog" /><category term="Study" /><category term="Self-Developement" /><category term="Personal Writing" /><category term="InterviewBit" /><summary type="html">InterviewBit 회원가입 시 필요한 휴대폰 인증번호 문제</summary></entry><entry><title type="html">오늘의 명언과 명화 (2022년 10월 06일 Update)</title><link href="https://jhmins.github.io/Wise-Masterpiece-35/" rel="alternate" type="text/html" title="오늘의 명언과 명화 (2022년 10월 06일 Update)" /><published>2022-03-25T00:00:00+00:00</published><updated>2022-03-25T00:00:00+00:00</updated><id>https://jhmins.github.io/Wise-Masterpiece-35</id><content type="html" xml:base="https://jhmins.github.io/Wise-Masterpiece-35/">&lt;h2 id=&quot;2022년-3월-25일금요일의-1번째-명언과-명화&quot;&gt;2022년 3월 25일(금요일)의 1번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  힘이 드는가? 하지만 오늘 걷지 않으면 내일은 뛰어야 한다. -카를레스 푸욜 &lt;br /&gt; 
  Are you tired? If you don’t walk today, you should run tomorrow. -Carles Puyol&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Jack_Spurling_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Jack_Spurling_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; Great Tea Race of 1866(Ariel and Taeping) - Jack Spurling &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-3월-26일토요일의-2번째-명언과-명화&quot;&gt;2022년 3월 26일(토요일)의 2번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  아침은 하루에 있어서 중요한 시간이다. 이유는, 당신이 아침 시간을 어떻게 보냈는지에 따라 어떤 하루를 보낼 것인지가 결정되기 때문이다. -레모니 스니켓 &lt;br /&gt; 
  Morning is an important time of day, because how you spend your morning can often tell you what kind of day you are going to have. -Lemony Snicket&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Claude_Monet_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Claude_Monet_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; Rising Tide at Pourville, 1882 - Claude Monet &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-3월-28일월요일의-3번째-명언과-명화&quot;&gt;2022년 3월 28일(월요일)의 3번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  중요한 건 당신이 “어떻게 시작했는가”가 아니라 “어떻게 끝내는가”이다. -앤드류 매튜스 &lt;br /&gt; 
  The important thing is not how you started, but how you end it. -Andrew Matthews&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Georges_Seurat_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Georges_Seurat_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; The Seine seen from La Grande Jatte, 1888 - Georges Seurat &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-3월-29일화요일의-4번째-명언과-명화&quot;&gt;2022년 3월 29일(화요일)의 4번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  최선을 다하고 있다”라고 말해봤자 소용없다. 필요한 일을 함에 있어서는 반드시 성공해야 한다. -윈스턴 처칠 &lt;br /&gt;
  It is no use saying, “We are doing our best.” You have got to succeed in doing what is necessary. -Winston Churchill&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/William_Turner_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/William_Turner_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; The Burning of the Houses of Parliament, 1835 - William Turner &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-3월-30일수요일의-5번째-명언과-명화&quot;&gt;2022년 3월 30일(수요일)의 5번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  새로운 일에 도전하다 보면 가끔 실수를 저지를 수 있다. 자신의 실수를 빨리 인정하고 다른 시도에 집중하는 것이 최선이다. -스티브 잡스 &lt;br /&gt;
  When you try a new job, you can sometimes make mistakes. It is best to admit your mistakes quickly and focus on other attempts. -Steve jobs&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/John_Constable_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/John_Constable_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; The Hay Wain, 1821 - John Constable &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-3월-31일목요일의-6번째-명언과-명화&quot;&gt;2022년 3월 31일(목요일)의 6번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  사람에게 가장 중요한 일은 실패했다고 낙심하지 않는 일이며, 성공했다고 기뻐 날뛰지 않는 일이다. -표도르 도스토옙스키 &lt;br /&gt;
  The most important thing for a person is not to be discouraged by failure, and not to be excited about success. -Fyodor Mikhailovich Dostoevskii&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Edouard_Manet_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Edouard_Manet_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; The Bar at the Folies-Bergere, 1882 - Edouard Manet &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-4월-01일금요일의-7번째-명언과-명화&quot;&gt;2022년 4월 01일(금요일)의 7번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  이기기 위해서는 한 번 이상 전쟁을 치러야 할 때도 있다. –마가렛 대처 &lt;br /&gt;
  You may have to figth a battle more than once to win it. -Margaret Thatcher&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Eugene_Galien_Laloue_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Eugene_Galien_Laloue_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; Place de Clichy - Eugene Galien Laloue &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-4월-02일토요일의-8번째-명언과-명화&quot;&gt;2022년 4월 02일(토요일)의 8번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  우리는 우리가 읽은 것으로부터 만들어진다. -마르틴 발저 &lt;br /&gt;
  We are made from what we read. -Martin Walser&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Gustave_Courbet_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Gustave_Courbet_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; Les Casseurs de pierres, 1849 - Gustave Courbet &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-4월-04일월요일의-9번째-명언과-명화&quot;&gt;2022년 4월 04일(월요일)의 9번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  인간은 인생의 방향을 결정할 규칙을 가지고 있어야 한다. -존 웨인 &lt;br /&gt;
  A man has to have a code, a way of life to live by -John Wayne&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Mikhail_Yuryevich_Kugach_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Mikhail_Yuryevich_Kugach_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; A long Way, 2014 - Mikhail Yuryevich Kugach &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-4월-06수요일의-10번째-명언과-명화&quot;&gt;2022년 4월 06(수요일)의 10번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  분노하지 말라. 분노는 지혜를 갉아먹는다. 증오하지 마라. 판단력이 흐려진다. -조조 &lt;br /&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Ma_Yuan_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Ma_Yuan_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; 답가도(踏歌图) - 마원(马远) &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-4월-07목요일의-11번째-명언과-명화&quot;&gt;2022년 4월 07(목요일)의 11번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  자기 자신을 존중하되 자만하지 말라. 자신의 능력을 키우되 과신하지 말라. -탈무드 &lt;br /&gt;
  Respect yourself, but don’t be arrogant. Build your skills, but don’t be overconfident. -Talmud&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Frederick_Arthur_Bridgman_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Frederick_Arthur_Bridgman_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; Halt In The Desert, 1922 - Frederick Arthur Bridgman &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-4월-08금요일의-12번째-명언과-명화&quot;&gt;2022년 4월 08(금요일)의 12번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  인생의 시기에 따라 목표가 다르고 전략이 다르다. -리처드 템플러 &lt;br /&gt;
  Different goals and strategies are different depending on the time of life. -Richard Templar&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Barend_Cornelis_Koekkoek_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Barend_Cornelis_Koekkoek_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; Figures on a winter road, 1849 - Barend Cornelis Koekkoek &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-4월-09토요일의-13번째-명언과-명화&quot;&gt;2022년 4월 09(토요일)의 13번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  바쁘고 안 바쁘고는 그리 중요하지 않다. 문제는 무엇을 위해 뱌쁘냐는 것이다. -헨리 데이비드 소로 &lt;br /&gt;
  Busy or not busy doesn’t really matter. The question is, what is it for. -Henry David Thoreau&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/George_Henry_Durrie_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/George_Henry_Durrie_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; Winter_Time On The Farm, (circa 1862-1863) - George Henry Durrie &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-4월-12화요일의-14번째-명언과-명화&quot;&gt;2022년 4월 12(화요일)의 14번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  사람의 성품 중에 가장 뿌리깊은 것은 교만이다. 지금 자신이 누구에게나 겸손할 수 있다고 자랑하는 것도 하나의 교만이다. 겸손을 의식하는 동안에는 아직 교만의 뿌리가 남아있는 증거이다. -필립 체스터필드 &lt;br /&gt;
  Pride is the most deeply rooted in a person’s character. It is also a form of pride to brag that you can be humble to anyone right now. As long as you are conscious of humility, it is evidence that the roots of pride still remain. -Philip Chesterfield&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Frederick_Stuart_Church_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Frederick_Stuart_Church_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; The Polar Bear Dance, 1915 - Frederick Stuart Church &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-4월-13수요일의-15번째-명언과-명화&quot;&gt;2022년 4월 13(수요일)의 15번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  두뇌는 최상의 기능을 수행하기 위해 정기적으로 도전받을 필요가 있다. -프랭크 놀 &lt;br /&gt;
  The brain needs to be regularly challenged in order to attain its uttermost performance. -Frank Knoll&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/John_Bond_Francisco_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/John_Bond_Francisco_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; Dry Dock - John Bond Francisco &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-4월-14목요일의-16번째-명언과-명화&quot;&gt;2022년 4월 14(목요일)의 16번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  정상은 내려오고 나서야 비로소 내 것이 된다. 그 전에는 진정 오른 것이 아니다. - 조지 말로리 &lt;br /&gt;
  The summit becomes mine only when it comes down. Before that, it wasn’t really up. -George Mallory&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Johannes_Tavenraat_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Johannes_Tavenraat_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; Mountain Landscape in Tirol with Chamois, 1858 - Johannes Tavenraat &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-4월-15금요일의-17번째-명언과-명화&quot;&gt;2022년 4월 15(금요일)의 17번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  모든 꽃은 피는 시기가 있다. -켄 페티 &lt;br /&gt;
  Every flower blooms in its own time. -Ken Petti&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Jules_Ferdinand_Medard_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Jules_Ferdinand_Medard_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; Roses Et Raisins - Jules Ferdinand Medard &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-4월-17일요일의-18번째-명언과-명화&quot;&gt;2022년 4월 17(일요일)의 18번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  내 자신의 무식을 아는 것은 지식으로의 첫걸음이다. -조지 고든 바이런 &lt;br /&gt;
  Knowing my own ignorance is the first step to knowledge. -George Gordon Byron&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Samuel_Halpert_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Samuel_Halpert_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; The Flatiron Building, 1919 - Samuel Halpert &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-4월-18월요일의-19번째-명언과-명화&quot;&gt;2022년 4월 18(월요일)의 19번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  겨울이 없다면 봄은 그리 즐겁지 않을 것이다. 때때로 고난을 맛보지 않으면 성공이 그리 반갑지 않을 것이다. -앤 브레드스트릿 &lt;br /&gt;
  Without winter, spring would not be so pleasant. Success will not be very welcome unless you experience hardship sometimes. -Anne Bradstreet&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Henry_Roderick_Newman_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Henry_Roderick_Newman_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; Cherry Blossom, 1898 - Henry Roderick Newman &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-4월-19화요일의-20번째-명언과-명화&quot;&gt;2022년 4월 19(화요일)의 20번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  일을 즉각 처리하는 것보다, 일을 바르게 하는 것이 낫습니다. -조지 소로스 &lt;br /&gt;
  It is better to do it right than right away. -George Soros&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Achille_Solari_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Achille_Solari_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; Grape pickers above Sorrento, Vesuvius beyond - Achille Solari &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-4월-20수요일의-21번째-명언과-명화&quot;&gt;2022년 4월 20(수요일)의 21번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  주식투자에 뛰어들려면 기꺼이 위험을 감수하겠다는 정신적 준비운동이 필요하다. 확실한 수익을 보장해주는 주식시장은 세상 어느 곳에도 없다. -앙드레 코스톨라니 &lt;br /&gt;
  To jump into stock investing, you need to be mentally prepared to take risks. There is no stock market anywhere in the world that guarantees a sure return. -Andre Kostolany&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Alfred_Friedländer_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Alfred_Friedländer_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; The Town Under Siege - Alfred Friedländer &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-4월-22금요일의-22번째-명언과-명화&quot;&gt;2022년 4월 22(금요일)의 22번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  나의 한계는 나의 포기하고 싶은 마음이 결정해버리는 것이다. 포기하지 않는 한, 그곳에 한계는 없다. -손 마사요시 &lt;br /&gt;
  My limit is determined by my desire to give up. As long as you don’t give up, there are no limits. -Masayoshi Son&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Ohara_Koson_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Ohara_Koson_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; Pheasant on cherry blossom branch, (circa 1887-1945) - Ohara Koson &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-4월-23토요일의-23번쩨-명언과-명화&quot;&gt;2022년 4월 23(토요일)의 23번쩨 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  꿈은 실현된다. 실현 가능성이 없으면 자연이 우리가 꿈을 갖도록 부추기지 않을 것이다. -존 업다이크 &lt;br /&gt;
  Dreams come true. Without realization, nature will not encourage us to dream. -John Updike&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Nakagawa_Hachiro_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Nakagawa_Hachiro_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; Cherry Blossom Festival, 1903 - Nakagawa Hachiro &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-4월-24일요일의-24번째-명언과-명화&quot;&gt;2022년 4월 24(일요일)의 24번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  행동은 모든 성공의 가장 기초적인 핵심이다. -파블로 피카소 &lt;br /&gt;
  Action is the most fundamental key to any success. -Pablo Picasso&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Ingeborg_Eggertz_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Ingeborg_Eggertz_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; Cherry Blossom - Ingeborg Eggertz &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-8월-30화요일의-25번째-명언과-명화&quot;&gt;2022년 8월 30(화요일)의 25번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  비 오는 날은 집에서 차를 마시며 좋은 책을 읽으며 보내야 한다. -빌 워터슨 &lt;br /&gt;
  Rainy days should be spent at home with a cup of tea and a good book. -Bill Watterson&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Dmitri_Danish_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Dmitri_Danish_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; Before the Rain, Saint Augustine - Dmitri Danish &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-8월-31수요일의-26번째-명언과-명화&quot;&gt;2022년 8월 31(수요일)의 26번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  성급함 때문에 당하는 큰 손해의 하나는 우습게도 무척 많은 시간이 걸린다는 것이다. -G. K. 체스터턴 &lt;br /&gt;
  One of the great Disadvantages of hurry is that it takes such a long time. -Gilbert Keith Chesterton&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Elijah_Walton_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Elijah_Walton_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; Rednal Wood, Winter - Elijah Walton &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-9월-01목요일의-27번째-명언과-명화&quot;&gt;2022년 9월 01(목요일)의 27번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  누구든지 좋은 기회가 없었던 것은 아니다. 다만 그것을 적시에 포착할 수 없었을 뿐이다. -앤드류 카네기 &lt;br /&gt;
  Everyone had a good chance, just couldn’t capture it in time. -Andrew Carnegie&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Ernest_Karl_Eugen_Koerner_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Ernest_Karl_Eugen_Koerner_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; Night view over the Bosphorus, 1874 - Ernest Karl Eugen Koerner &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-9월-19월요일의-28번째-명언과-명화-명화-1순위&quot;&gt;2022년 9월 19(월요일)의 28번째 명언과 명화 (명화 1순위)&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  한 때는 불가능하다고 생각한 것이 결국에는 가능한 것이 된다. -K. 오브라이언 &lt;br /&gt;
  What was once thought impossible eventually becomes possible. -Conan Christopher O’Brien&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Jae-Sam-Lee_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Jae-Sam-Lee_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; Moonlight 월인천강지호, 2022 - Jae Sam Lee &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-9월-20화요일의-29번째-명언과-명화&quot;&gt;2022년 9월 20(화요일)의 29번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  &lt;strong&gt;한 권의 책을 읽음으로써 자신의 삶에서 새 시대를 본 사람이 너무나 많다.&lt;/strong&gt; 책은 우리의 기적을 설명하고 새로운 기적을 드러낼 기회를 위해 존재한다. 현재 우리가 어디선가 말할 수 없는 것들을 책을 통해 발견할 수 있다. -헨리 데이비드 소로 &lt;br /&gt;
  How many a man has dated a new era in his life from the reading of a book. The book exists for us perchance which will explain our miracles and reveal new ones. The at present unutterable things we may find somewhere uttered. -Henry David Thoreau&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Jules_Coignet_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Jules_Coignet_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; View of the Sea(Boat at the Sea) - Jules Coignet &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-9월-22목요일의-30번째-명언과-명화&quot;&gt;2022년 9월 22(목요일)의 30번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  당신의 운명이 결정되는 것은 결심하는 그 순간이다. -앤서니 라빈스 &lt;br /&gt;
  It is in your moments of decision that your destiny is shaped. -Tony Robbins&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Edward_Moran_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Edward_Moran_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; Ships at Sunset(New York Harbor Sunset), (circa 1872) - Edward Moran &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-9월-23금요일의-31번째-명언과-명화&quot;&gt;2022년 9월 23(금요일)의 31번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  당신 스스로가 하지 않는다면, 아무도 당신의 운명을 개선시켜 주지 않을 것이다. -베르톨트 브레히트  &lt;br /&gt;
  No one will improve your destiny, If you don’t do it yourself. -Bertolt Brecht&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Mary_Cassatt_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Mary_Cassatt_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; In the Box, 1879 - Mary Cassatt &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-9월-26월요일의-32번째-명언과-명화&quot;&gt;2022년 9월 26(월요일)의 32번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  있는 것은 오직 목표 뿐이다. 길은 없다. 우리가 길이라고 부르는 것은 망설임에 불과하다. -카프카  &lt;br /&gt;
  There is only a goal. There is no way. What we call the way is nothing but a hesitation. -Franz Kafka&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Enrica_Giorgi_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Enrica_Giorgi_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; At the Crossroads, 1984 - Enrica Giorgi &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-10월-05수요일의-33번째-명언과-명화&quot;&gt;2022년 10월 05(수요일)의 33번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  못할 것 같은 일도 시작해 놓으면 이루어진다. -채근담 &lt;br /&gt;
  Things that you can’t do will come true if you start. -菜根譚&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Hong_Sung_Mo_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Hong_Sung_Mo_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; 사자바위와 누에섬 - 홍성모 화백 &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-10월-06목요일의-34번째-명언과-명화-명언-2순위&quot;&gt;2022년 10월 06(목요일)의 34번째 명언과 명화 (명언 2순위)&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  약한 자는 절대 누군가를 용서할 수 없다. 용서는 강한 자의 특권이다. -마하트마 간디 &lt;br /&gt;
  The weak can never forgive. Forgiveness is the attribute of the strong. -Mahatma Gandhi&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Johann_Georg_Platzer_1.jpg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Johann_Georg_Platzer_1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; Samson’s revenge, (circa 1730-1740) - Johann Georg Platzer &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2022년-10월-07금요일의-35번째-명언과-명화&quot;&gt;2022년 10월 07(금요일)의 35번째 명언과 명화&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;  겨울은 영원하지 않고, 봄은 자기 차례를 건너뛰지 않는다. -핼 볼랜드 &lt;br /&gt;
  No winter lasts forever, No spring skips its turn. -Hal Borland&lt;/p&gt;
&lt;/blockquote&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Wise-Masterpiece/Hong_Sung_Mo_2.jpeg&quot;&gt;&lt;img src=&quot;/images/Wise-Masterpiece/Hong_Sung_Mo_2.jpeg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; 개암사의 봄 - 홍성모 화백 &lt;/figcaption&gt;
&lt;/figure&gt;</content><author><name></name></author><category term="Today" /><category term="Wise saying" /><category term="Proverb" /><category term="Life quotes" /><category term="Masterpiece" /><summary type="html">나를 위한 명언과 명화 모음집 D-35</summary></entry><entry><title type="html">Automated ML을 통한 데이터 자동시각화(EDA)</title><link href="https://jhmins.github.io/Automated-ML/" rel="alternate" type="text/html" title="Automated ML을 통한 데이터 자동시각화(EDA)" /><published>2021-07-19T00:00:00+00:00</published><updated>2021-07-19T00:00:00+00:00</updated><id>https://jhmins.github.io/Automated-ML</id><content type="html" xml:base="https://jhmins.github.io/Automated-ML/">&lt;h2 id=&quot;automated-ml을-통한-데이터-자동시각화eda&quot;&gt;Automated ML을 통한 데이터 자동시각화(EDA)&lt;/h2&gt;
&lt;p&gt;  이번에는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Sweetviz&lt;/code&gt;를 사용한 간단한 데이터 자동시각화(EDA)를 해보았습니다. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Sweetviz&lt;/code&gt;는 간단한 코드 몇 줄만으로 ‘&lt;ins&gt;데이터를 빠르게 시각화하여 데이터 세트를 비교 (대상 분석, 비교, 기능 분석, 상관 관계) 하는데 중점을 두고 있는 라이브러리&lt;/ins&gt;’ 중 하나입니다. 사용할 데이터 자료는 데이터 사이언스를 공부하는 사람들은 한 번쯤은 들어봤을 Kaggle의 타이타닉 데이터셋을 사용하였습니다.&lt;/p&gt;

&lt;hr /&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sweetviz&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sv&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;pandas&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 모델을 학습시키기 위한 train 데이터를 불러옵니다.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df_train&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;read_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;train.csv&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# analyze 함수를 통해 리포트를 생성합니다.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;my_report&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;analyze&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;my_report&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;show_html&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;  위의 코드를 실행시켜보면&lt;/p&gt;

&lt;figure class=&quot;half&quot;&gt;
    &lt;a href=&quot;/images/AutomatedML/terminal1.jpg&quot;&gt;&lt;img src=&quot;/images/AutomatedML/terminal1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;a href=&quot;/images/AutomatedML/terminal2.jpg&quot;&gt;&lt;img src=&quot;/images/AutomatedML/terminal2.jpg&quot; /&gt;&lt;/a&gt;
&lt;/figure&gt;

&lt;p&gt;  몇 초만에 자동으로 데이터 분석,비교가 된 리포트가 SWEETVIZ_REPORT.html 파일로 만들어져서 나옵니다.&lt;/p&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/AutomatedML/report1.jpg&quot;&gt;&lt;img src=&quot;/images/AutomatedML/report1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; html 파일로 만들어진 리포트 &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;p&gt;  Sweetviz는 받은 데이터를 빠르게 시각화하여 간단히 훑어보기에는 좋은 라이브러리입니다. 또한, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;compare 함수&lt;/code&gt;를 사용하여 두 개의 데이터들을 비교하는 것도 가능합니다. 간단한 코드와 리포트 분석 결과 내용은 다른 EDA 라이브러리와 비교해보아도 나쁘지 않고, 괜찮은 것 같습니다. 그리고 계속 꾸준한 업데이트가 되고 있기 때문에 앞으로의 행보가 무척 기대됩니다ㅎㅎ&lt;/p&gt;</content><author><name></name></author><category term="Python" /><category term="Sweetviz" /><category term="Pandas" /><category term="Data science" /><category term="Machine Learning" /><summary type="html">Sweetviz와 Pandas를 이용한 데이터 자동시각화</summary></entry><entry><title type="html">Open CV 모양(도형) 감지</title><link href="https://jhmins.github.io/Open-CV-and-Shape-Detection/" rel="alternate" type="text/html" title="Open CV 모양(도형) 감지" /><published>2021-03-03T00:00:00+00:00</published><updated>2021-03-03T00:00:00+00:00</updated><id>https://jhmins.github.io/Open-CV-and-Shape-Detection</id><content type="html" xml:base="https://jhmins.github.io/Open-CV-and-Shape-Detection/">&lt;h2 id=&quot;open-cv-모양도형-감지&quot;&gt;Open CV 모양(도형) 감지&lt;/h2&gt;
&lt;p&gt;  이번에는 Open CV를 활용하여, 모양(도형)을 감지할 수 있도록 해보았습니다. 이번에는 실행할 main.py와는 별도로 클래스의 구현을 저장할 .py를 추가로 만들 것이기 때문에 별도의 패키지를 만들어 놓았습니다.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;:\Project
    - ShapeDetect
        --- shapedetector.py
        --- __init__.py             
    - shapes_detection.py
    - 그 외 jpg,png
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;  폴더(디렉터리) 안에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_init_.py&lt;/code&gt; 파일이 있는 이유는 있어야지 해당 폴더를 패키지로 인식하기 때문입니다. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_init_.py&lt;/code&gt;는 비워둘 수도 있고, 패키지를 초기화하는 역할도 가능합니다. (파이썬 3.3 이후로는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_init_.py&lt;/code&gt; 파일이 없어도 패키지로 인식이 가능함.) 일단 저는 먼저 클래스의 구현을 저장할 shapeDetector.py를 만들어보겠습니다.&lt;/p&gt;

&lt;hr /&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;cv2&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ShapeDetector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;pass&lt;/span&gt;

	&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;detect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;contour&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
		&lt;span class=&quot;c1&quot;&gt;# 도형 이름을 초기화하고 윤곽선을 근사화합니다.
&lt;/span&gt;		&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;unidentified&quot;&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;epsilon&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arcLength&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;contour&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;approx&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;approxPolyDP&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;contour&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;epsilon&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.04&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        
        &lt;span class=&quot;c1&quot;&gt;# 꼭짓점 3개면 그 도형은 삼각형입니다.
&lt;/span&gt;		&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;approx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Triangle&quot;&lt;/span&gt;

		&lt;span class=&quot;c1&quot;&gt;# 정점이 4개인 경우 그 도형은 정사각형 또는 직사각형입니다.
&lt;/span&gt;		&lt;span class=&quot;k&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;approx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;

			&lt;span class=&quot;c1&quot;&gt;# 윤곽선의 경계 상자를 계산하고 이를 사용하여 종횡비를 계산합니다.
&lt;/span&gt;			&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;boundingRect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;approx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;ar&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;w&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

			&lt;span class=&quot;c1&quot;&gt;# 정사각형은 대략 1과 같은 종횡비를 갖습니다. 그 외는 직사각형입니다.
&lt;/span&gt;			&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Square&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ar&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.95&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ar&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1.05&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Rectangle&quot;&lt;/span&gt;

		&lt;span class=&quot;c1&quot;&gt;# 꼭짓점 5개면 그 도형은 오각형입니다.
&lt;/span&gt;		&lt;span class=&quot;k&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;approx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Pentagon&quot;&lt;/span&gt;

		&lt;span class=&quot;c1&quot;&gt;# 그 외에는 원이라고 가정합니다.
&lt;/span&gt;		&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Circle&quot;&lt;/span&gt;

		&lt;span class=&quot;c1&quot;&gt;# 도형의 이름을 반환합니다.
&lt;/span&gt;		&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;  저는 클래스의 구현을 저장할 ShapeDetector.py를 만들었고, 저는 모양 감지를 하기 위해서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;윤곽 근사(Contour approximation)&lt;/code&gt;를 이용했습니다.&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;윤곽 근사(Contour approximation)란 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ramer-Douglas-Peucker 알고리즘&lt;/code&gt;을 이용하여 ‘지정한 정밀도에 따라 정점의 수가 적은 모양으로 윤곽 모양을 근사’ 하는 방법입니다. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;근사치 정확도 값(epsilon)&lt;/code&gt;은 입력할 다각형과 반환할 근사화된 다각형 사이 최대 편차를 고려해 다각형을 근사하는 원리입니다. 이러한 근사치 정확도의 값은 작을수록, 근사를 더욱 적게 하기 때문에 원본 윤곽과 유사해진다고 합니다.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;	&lt;span class=&quot;c1&quot;&gt;# contour는 검출한 윤곽선들이 저장되는 Numpy 배열, True는 검출한 윤곽선이 닫혀있는지, False는 열려있는지를 의미합니다.
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;epsilon&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arcLength&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;contour&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; 

	&lt;span class=&quot;c1&quot;&gt;# 저는 근사치 정확도를 위해 윤곽선 전체 길이의 4%로 활용했습니다.
&lt;/span&gt;	&lt;span class=&quot;n&quot;&gt;approx&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;approxPolyDP&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;contour&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;epsilon&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.04&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;p&gt;  이제는 본격적으로 실행할 shapes_detection.py 을 만들어보겠습니다.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;.ShapeDetect.shapedetector&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shapedetector&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;argparse&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;imutils&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;cv2&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;ap&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;argparse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ArgumentParser&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;ap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add_argument&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;-i&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;--image&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;required&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;help&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;입력하려는 이미지 경로&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;vars&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;parse_args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 도형이 더 잘 근사화될 수 있도록, 이미지를 더 작은 크기로 조정합니다.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imread&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;image&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;resized&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;imutils&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;ratio&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resized&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 사이즈 조정한 이미지를 회색조로 변환하고, 살짝 흐리게 한 다음 임계값을 설정합니다.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gray&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cvtColor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resized&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;COLOR_BGR2GRAY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;blurred&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GaussianBlur&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gray&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;thresh&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;threshold&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;blurred&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;60&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;THRESH_BINARY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 임계값(이진) 이미지에서 윤곽선을 찾고, Shapedetector를 초기화합니다.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cnts&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;findContours&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;thresh&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;copy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RETR_EXTERNAL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CHAIN_APPROX_SIMPLE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;cnts&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;imutils&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;grab_contours&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cnts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;sd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ShapeDetector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 윤곽선을 반복합니다.
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cnts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
	&lt;span class=&quot;c1&quot;&gt;# 윤곽선의 중심을 계산한 다음, 윤곽선을 사용하여 모양의 이름을 감지합니다.
&lt;/span&gt;	&lt;span class=&quot;n&quot;&gt;M&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;moments&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;cX&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;M&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;m10&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;M&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;m00&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ratio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;cY&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;M&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;m01&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;M&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;m00&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ratio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;detect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

	&lt;span class=&quot;c1&quot;&gt;# 윤곽선 (x, y)에 크기 조정 비율을 곱한 후, 윤곽선과 모양의 이름을 이미지에 그립니다.
&lt;/span&gt;	&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;astype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;float&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ratio&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;astype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;int&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;drawContours&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;putText&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;FONT_HERSHEY_SIMPLEX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
		&lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

	&lt;span class=&quot;c1&quot;&gt;# 출력할 이미지 표시
&lt;/span&gt;	&lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Image&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;waitKey&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;  이러한 영상처리를 하는 코드들을 보면 주로 전처리 과정에서 사이즈를 조절하거나, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Grayscale(그레이스케일)&lt;/code&gt; 작업과 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Gaussian blur(가우시안 블러)&lt;/code&gt; 작업을 하게 되는데, 그 이유는 보통 이미지 노이즈를 줄이고 세부 사항을 줄여 컴퓨터가 이진화 처리를 하기에 편리하기 때문입니다.&lt;/p&gt;

&lt;figure class=&quot;half&quot;&gt;
    &lt;a href=&quot;/images/ShapeDetection/sample.png&quot;&gt;&lt;img src=&quot;/images/ShapeDetection/sample.png&quot; /&gt;&lt;/a&gt;
    &lt;a href=&quot;/images/ShapeDetection/sampleout.jpg&quot;&gt;&lt;img src=&quot;/images/ShapeDetection/sampleout.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt;샘플 이미지(왼쪽)과 출력 후(오른쪽) &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;blockquote&gt;
  &lt;p&gt;Tip. 저는 영어로 출력했지만, 만약에 Open CV로 한글을 출력하고 싶으면 PIL(Python Image Library)을 사용해 한글을 출력해주면 됩니다. 그냥 하면 한글이 깨지기 때문에 한글을 출력하고 싶을 경우 꼭 사용해줘야 합니다.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;hr /&gt;

&lt;p&gt;  P.S. 위에 있는 코드대로 실행을 시키면 아래와 같은 에러가 발생하게 됩니다.&lt;br /&gt;
“ ImportError: attempted relative import with no known parent package “은 메인 모듈에서 상대경로를 사용하다가 발생하는 오류로&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;.ShapeDetect.shapedetector&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shapedetector&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;  그럴 경우에는 경로를 상대 경로에서 절대 경로로 수정해주면됩니다.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# 지금 현재 상태에서 코드를 추가해줍니다.
&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# 현재 모듈의 절대경로를 알아내어 추가하는 방식
&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sys&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;os&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;os&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dirname&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;os&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;abspath&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;__file__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 그리고 앞에 있는 . 한 개 지움
&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;ShapeDetect.shapedetector&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shapedetector&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name></name></author><category term="Python" /><category term="Open CV" /><category term="Shape recognition" /><category term="Artificial Intelligence" /><summary type="html">Open CV를 이용한 모양(도형) 감지</summary></entry><entry><title type="html">Open CV 색상 감지</title><link href="https://jhmins.github.io/Open-CV-and-Color-Detection/" rel="alternate" type="text/html" title="Open CV 색상 감지" /><published>2021-02-16T00:00:00+00:00</published><updated>2021-02-16T00:00:00+00:00</updated><id>https://jhmins.github.io/Open-CV-and-Color-Detection</id><content type="html" xml:base="https://jhmins.github.io/Open-CV-and-Color-Detection/">&lt;h2 id=&quot;open-cv-색상-감지&quot;&gt;Open CV 색상 감지&lt;/h2&gt;
&lt;p&gt;  이번에는 영상 처리 라이브러리 중 하나인 Open CV를 이용하여, 특정 지정한 색상을 감지할 수 있도록 해보았습니다.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;argparse&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;cv2&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 명령행 인수 구문 분석을 처리
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ap&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;argparse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ArgumentParser&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;ap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add_argument&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;-i&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;--image&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;help&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;입력하려는 이미지 경로&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;vars&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;parse_args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 이미지를 로드
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imread&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;image&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 색상 경계값(하한,상한)을 미리 정의해줍니다.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;boundaries&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;17&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;56&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]),&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;86&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;31&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;220&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;88&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]),&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;25&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;146&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;190&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;62&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;174&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;250&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]),&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;103&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;86&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;65&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;145&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;133&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;128&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; 
&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 경계값을 반복합니다.
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lower&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;upper&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;boundaries&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;

	&lt;span class=&quot;c1&quot;&gt;# 경계값에서 Numpy 배열을 생성합니다.
&lt;/span&gt;	&lt;span class=&quot;n&quot;&gt;lower&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lower&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dtype&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;uint8&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;upper&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;upper&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dtype&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;uint8&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

	&lt;span class=&quot;c1&quot;&gt;# 지정된 경계값 내에서 색상을 찾아 마스크 적용해줍니다.
&lt;/span&gt;	&lt;span class=&quot;n&quot;&gt;mask&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;inRange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lower&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;upper&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;output&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bitwise_and&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mask&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mask&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

	&lt;span class=&quot;c1&quot;&gt;# 이미지를 보여줍니다.
&lt;/span&gt;	&lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imshow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;images&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hstack&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]))&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;waitKey&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;작성한 코드는 대략 이렇습니다. 여기서 중요한 점은&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;  색상의 경계값을 정할 때 Open CV는 RGB 형식이 아닌 BGR 형식을 사용한다는 점입니다. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;boundaries = ([17, 15, 100], [50, 56, 200])&lt;/code&gt;은 “B&amp;gt;=17, G&amp;gt;=15, R&amp;gt;=100”에서 ~ “B&amp;lt;=50, G&amp;lt;=56, R&amp;lt;=200” 사이의 색상을 적색으로 간주하게 됩니다. 다른 색상들도 이와 마찬가지입니다.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;boundaries&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;17&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;56&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]),&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;적색&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;86&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;31&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;220&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;88&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]),&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;청색&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;25&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;146&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;190&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;62&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;174&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;250&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]),&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;노랑색&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;103&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;86&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;65&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;145&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;133&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;128&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;회색&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;blockquote&gt;
  &lt;p&gt;  또한 cv2.inRange 함수에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;첫 번째 인수는 우리가 색 감지를 수행할 이미지이고, 두 번째 인수는 탐지하려는 색상의 하한이며, 세 번째 인수는 탐지하려는 색상의 상한입니다.&lt;/code&gt;
여기서 범위에 들어가는 부분은 값 그대로, 나머지 부분은 0으로 채워져서 결과값을 반환하게 됩니다. (따라서, 우리가 지정한 범위 이외에 부분은 검은색으로 처리된후 나오게 됩니다.)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  &lt;span class=&quot;c1&quot;&gt;# 이미지에서 특정 색상만 추출하기 위한 임계값으로 사용합니다.
&lt;/span&gt;  &lt;span class=&quot;n&quot;&gt;mask&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;inRange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lower&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;upper&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;# mask와 원본 이미지를 비트 연산합니다.
&lt;/span&gt;  &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bitwise_and&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mask&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mask&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/ColorDetection/shoes.jpg&quot;&gt;&lt;img src=&quot;/images/ColorDetection/shoes.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; 넣고자 하는 하는 샘플 이미지 파일 &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;figure class=&quot;third&quot;&gt;
	&lt;a href=&quot;/images/ColorDetection/shoes_red.jpg&quot;&gt;&lt;img src=&quot;/images/ColorDetection/shoes_red.jpg&quot; /&gt;&lt;/a&gt;
	&lt;a href=&quot;/images/ColorDetection/shoes_blue.jpg&quot;&gt;&lt;img src=&quot;/images/ColorDetection/shoes_blue.jpg&quot; /&gt;&lt;/a&gt;
	&lt;a href=&quot;/images/ColorDetection/shoes_gray.jpg&quot;&gt;&lt;img src=&quot;/images/ColorDetection/shoes_gray.jpg&quot; /&gt;&lt;/a&gt;
	&lt;figcaption&gt;감지해서 나온 색상들 빨강 - 파랑 - 회색 순서대로(노랑은 실수로 빠졌네요ㅎㅎ)&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cv2.inRange&lt;/code&gt; 함수는 매우 효율적이지만, 이미지에 적용하기 위해서는 반드시 색상 경계를 알아야 한다는 단점이 있습니다. 그리고 인터넷을 통해 찾아본 결과 음영을 포함한 넓은 색상을 넣기 위해서는 HSV 색 공간을 사용하는 것이 훨씬 쉽다고 합니다. (HSV에서 고른 색상을 다시 RGB로 변환하여 경계값에 넣어 사용하시면 됩니다.)&lt;/p&gt;</content><author><name></name></author><category term="Python" /><category term="Open CV" /><category term="Numpy" /><category term="Color recognition" /><category term="Artificial Intelligence" /><summary type="html">Open CV를 이용한 지정한 색상 감지</summary></entry><entry><title type="html">Argparse 명령줄 인수와 간단한 Open CV 예제</title><link href="https://jhmins.github.io/Argparse-and-Open-CV/" rel="alternate" type="text/html" title="Argparse 명령줄 인수와 간단한 Open CV 예제" /><published>2021-02-13T00:00:00+00:00</published><updated>2021-02-13T00:00:00+00:00</updated><id>https://jhmins.github.io/Argparse-and-Open%20CV</id><content type="html" xml:base="https://jhmins.github.io/Argparse-and-Open-CV/">&lt;h2 id=&quot;argparse-명령줄-인수와-간단한-open-cv-예제&quot;&gt;Argparse 명령줄 인수와 간단한 Open CV 예제&lt;/h2&gt;
&lt;p&gt;  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Argparse&lt;/code&gt; 모듈은 Python에서 많이 사용되는 명령줄 인수 구문 중 하나로, ‘&lt;ins&gt;인자값을 입력받고 이와 관련된 간단한 도움말과 사용법 작성이 가능합니다.&lt;/ins&gt;’ 그리고 만약에 사용자가 프로그램에 잘못된 인자를 줄 때 에러를 통해 알려주는 역활도 가능합니다.&lt;/p&gt;

&lt;h3 id=&quot;argparse-간단한-설명&quot;&gt;Argparse 간단한 설명&lt;/h3&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# argparse 모듈 가져오기
&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;argparse&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# argparse.ArgumentParser() 함수를 통해 parser를 생성합니다.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ap&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;argparse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ArgumentParser&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 인수를 추가하고 인수의 조건을 설정합니다. 저는 required=True를 통해, parse_args()의 옵션에 그 명령행이 없으면 에러를 보고하도록 설정했습니다.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add_argument&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;-n&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;--name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;required&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;help&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;사용자의 이름&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# parse_args를 통해 인자 문자열을 객체로 변환하고 namespace의 어트리뷰트로 설정합니다.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;vars&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;parse_args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 그리고 출력
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;안녕하세요 {}씨, 만나서 반갑습니다.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/Argparse/sample.jpg&quot;&gt;&lt;img src=&quot;/images/Argparse/sample.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; 터미널에서 한 번 실행시켜 봅시다. &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;Argparse 모듈에 대해서 더욱 자세한 설명을 원한다면&lt;br /&gt;
&lt;a href=&quot;https://docs.python.org/ko/3/library/argparse.html&quot;&gt;https://docs.python.org/ko/3/library/argparse.html&lt;/a&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;argparse-명령줄-인수를-활용한-간단한-open-cv-예제&quot;&gt;Argparse 명령줄 인수를 활용한 간단한 Open CV 예제&lt;/h3&gt;

&lt;p&gt;  Argparse 명령줄 인수의 특성 때문에 머신러닝이나 딥러닝을 하다보면 자주 보게 됩니다. 우선은 Argparse 명령줄 인수를 이용하여 이미지 윤곽을 찾아내는 간단한 Open CV 예제를 해보았습니다.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;argparse&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;imutils&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;cv2&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 인수 구문 분석기를 구성하고 인수를 구문 분석합니다.(위에 설명 확인)
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ap&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;argparse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ArgumentParser&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;ap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add_argument&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;-i&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;--input&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;required&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;help&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;입력하려는 이미지 경로&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;ap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add_argument&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;-o&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;--output&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;required&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;help&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;출력하려는 이미지 경로&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;vars&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;parse_args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 디스크에서 입력 이미지를 로드합니다.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imread&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;input&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 이미지를 회색조, 흐리게 및 임계값을 설정
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gray&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cvtColor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;COLOR_BGR2GRAY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;blurred&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GaussianBlur&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gray&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;thresh&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;threshold&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;blurred&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;60&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;THRESH_BINARY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 이미지에서 윤곽을 추출
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cnts&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;findContours&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;thresh&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;copy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RETR_EXTERNAL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CHAIN_APPROX_SIMPLE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;cnts&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;imutils&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;grab_contours&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cnts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 윤곽선을 반복하여 입력 영상에 그립니다.
&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cnts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;drawContours&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 이미지의 총 모양 수를 표시
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;I found {} total shapes&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cnts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;putText&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;FONT_HERSHEY_SIMPLEX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 출력 이미지를 디스크에 기록
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imwrite&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;output&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;figure class=&quot;half&quot;&gt;
    &lt;a href=&quot;/images/Argparse/input1.png&quot;&gt;&lt;img src=&quot;/images/Argparse/input1.png&quot; /&gt;&lt;/a&gt;
    &lt;a href=&quot;/images/Argparse/output1.png&quot;&gt;&lt;img src=&quot;/images/Argparse/output1.png&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt;넣은 그림(왼쪽)과 나온 그림(오른쪽) &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;  이 코드는 단순히 이미지 윤곽을 추출만 하는 내용으로, 스스로 학습하는 능력이 없기 때문에 아직까지는 정확도가 많이 부족한 점이 있습니다. 이는 나중에 공부할 머신러닝, 딥러닝 등을 이용하여 겪은 경험을 통해 자동으로 개선이 가능하게 코드를 수정해보도록 하겠습니다.&lt;/p&gt;</content><author><name></name></author><category term="Python" /><category term="Open CV" /><category term="Image recognition" /><category term="Artificial Intelligence" /><summary type="html">Argparse에 대한 간략한 설명과 간단한 이미지 윤곽 인식</summary></entry><entry><title type="html">머신 러닝을 통한 로켓 발사 예측</title><link href="https://jhmins.github.io/Rocket-launch-machine-learning/" rel="alternate" type="text/html" title="머신 러닝을 통한 로켓 발사 예측" /><published>2020-11-01T00:00:00+00:00</published><updated>2020-11-01T00:00:00+00:00</updated><id>https://jhmins.github.io/Rocket-launch-machine-learning</id><content type="html" xml:base="https://jhmins.github.io/Rocket-launch-machine-learning/">&lt;h2 id=&quot;머신-러닝을-통한-로켓-발사-예측&quot;&gt;머신 러닝을 통한 로켓 발사 예측&lt;/h2&gt;
&lt;p&gt;  머신 러닝을 통한 로켓 발사 예측을 하기 위해서는 우선 파이썬(Python)과 아나콘다(Anaconda)가 설치되어 있어야 합니다. 이 둘은 데이터 과학을 쉽고 편리하게 처리하기 위한 필수 요소들 중 하나입니다.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;‘아나콘다(Anaconda)’는 여러가지 수학 및 과학 계산(데이터 과학, 기계 학습 애플리케이션, 대규모 데이터 처리, 예측 분석 등)을 포함하고 있는 패키지로 머신러닝(Machine learning)이나 데이터 분석(Data analysis)를 수월하게 처리하고자 할 때 많이 사용됩니다.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;아나콘다 다운로드 및 기초 환경 구성&lt;br /&gt;
&lt;a href=&quot;https://www.anaconda.com/products/individual&quot;&gt;https://www.anaconda.com/products/individual&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;자신의 컴퓨터 환경에 맞는 아나콘다를 설치후 Anaconda Prompt를 실행해줍니다.&lt;/p&gt;
&lt;figure class=&quot;half&quot;&gt;
    &lt;a href=&quot;/images/RocketLaunch/anaconda1.jpg&quot;&gt;&lt;img src=&quot;/images/RocketLaunch/anaconda1.jpg&quot; /&gt;&lt;/a&gt;
    &lt;a href=&quot;/images/RocketLaunch/anaconda2.jpg&quot;&gt;&lt;img src=&quot;/images/RocketLaunch/anaconda2.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt;Anaconda Prompt를 찾아서 실행&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h3 id=&quot;새로운-아나콘다-환경-구성&quot;&gt;새로운 아나콘다 환경 구성&lt;/h3&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# conda create -n myenv: 이름 'myenv'의 새로운 conda 가상환경 생성&lt;/span&gt;
conda create &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; myenv &lt;span class=&quot;nv&quot;&gt;python&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;3.7 pandas numpy jupyter seaborn scikit-learn pydotplus
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Pandas&lt;/code&gt; : 데이터를 구조화된 형식으로 가공 및 분석할 수 있도록 자료구조를 제공하는 패키지&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Numpy&lt;/code&gt; : 행렬이나 대규모 다차원 배열을 쉽게 처리 할 수 있도록 지원하여 고성능 계산이나 데이터 분석에 유용한 패키지&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Jupyter&lt;/code&gt; : 라이브 코드, 등식, 시각화와 설명을 위한 텍스트 등을 포함한 문서를 만들고 공유가 가능하며 머신러닝이나 데이터분석 용도로 많이 사용하는 오픈소스 소프트웨어&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Seaborn&lt;/code&gt; : Matplotlib 기반의 고급 인터페이스를 제공하는 Python 데이터 시각화 라이브러리&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Scikit-learn&lt;/code&gt; : 회귀(Regression), 분류(Classification), 군집화(clustering), 의사결정 트리(Decision tree) 등의 다양한 머신러닝 알고리즘을 적용할 수 있는 함수들을 제공하는 머신러닝 라이브러리&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Pydotplus&lt;/code&gt; : 그래프를 생성하는 graphviz의 dot 언어를 파이썬 인터페이스로 제공하는 모듈&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# myenv 환경 실행&lt;/span&gt;
conda activate myenv
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# AzureML-SDK 설치 및 업그레이드&lt;/span&gt;
pip &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--upgrade&lt;/span&gt; azureml-sdk
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AzureML-SDK&lt;/code&gt; :  Azure Machine Learning 작업 영역에서 기계 학습 및 딥 러닝 모델을 빌드할 수 있게 해줍니다.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# Excel 파일을 읽을 수 있는 라이브러리 설치&lt;/span&gt;
pip &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;xlrd
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Visual Studio Code 마켓플레이스에서 Python과 Azure Machine Learning 설치&lt;/p&gt;
&lt;figure class=&quot;half&quot;&gt;
    &lt;img src=&quot;/images/RocketLaunch/python.jpg&quot; /&gt;
    &lt;img src=&quot;/images/RocketLaunch/Azure.jpg&quot; /&gt;
&lt;/figure&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/RocketLaunch/same.jpg&quot;&gt;&lt;img src=&quot;/images/RocketLaunch/same.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt;오른쪽 위의 Jupyter 커널과 왼쪽 아래의 Python 인터프리터가 모두 같은 버전의 &lt;br /&gt; Anaconda 환경을 사용하고 있어야 합니다.(주황색으로 표시)&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;라이브러리-가져오기-데이터-읽기-및-호출&quot;&gt;라이브러리 가져오기, 데이터 읽기 및 호출&lt;/h3&gt;
&lt;p&gt;  라이브러리를 가져와 날씨 데이터를 가져와 정리하고, 기계 학습 모델을 만들고 테스트할 수 있도록 구성합니다.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Pandas는 표 데이터를 처리하는 데 사용
&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;pandas&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# NumPy는 수열 연산 작업을 처리하는 데 사용(덧셈, 곱셈 ...)
&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Sklearn 라이브러리는 데이터에서 패턴을 분석하고 추출하는 데 필요한 모든 머신러닝 패키지 포함
&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sklearn&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;linear_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;model_selection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;metrics&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sklearn.model_selection&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;train_test_split&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 의사 결정 트리를 작성하는 데 사용되는 머신 러닝 라이브러리
&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sklearn.tree&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;DecisionTreeClassifier&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sklearn&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tree&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 데이터를 처리하고 정리하는 데 사용되는 Sklearn 전처리 라이브러리
&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sklearn&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;preprocessing&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 트리를 시각화하기 위해 사용
&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;pydotplus&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;IPython.display&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Image&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# pd.read_excel을 통해 데이터를 읽고 변수에 저장
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;launch_data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;read_excel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'RocketLaunchDataCompleted.xlsx'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# .head() 함수를 통해 데이터의 상위 5개 행을 출력
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;launch_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# .columns 함수를 통해 데이터의 모든 열을 볼 수 있음
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;launch_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;columns&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;데이터-정리-및-조작&quot;&gt;데이터 정리 및 조작&lt;/h3&gt;
&lt;p&gt;  올바르지 않거나 엉망으로 보이는 데이터를 가져와서 값을 변경하거나 삭제하여 정리하는 역활로, 일관되지 않은 데이터를 확인하거나 데이터에 null인 많을 경우 컴퓨터가 혼동을 일으키기 때문에 이러한 작업이 필요합니다.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# .info() 함수를 통해 컬럼명, 데이터 값의 타입 등 데이터에 대한 전반적인 정보 표시
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;launch_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;  전체적으로 훑어보다보면 일부 열에 데이터가 누락되어 있어 수정이 필요한 곳이 몇 군데가 보입니다.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# 데이터가 누락되어 있는 곳을 다른 적절한 값으로 변경 
## (Excel 파일에 저장된 데이터가 아닌 launch_data 변수에 저장된 데이터를 변경)
&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# 'Launched' 열에 데이터가 누락된 곳은 누락 값을 N으로 지정
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;launch_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Launched?'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fillna&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'N'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;inplace&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# 'Crewed or Uncrewed'(유인 or 무인) 정보가 없는 행의 경우 무인으로 가정
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;launch_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Crewed or Uncrewed'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fillna&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Uncrewed'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;inplace&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# '바람 방향'이 누락되면 unknown으로 표시
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;launch_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Wind Direction'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fillna&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'unknown'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;inplace&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# '컨디션' 데이터가 누락되면 일반적인 날로 간주하고 fair를 사용
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;launch_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Condition'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fillna&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Fair'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;inplace&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# 다른 누락된 데이터의 경우에는 0 값을 사용
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;launch_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fillna&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;inplace&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 변경한 데이터의 상위 5개 행을 출력
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;launch_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;figure class=&quot;half&quot;&gt;
    &lt;a href=&quot;/images/RocketLaunch/before.jpg&quot;&gt;&lt;img src=&quot;/images/RocketLaunch/before.jpg&quot; /&gt;&lt;/a&gt;
    &lt;a href=&quot;/images/RocketLaunch/after.jpg&quot;&gt;&lt;img src=&quot;/images/RocketLaunch/after.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt;변경 전(왼쪽)과 변경 후(오른쪽) &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;누락값을 정리한 후 컴퓨터가 계산을 하기 위해서,&lt;br /&gt;
계산은 텍스트보다는 숫자 입력이 적합하므로 모든 텍스트를 숫자로 변환해줍니다.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;## 데이터 정리 과정의 일환으로 텍스트 데이터를 숫자로 변환해야 하는 이유는 컴퓨터가 숫자만 이해하기 때문
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label_encoder&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;preprocessing&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LabelEncoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 이 3개의 열에는 범주형 텍스트 정보가 있으므로, 이를 숫자로 변환해줄 필요가 있음
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;launch_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Crewed or Uncrewed'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label_encoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fit_transform&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;launch_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Crewed or Uncrewed'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;launch_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Wind Direction'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label_encoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fit_transform&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;launch_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Wind Direction'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;launch_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Condition'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label_encoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fit_transform&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;launch_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Condition'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;데이터를 한 번 살펴보고 잘 정리되었는지를 확인합니다.&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;launch_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/RocketLaunch/datatheorem.jpg&quot;&gt;&lt;img src=&quot;/images/RocketLaunch/datatheorem.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; 정리된 데이터를 보면 'Crewed or Uncrewed'와 'Condition'의 값이 숫자로 바뀌었음을 알 수 있습니다.  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;  이번에는 로켓 발사와 관련하여 필요하지 않거나 사용하지 않을 일부 열들을 제거하고, 앞으로 사용할 열들만 남겨두도록 합니다.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# 관심 있는 출력(로켓 발사 성공 여부)을 따로 저장 -&amp;gt; 출력
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;launch_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Launched?'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 관심 없는 기둥 제거
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;launch_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;drop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Name'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Date'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Time (East Coast)'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Location'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Launched?'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Hist Ave Sea Level Pressure'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Sea Level Pressure'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Day Length'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Notes'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Hist Ave Visibility'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'Hist Ave Max Wind Speed'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;axis&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;inplace&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# 그리고 나머지 데이터들은 입력 데이터로 저장 -&amp;gt; 입력
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;launch_data&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;  당연히 로켓 발사 성공 여부를 예측하기 위해서 컴퓨터는 X에 입력된 데이터를 중점으로 살펴보게 됩니다.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# 기계 학습 알고리즘이 살펴볼 변수 목록:
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;columns&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;figure class=&quot;half&quot;&gt;
    &lt;a href=&quot;/images/RocketLaunch/before2.jpg&quot;&gt;&lt;img src=&quot;/images/RocketLaunch/before2.jpg&quot; /&gt;&lt;/a&gt;
    &lt;a href=&quot;/images/RocketLaunch/after2.jpg&quot;&gt;&lt;img src=&quot;/images/RocketLaunch/after2.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt;변경 전(왼쪽)과 변경 후(오른쪽) &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;python에서-기계-학습-모델-만들기&quot;&gt;Python에서 기계 학습 모델 만들기&lt;/h3&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# 의사결정 트리 분류자 생성 (Scikit-learn 라이브러리 사용)
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tree_model&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;DecisionTreeClassifier&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random_state&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;max_depth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;  의사 결정 트리를 사용하는 이유는 쉽게 시각화할 수가 있고, 모델은 두 가지 중에서만 선택할 수 있으므로 쉽게 사용이 가능합니다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Random_state&lt;/code&gt; : 알고리즘의 임의성을 제어하는 매개변수로, 데이터를 학습시킬 데이터와 테스트할 데이터로 분할할 경우 여기에 제공된 초기값은 해당 분할의 임의성을 결정&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Max_depth&lt;/code&gt; : 모델 출력의 범위를 지정할 수 있도록 하는 트리 관련 매개 변수&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;데이터를-학습-데이터와-테스트-데이터로-분할&quot;&gt;데이터를 학습 데이터와 테스트 데이터로 분할&lt;/h3&gt;
&lt;p&gt;  데이터 세트를 분할하는 이유는 모델을 학습하고 테스트하기 위한 다양한 데이터를 확보하기 위해서입니다. 일단은 데이터를 4개의 새 변수로 분할하고자 합니다. 입력 및 출력을 나타내는 X 및 y가 이미 있으므로 이러한 데이터를 바탕으로 학습 및 테스트 데이터로 분할하도록 합니다.&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;X_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_test&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;train_test_split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;test_size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_state&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;99&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;입력 데이터 : X - 발사를 예측하는 데 사용하려는 모든 열&lt;/li&gt;
  &lt;li&gt;출력 데이터 : y - 각 행의 결과 (로켓이 발사되었는지 여부는 관계없음)&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Test_size&lt;/code&gt; : 0.2 - 데이터를 80% 학습시키고, 20% 테스트하는 것은 데이터 과학에서 일반적으로 사용되는 분할 방식임&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Random_state&lt;/code&gt; : 99 - 데이터 선택의 임의성을 변경하는 무작위 초기값&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
  &lt;p&gt;Random_state 를 지정하지 않은 경우  코드를 실행할 때마다 다른 (임의의) 분할이 발생합니다. 따라서 Random_state 를 주면  스플릿은 항상 동일하기 때문에 실험 재현성에 자주 사용됩니다.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;기계-학습-모델-데이터-맞추기-및-테스트&quot;&gt;기계 학습 모델 데이터 맞추기 및 테스트&lt;/h3&gt;
&lt;p&gt;“데이터 맞춤” 작업은 기본적으로 모델이 학습하는 단계를 말합니다.&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# 모델을 학습 데이터에 맞춤
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tree_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;데이터 맞춤 착업이 끝난다면 가져온 라이브러리를 사용하여 모델을 쉽게 테스트할 수 있습니다.&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;predict()&lt;/code&gt; 함수는 해당 모델로부터 새로운 데이터에 대한 예측값을 구하는 데 사용하는 함수로, predict() 함수에 X_test (테스트용을 예약한 입력 데이터의 20%) 를 제공합니다.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# 테스트 데이터에 대한 예측 수행
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y_pred&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tree_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;predict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y_pred&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;기계-학습-모델-점수-매기기&quot;&gt;기계 학습 모델 점수 매기기&lt;/h3&gt;
&lt;p&gt;발사가 진행될지 여부를 예측할 때의 모델의 정확도를 확인하기 위해 사용하며,&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# 정확도(Accuracy) 계산
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tree_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;score&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;score()&lt;/code&gt; 함수를 사용하여 X_test 입력 데이터 및 y_test 출력 데이터를 전달하여 모델의 “등급”을 매깁니다. 이 점수가 높을수록 모델의 정확도가 더 높아진다는 사실은 학습 데이터를 기준으로 로켓 발사의 결과를 예측할 때 적용됩니다.&lt;/p&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/RocketLaunch/accuracy.jpg&quot;&gt;&lt;img src=&quot;/images/RocketLaunch/accuracy.jpg&quot; /&gt;&lt;/a&gt;
    &lt;figcaption&gt; 모델의 정확도 약 98.3% 인 것을 알 수 있습니다. &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;  발사하지 않은 날짜에 대해 Y 및 N 데이터를 채움으로써 정확도를 더 높일 수도 있지만, 이 정확도는 항상 믿음직스럽지 않다는 것을 알고 있어야 합니다. 또한 이러한 머신 러닝 모델에서 정확도를 구할 때는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;정확도의 역설(Accuracy Paradox)&lt;/code&gt;을 조심하여야 합니다.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;‘정확도의 역설(Accuracy Paradox)’ 이란 특정 수준의 정확성을 가진 예측 모델이 더 높은 정확성을 가진 모델보다 더 큰 예측 능력을 가질 수도 있다는 것을 말합니다.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;  따라서 정확성은 항상 의심해봐야 하며, 정밀도(Precision)와 재현율(Recall)을 분류지표로 같이 사용해주는 방법을 많이 사용합니다.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;기계-학습-모델-시각화&quot;&gt;기계 학습 모델 시각화&lt;/h3&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# 의사 결정 트리를 시각화하기 위해 라이브러리를 가져옴
&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;sklearn.tree&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;export_graphviz&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;tree_graph_to_png&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tree&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;feature_names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;class_names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;png_file_to_save&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;tree_str&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;export_graphviz&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tree&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;feature_names&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;feature_names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;        
    &lt;span class=&quot;n&quot;&gt;class_names&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;class_names&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;filled&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;out_file&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pydotplus&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;graph_from_dot_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tree_str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;graph&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;create_png&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;먼저 시각적 표현을 하기 위해서는 매개 변수로 사용하는 함수를 만들어야 합니다.&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;데이터 : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tree&lt;/code&gt; - 기계 학습 모델&lt;/li&gt;
  &lt;li&gt;열 : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;feature_names&lt;/code&gt; - 입력 데이터의 열 목록&lt;/li&gt;
  &lt;li&gt;출력 : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;class_names&lt;/code&gt; - 분류 옵션 목록(이 경우 yes 또는 no)&lt;/li&gt;
  &lt;li&gt;파일 이름 : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;png_file_to_save&lt;/code&gt; - 시각화를 저장하려는 파일의 이름&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# 기계학습 모델을 시각화한다.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tree_graph_to_png&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tree&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tree_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;feature_names&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;columns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;class_names&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'No Launch'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Launch'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;png_file_to_save&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'decision-tree.png'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;함수를 호출하는 방법&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;데이터: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tree_model&lt;/code&gt; - 이전에 학습시키고 테스트한 모델&lt;/li&gt;
  &lt;li&gt;열: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;X.columns.values&lt;/code&gt; - 입력의 열 목록&lt;/li&gt;
  &lt;li&gt;출력: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[Yes, No]&lt;/code&gt; - 가능한 두 가지 결과&lt;/li&gt;
  &lt;li&gt;파일 이름: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;decision_tree.png&lt;/code&gt; - 이미지를 저장하려는 파일의 이름&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;코드를 실행하면 다음과 같은 이미지가 나옵니다.&lt;/p&gt;

&lt;figure&gt;
    &lt;a href=&quot;/images/RocketLaunch/decisiontree.png&quot;&gt;&lt;img src=&quot;/images/RocketLaunch/decisiontree.png&quot; /&gt;&lt;/a&gt;
&lt;/figure&gt;

&lt;p&gt;  이 간단한 트리를 시각화를 통해 데이터의 가장 중요한 기능이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;'Wind Speed at Launch Time'&lt;/code&gt;이였다는 것을 알 수 있습니다. 풍속이 1.0보다 작거나 같은 경우 240개 샘플 중에서 191개가 발사가 없는 것으로 올바르게 추측되었습니다.&lt;br /&gt;
  두 번째로 데이터에서 가장 중요한 기능은 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;'Max Wind Speed'&lt;/code&gt;인 것을 확인할 수 있습니다. 여기에서 최대 풍속이 30.5보다 작거나 같았던 나머지 49일 중에서 48일은 올바른 발사 결과를 생성했고, 1일은 비발사 결과를 생성한 것을 알 수 있습니다.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;하지만 이 결과에는 문제점이 있습니다. 저희는 이전의 데이터 조작에서 비어 있던 값을 모두 0으로 설정했습니다. 또한 저희가 사용한 데이터는 실제 발사나 발사 시도와 관련이 없는 것도 많기 때문에 어디까지나 이 결과는 정확하지 않다는 것을 알고 있어야 합니다.&lt;/p&gt;
&lt;/blockquote&gt;</content><author><name></name></author><category term="Python" /><category term="Anaconda" /><category term="Jupyter" /><category term="Pandas" /><category term="Data science" /><category term="Machine Learning" /><summary type="html">Python과 Anaconda를 이용한 머신 러닝 활용</summary></entry></feed>