
대학생들의 신장과 체중을 받아서 성별을 출력하는 퍼셉트론을 만들어보자.
즉 입력과 출력은 다음과 같다.
from sklearn.linear_model import Perceptron
import numpy as np
from matplotlib import pyplot as plt
x = np.array([[160,55],
[163,43],
[165,48],
[170,80],
[175,76],
[180,70]])
y = np.array([1,1,1,0,0,0])
# 모델 생성 및 학습
clf = Perceptron(tol=1e-2, random_state = 0)
clf.fit(x, y)
# 실제 데이터는 점으로 표시
plt.scatter(x[:,0],x[:,1])
# 예측한 값 출력
prediction = clf.predict(x[:])
print(prediction)
# 내 몸무게랑 키 입력해서 예측값 출력
prediction_me = clf.predict([[162,53]])
print(prediction_me)
prediction_s = clf.predict([[175,69]])
print(prediction_s)
plt.show()


나를 여자로 분류해줬다~
퍼셉트론 땡큐요~><~🥹👍❤️