CodeOnWeb
로그인

Linear Regression 02

오 태호 2018/09/07, 16:12

내용

AI PM 강의 (49)

Python 환경 만들기 Python 기초 실습 Python 기초 요약 Python 활용 실습 Python 활용 요약 Linear Regression 01 Linear Regression 02 Linear Regression 03 Linear Regression 04 Linear Regression 05 Linear Regression 06 Linear Regression 요약 Logistic Regression 01 Logistic Regression 02 Logistic Regression 03 Logistic Regression 04 Logistic Regression 05 Logistic Regression 요약 추천 시스템 실습 - 내용 기반 추천 추천 시스템 실습 - 협업 필터링1 추천 시스템 실습 - 협업 필터링2 TMDB API키 만들기 추천 시스템 요약 ML 방법론 및 결과 해석 실습 - 데이터셋 나누기 ML 방법론 및 결과 해석 실습 - Skewed Classes ML 방법론 및 결과 해석 실습 - Precision/Recall ML 방법론 및 결과 해석 실습 - Down/Up Sampling ML 방법론 및 결과 해석 요약 Neural Network 01 Neural Network 02 Neural Network 03 Neural Network 04 Neural Network 요약 Convolutional Neural Network 01 Convolutional Neural Network 02 Convolutional Neural Network 03 Convolutional Neural Network 04 Convolutional Neural Network 05 Convolutional Neural Network 06 Convolutional Neural Network 요약 ML as a Service (MLaaS)

AI PM 강의 V1

집 넓이로부터 집 가격을 추정하는 $h_\theta(x)$를 Gradient Descent를 사용하여 찾아 봅니다.

  • 필요한 package들을 import합니다.

  • 집의 data를 얻어오는 함수를 정의합니다.

  • 집의 넓이로 집의 가격을 추정하는 $h_\theta(x)=\theta_0+\theta_1x$ 함수를 정의합니다.

  • cost를 계산하는 함수를 정의합니다.
    • $J(\theta_0, \theta_1)=\frac{1}{m}\sum_{i=1}^{m}(h_{\theta}(x^{(i)})-y^{(i)})^{2}$
    • $h_\theta(x)=\theta_0+\theta_1x$

  • x_data, y_data로 그래프를 그리고, $h_\theta(x)=\theta_0+\theta_1x$ 그래프를 그리는 함수를 정의합니다.
    • 그래프에 cost의 contour map도 표시합니다.
    • 그래프에 cost정보도 표시합니다.

  • $\theta_0$$\theta_1$를 Cost가 약간 작아지는 방향으로 변경해서 return하는 함수를 정의합니다.
    • $temp0 := \theta_0-\alpha\frac{\partial }{\partial \theta_0}J(\theta_0,\theta_1)$
      $temp1 := \theta_1-\alpha\frac{\partial }{\partial \theta_1}J(\theta_0,\theta_1)$
      $\theta_0 := temp0$
      $\theta_1 := temp1$
    • $\frac{\partial }{\partial \theta_0}J(\theta_0,\theta_1)=\lim_{h \to 0}\frac{J(\theta_0+h,\theta_1)-J(\theta_0,\theta_1)}{h}$
      $\frac{\partial }{\partial \theta_1}J(\theta_0,\theta_1)=\lim_{h \to 0}\frac{J(\theta_0,\theta_1+h)-J(\theta_0,\theta_1)}{h}$

  • Gradient Descent를 사용하여 cost가 가장 작아지는 $\theta_0$$\theta_1$을 찾습니다.
    • theta0, theta1, learning_rate를 다양하게 설정해 보며 Gradient Descent가 어떻게 작동하는지 살펴봅니다.

  • 집의 넓이, 집의 가격, 집의 추정 가격을 print합니다.


714 읽음
이전 Linear Regression 01
다음 Linear Regression 03

저자

토론이 없습니다

Please log in to leave a comment

16.5.11618.20190612.allo
문제 보고 · 사용조건 · 개인정보보호
래블업 주식회사 · 대한민국 서울 테헤란로 145 · 대표: 신정규 · 사업자번호: 864-88-00080 · +82 70-8200-2587

거절 확인

닫기
좋아요 책갈피 토론

아래 주소를 복사하세요