본문 바로가기
Old/AI

로지스틱 회귀 / Keras

by onenewkong 2023. 1. 16.

로지스틱 회귀: 회귀를 사용하여 데이터가 어떤 범주에 속할 확률을 0에서 1 사이의 값으로 예측하고 그 확률에 따라 가능성이 더 높은 범주에 속하는 것으로 분류해주는 지도 학습 알고리즘

 

- 실제 값이 1일 때 예측 값이 0에 가까워지면 오차가 커져야 함 (-log(x) 그래프)

- 실제 값이 0일 때 예측 값이 1에 가까워지면 오차가 커져야 함 (-log(1-x) 그래프)

- sigmoid 함수 사용

 

신경망의 이해

- 퍼셉트론

- 원래는 XOR 연산 불가능 했음 -> hidden layer

- 기울기와 절편 -> 가중치와 바이어스

여기서 가중치가 이산수학에서 배운 그 가중치라서 반가웠음..ㅎㅎ

- Vanishing Gradient 문제 -> relu 등 다른 함수 적용

 

오늘의 실습!

Epoch 1/30
47/47 [==============================] - 0s 688us/step - loss: 0.6723 - accuracy: 0.6128
Epoch 2/30
47/47 [==============================] - 0s 1ms/step - loss: 0.4566 - accuracy: 0.8511
Epoch 3/30
47/47 [==============================] - 0s 686us/step - loss: 0.4311 - accuracy: 0.8511
Epoch 4/30
47/47 [==============================] - 0s 666us/step - loss: 0.4244 - accuracy: 0.8511
Epoch 5/30
47/47 [==============================] - 0s 709us/step - loss: 0.4210 - accuracy: 0.8511
Epoch 6/30
47/47 [==============================] - 0s 1ms/step - loss: 0.4214 - accuracy: 0.8511
Epoch 7/30
47/47 [==============================] - 0s 689us/step - loss: 0.4197 - accuracy: 0.8511
Epoch 8/30
47/47 [==============================] - 0s 686us/step - loss: 0.4185 - accuracy: 0.8511
Epoch 9/30
47/47 [==============================] - 0s 1ms/step - loss: 0.4176 - accuracy: 0.8511
Epoch 10/30
47/47 [==============================] - 0s 700us/step - loss: 0.4172 - accuracy: 0.8511
Epoch 11/30
47/47 [==============================] - 0s 663us/step - loss: 0.4163 - accuracy: 0.8511
Epoch 12/30
47/47 [==============================] - 0s 700us/step - loss: 0.4160 - accuracy: 0.8511
Epoch 13/30
47/47 [==============================] - 0s 692us/step - loss: 0.4159 - accuracy: 0.8511
Epoch 14/30
47/47 [==============================] - 0s 661us/step - loss: 0.4161 - accuracy: 0.8511
Epoch 15/30
47/47 [==============================] - 0s 1ms/step - loss: 0.4152 - accuracy: 0.8511
Epoch 16/30
47/47 [==============================] - 0s 872us/step - loss: 0.4155 - accuracy: 0.8511
Epoch 17/30
47/47 [==============================] - 0s 800us/step - loss: 0.4156 - accuracy: 0.8511
Epoch 18/30
47/47 [==============================] - 0s 1ms/step - loss: 0.4161 - accuracy: 0.8511
Epoch 19/30
47/47 [==============================] - 0s 1ms/step - loss: 0.4148 - accuracy: 0.8511
Epoch 20/30
47/47 [==============================] - 0s 611us/step - loss: 0.4148 - accuracy: 0.8511
Epoch 21/30
47/47 [==============================] - 0s 1ms/step - loss: 0.4140 - accuracy: 0.8511
Epoch 22/30
47/47 [==============================] - 0s 668us/step - loss: 0.4132 - accuracy: 0.8511
Epoch 23/30
47/47 [==============================] - 0s 705us/step - loss: 0.4151 - accuracy: 0.8511
Epoch 24/30
47/47 [==============================] - 0s 697us/step - loss: 0.4145 - accuracy: 0.8511
Epoch 25/30
47/47 [==============================] - 0s 1ms/step - loss: 0.4138 - accuracy: 0.8511
Epoch 26/30
47/47 [==============================] - 0s 671us/step - loss: 0.4132 - accuracy: 0.8511
Epoch 27/30
47/47 [==============================] - 0s 699us/step - loss: 0.4139 - accuracy: 0.8511
Epoch 28/30
47/47 [==============================] - 0s 1ms/step - loss: 0.4133 - accuracy: 0.8511
Epoch 29/30
47/47 [==============================] - 0s 709us/step - loss: 0.4128 - accuracy: 0.8511
Epoch 30/30
47/47 [==============================] - 0s 666us/step - loss: 0.4129 - accuracy: 0.8511
15/15 [==============================] - 0s 1ms/step - loss: 0.4112 - accuracy: 0.8511

Accuracy: 0.8511

 

step=300, a1=0.7642, a2=-0.4654, b=-2.5223, loss=0.2611
step=600, a1=0.7804, a2=-0.2194, b=-3.9739, loss=0.1876
step=900, a1=0.7010, a2=0.0909, b=-5.0240, loss=0.1472
step=1200, a1=0.6049, a2=0.3849, b=-5.8558, loss=0.1208
step=1500, a1=0.5116, a2=0.6490, b=-6.5467, loss=0.1022
step=1800, a1=0.4263, a2=0.8831, b=-7.1380, loss=0.0885
step=2100, a1=0.3499, a2=1.0906, b=-7.6553, loss=0.0779
step=2400, a1=0.2821, a2=1.2753, b=-8.1151, loss=0.0696
step=2700, a1=0.2217, a2=1.4408, b=-8.5290, loss=0.0628
step=3000, a1=0.1677, a2=1.5899, b=-8.9054, loss=0.0572
predicted= [[0.]
 [0.]
 [0.]
 [1.]
 [1.]
 [1.]
 [1.]]
check predicted= [[0.]
 [1.]
 [0.]]
check hypothesis= [[0.31281755]
 [0.67287771]
 [0.42941379]]

Hypothesis:  [[0.02187637]
 [0.03032256]
 [0.17660801]
 [0.87830607]
 [0.98019967]
 [0.9970636 ]
 [0.99957082]] 
Correct (Y) [[0.]
 [0.]
 [0.]
 [1.]
 [1.]
 [1.]
 [1.]] 
Accuracy:  1.0
공부한 시간: 7, 과외 수업 횟수: 6
합격 가능성:  85.92 %

 

 

 

오늘 자 비교과 수업 내용 정리

- 김상모 교수님 인공지능 입문 교육

- 6회차: 로지스틱 회귀 이론 및 실습, 케라스 기본 이

'Old > AI' 카테고리의 다른 글

과적합  (0) 2023.01.20
다중분류  (0) 2023.01.19
선형회귀 / TensorFlow  (0) 2023.01.13
선형회귀  (0) 2023.01.11