혼공ML+DL #4

myeong·2022년 9월 7일
0

ML+DL

목록 보기
2/23
post-thumbnail

📌Data set

  • training-set / test-set 으로 슬라이싱해 사용

  • fit 함수에는 training-set / score 함수에는 test-set

  • 슬라이싱할 때에는 sample data가 편향되지 않도록 ❗❗
    -> 넘파이 사용 + 데이터 셔플 (입력과 타깃이 쌍으로)


📍 넘파이

fish_data = [[...]]
fish_target = [...]

#리스트를 넘파이로 변환
import numpy as np
input_arr = np.array(fish_data)
target_arr = np.array(fish_target)
  • 인덱스 셔플 -> 해당 데이터 매칭
index = np.arange(49)  # 인덱스 배열 0~48
np.random.shuffle(index)  # 섞기
  • 배열 슬라이싱 - 인덱스에 배열을 넣어 슬라이싱
train_input = input_arr[index[:35]]  
train_target = target_arr[index[:35]]
test_input = input_arr[index[35:]]
test_target = target_arr[index[35:]]

📍 나누어진 데이터

  • 샘플의 [x, 0] = length / [x, 1] = weight
  • 범위, 전체를 지칭할 땐 : 사용
import matplotlib.pyplot as plt
plt.scatter(train_input[:, 0], train_input[:, 1])
plt.scatter(test_input[:, 0], test_input[:, 1])
plt.xlabel('length')
plt.ylabel('weight')
plt.show()



🔗혼공 MLDL -4

0개의 댓글