[TIL] 2021.02.15

hyelimchoi1223·2021년 2월 15일
1

[TIL] 2021년

목록 보기
11/44
post-thumbnail

오늘 공부한 내용

  • 시각화 실습

시각화 실습

Coursera-Machine Learning강의(Andrew Ng) 중 Exam 예제를 가지고 시각화를 시켜보았다.

from matplotlib import pyplot as plt
import pandas as pd
import numpy as np

def hypothesis(seta0, seta1, value_x):    
    return seta0+(seta1*value_x)

lineardata = {'x':[],'y':[]}
for x in np.arange(0,10,1):
    lineardata['x'].append(x)
    lineardata['y'].append(hypothesis(-569.6, -530.9, x))

lineardata_df = pd.DataFrame(lineardata)
testdata = {'x':[1,2,2,3,3,4,5,6,6,6,8,10],
           'y':[-890, -1411,-1560,-2220, -2091, -2878, -3537, -3268, -3920, -4163, -5471, -5157] }
test_df = pd.DataFrame(testdata, index=['methane', 'ethene', 'ethene', 'propane', 'cyclopropane', 'butan', 'pentane', 'benzene', 'cycloexane', 'hexane', 'octane', 'napthalene'])
plt.plot(testdata['x'], testdata['y'])
plt.plot(lineardata_df['x'], lineardata_df['y'])
plt.show()
  • 데이터
  • 결과

오늘 하루 돌아보기

오늘 데이터셋과 모양이 비슷한 hypothesis를 직접 그려보기로 했다. 물론 seta0, seta1은 이미 주어진 값이었지만 matplotlib으로 그래프를 그리니 주어진 값이 데이터셋과 모양이 비슷한 것을 말로만 아닌 직접 눈으로 확인하는 기회였다. 다음에는 costFunction 결과값을 그래프로 그리는 작업을 해보고 싶다.

0개의 댓글