[머신러닝] Logistic Regression이 Classification에서 Linear Regression보다 우월하게 동작하는 예제를 보고 싶습니다.

HDNua의 이미지

안녕하세요. 김성훈 교수님의 머신러닝 강의를 듣고 있던 도중 의문이 생겼습니다.
Logistic Regression에 관한 문제입니다.

결론부터 말하면, Logistic Regression이 Linear Regression보다 우월하게 동작하는 예제를 보고 싶습니다.
그리고 제 코드의 구현이 틀렸는지도 추가로 여쭤보고 싶습니다.

Linear Regression이 Binary Classification에 적합하지 않은 이유로 두 가지가 제시되었습니다.
1. outlier가 들어왔을 때 기울기가 크게 변해서 잘못된 결과를 낸다.
2. 출력이 0과 1로 고정되어있는데 Linear Regression의 경우 실수 전체가 출력이 된다.
따라서 "outlier에 영향을 적게 받으면서 출력을 0과 1 사이로 고정하기 위해 제안된 모델이 Logistic Regression이다."라고 이해했습니다.

아래 링크는 강의 동영상을 토대로 Logistic Regression을 구현한 것입니다.
링크에 출력 결과가 포함되어있습니다.
https://goo.gl/ZPiUjQ

이 프로그램을 통해 확인하려는 것은, 정말로 Logistic Regression이 Linear Regression보다 Binary Classification을 더 잘 하는가입니다. 그래서 Linear Regression과 Logistic Regression을 모두 수행한 후 하나의 그래프로 그려서 결과를 확인하고자 했습니다.

그 결과는 링크의 맨 마지막 그림과 같습니다.
빨간 선이 Linear Regression, 초록 선이 Logistic Regression의 결과입니다.

이 세트는 40이라는 outlier를 포함하지만, 0.5를 기준으로 적당히 분류를 잘 하고 있는 것으로 보입니다. 사실 두 경우에 같은 점을 지나는 것처럼 보여요.
outlier가 있더라도 Linear Regression이 알아서 기준선을 잘 찾는 느낌이 들었는데, 제가 잘못 이해하고 있다는 생각이 들었습니다.

아래는 outlier가 너무 작아서 생긴 일인가 해서 40을 140으로 바꾼 후의 결과입니다.
https://goo.gl/BLj6JH
여전히 0.5 기준으로 분류가 잘 되는 것 같아요...

덧. Logistic Regression이 초기 weight와 bias에 따라 nan이 출력되는 경우가 있는데, 이것도 제 코드 문제인지 궁금합니다.

부족한 공대생에게 가르침 부탁합니다. 긴 글 읽어주셔서 감사합니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.