
'''

또 낯춰보자 
이 바닥 끝까지

단, 데이터 조작은 안된다. 



1. R2 0.5이하
2. layer 5개 이상
3. node의 갯수 10개 이상
4. epoch는 30개 이상
5. batch_size는 8 이하


또 overfitting 해야할까 

'''

# 1. 데이터_________________________________
import numpy as np

x = np.array([range(1,101), range(311,411), range(100)]).T
y = np.array(range(711,811))




from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(
   
    x, y, shuffle = False  , train_size = 0.9  
)




# 2. 모델 구성____________________________
from keras.models import Sequential
from keras.layers import Dense 
model = Sequential()

model.add(Dense(5, input_dim = 3)) # input 데이터가 3열 
model.add(Dense(50))
model.add(Dense(50))
model.add(Dense(50))
model.add(Dense(50))
model.add(Dense(50))
model.add(Dense(50))
model.add(Dense(50))
model.add(Dense(50))
model.add(Dense(50))
model.add(Dense(1))                # 반면 output은 1열 


# 3. 훈련_______________________________________________________________________________
model.compile(loss='mse', optimizer='adam', metrics=['mse'])
model.fit(x_train, y_train, epochs=800, batch_size = 15, validation_split= 0.5, verbose= 0) 

#80만번 돌리다가 집에 갈 시간

#4. 평가, 예측____________________________________________
loss,mse = model.evaluate(x_test, y_test, batch_size = 1) 
print("loss : ", loss)
print("mse : ", mse) 



y_predict = model.predict(x_test)
print(y_predict)


#________RMSE 구하기_________________________________________
from sklearn.metrics import mean_squared_error
def RMSE(y_test ,y_pred) :
    return np.sqrt(mean_squared_error(y_test, y_predict))

# y_test = 실제값, y_pred = 예측값

print("RMSE : ", RMSE(y_test, y_predict))    




#________R2 구하기_____________________
from sklearn.metrics import r2_score
r2 = r2_score(y_test, y_predict)

print("R2 score : ", r2)
# _____________________________________

