๋ฐ์ํ
์ด์ง ๋ถ๋ฅ๋?
๊ฒฐ๊ณผ๊ฐ์ด ์ ํ data๋ฅผ ํ์ตํ ํ
์ ๋ ฅ๋ ๋ฐ์ดํฐ๊ฐ ์ด๋ค group์ ์ํ๋ ์ง ์ฐพ์๋ด๋ ๋ฐฉ๋ฒ
ํนํ ๋ ์ค ํ๋๋ฅผ ๊ฒฐ์ ํ๋ ๊ฑธ ์ด์ง ๋ถ๋ฅ๋ผ๊ณ ํ๋ค.
ex)์คํธ๋ฉ์ผ์ธ๊ฐ ์๋๊ฐ
ํ์ํ Library
- numpy : data ์์ฑํ ๋ ํ์(๋ฐฐ์ด๋ก ๋ฐํ)
- tensorflow : google์์ ์ ๊ณต
โ keras : model์ ๊ตฌ์ฑํ๋๋ฐ ํ์ - matplotlib : ๊ทธ๋ํ๋ฅผ ๋ง๋๋๋ฐ ํ์
import numpy as np
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
from tensorflow.keras import optimizers
%matplotlib inline
import matplotlib.pyplot as plt
x = np.array( [-20, -10, -5, 0, 5, 10, 20, 25, 30] )
y = np.array( [0, 0, 0, 0, 0, 0, 1, 1, 1] )
model=Sequential()
model.add(Dense(1, input_dim=1, activation='sigmoid'))
sgd=optimizers.SGD(lr=0.01)
model.compile(optimizer=sgd, loss='binary_crossentropy', metrics=['binary_accuracy'])
model.fit(x, y, batch_size=1, epochs=300, shuffle=False)
plt.plot(x, model.predict(x), 'b', x, y, 'k.')
print(model.predict([1, 23, 50]))
๋ฐ์ํ
'๐ Python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Python]๊ฐ๋ฐํ๊ฒฝ ๊ตฌ์ฑ1: ์๋์ฝ๋ค ์ค์น, ์ฅฌํผํฐ์คํ (1) | 2024.06.02 |
---|---|
[Python]Data science (0) | 2024.05.28 |
[python]Colab (0) | 2024.05.22 |
[Python]์ธ๊ณต์ง๋ฅ Artificial Inteligence (0) | 2024.05.21 |
์์ ํ์ด4 (0) | 2024.05.19 |