반응형

tensorflow 11

회귀 모델 정리 - 앙상블 및 기타 모델

앙상블은 여러 모델을 합치는 모델로, 1:1 모델은 없다 2개의 모델이 합쳐서 2개의 모델로 출력되는 다:다 모델을 만들자 다:다 1 모델 #1. 데이터 import numpy as np x1 = np.array([range(1, 101), range(101, 201)]) y1 = np.array([range(1, 101), range(101, 201)]) x2 = np.array([range(501, 601), range(601, 701)]) y2 = np.array([range(501, 601), range(601, 701)]) print(x1.shape) print(y1.shape) print(x2.shape) print(y2.shape) (2, 100) (2, 100) (2, 100) (2, 10..

AI/DeepLearning 2020.07.13

회귀 모델 정리 - 함수형 모델

1:1모델 데이터 입력과 출력은 Sequential과 동일하다. #1. 데이터 # 1~7까지 데이터를 훈련시키고 8~10 데이터로 평가, 훈련이 잘되었나 11~13 예측 import numpy as np x_train = np.array([1,2,3,4,5,6,7]) y_train = np.array([1,2,3,4,5,6,7]) x_test = np.array([8,9,10]) y_test = np.array([8,9,10]) x_predict = np.array([11,12,13]) #2. 모델 구성 from keras.models import Model from keras.layers import Dense, Input input1 = Input(shape=(1,)) dense1 = Dense(10..

AI/DeepLearning 2020.07.11

회귀 모델 4 R2, RMSE 추가

https://soccerda.tistory.com/131 회귀모델의 판별식 R2, RMSE #RMSE 구하기 from sklearn.metrics import mean_squared_error def RMSE(y_test, y_predict): return np.sqrt(mean_squared_error(y_test, y_predict)) print("RMSE : ", RMSE(y_test, y_predict)) RMSE(평균 제.. soccerda.tistory.com R2는 1에 가까울수록 RMSE는 낮을수록 좋은 수치이다. 아직 데이터가 적은 양이어서 Validation을 추가했다고 더 좋은 값이 나오는 것이 눈에 띄지 않지만, 많아질수록 Train 데이터에서 일부의 검증 세트를 분리하여 훈련하는..

AI/DeepLearning 2020.06.27

회귀 모델 3 훈련세트, 검증세트, 테스트세트 분리

앞에서 모델을 훈련시킬 때(fit) 검증 값을 test로 사용했다. 그러나 훈련 세트에 검증 값이 들어가고 그 검증 값을 다시 테스트한다면 평가에 검증 값이 반영되는 문제가 있다. 그래서 훈련 세트, 테스트 세트, 검증 세트은 분리가 되는 것이 좋다. 일반적으로 Train 데이터의 일부를 잘라서 Validation 데이터로 사용하는 것이 좋다. import numpy as np #1 데이터 준비 #훈련데이터 x_train = np.array([1,2,3,4,5,6,7,8,9,10]) y_train = np.array([1,2,3,4,5,6,7,8,9,10]) #테스트데이터 x_test = np.array([11,12,13,14,15,16,17,18,19,20]) y_test = np.array([11,1..

AI/DeepLearning 2020.06.26

회귀모델의 판별식 R2, RMSE

#RMSE 구하기 from sklearn.metrics import mean_squared_error def RMSE(y_test, y_predict): return np.sqrt(mean_squared_error(y_test, y_predict)) print("RMSE : ", RMSE(y_test, y_predict)) RMSE(평균 제곱근 오차 , Root Mean Squared Error)는 회귀 분석을 평가할 때 가장 많이 쓰는 지표 중 하나이다. RMSE는 함수가 내장되어 있지 않아 함수를 직접 구현해야 한다. from sklearn.metrics import mean_squared_error MSE에 루트를 씌운 것이 RMSE이다. 원래 데이터에서 평균을 뺀 값을 제곱하여 모두 더한 뒤 전체..

AI/DeepLearning 2020.06.23

회귀 모델 2 101~110 예측하기

1차 함수 from keras.models import Sequential from keras.layers import Dense import numpy as np #1 데이터 준비 #훈련데이터 x_train = np.array([1,2,3,4,5,6,7,8,9,10]) y_train = np.array([1,2,3,4,5,6,7,8,9,10]) #평가데이터 x_test = np.array([101,102,103,104,105,106,107,108,109,110]) y_test = np.array([101,102,103,104,105,106,107,108,109,110]) #2 모델 구성 model = Sequential() #input_dim x_train으로 1개의 컬럼 데이터를 입력하며르 input..

AI/DeepLearning 2020.06.23

회귀 모델 1 1에서 10까지 예측하기

import numpy as np #데이터 생성 x입력 y출력 x = np.array([1,2,3,4,5,6,7,8,9,10]) y = np.array([1,2,3,4,5,6,7,8,9,10]) from keras.models import Sequential from keras.layers import Dense #1차 함수 모델 구성 #순차적 구성 model = Sequential() #순차적 구성 모델에 Dense(레이어 layer)를 추가 model.add(Dense(1, input_dim=1, activation='relu')) #컴파일 loss: 손실함수 optimizer:최적화함수 metrics:방식(accuracy:정확도) model.compile(loss='mean_squared_error..

AI/DeepLearning 2020.06.23

텐서플로우 개발 환경 구축 3 (PyCharm 설치)

Python 개발을 쉽게 할 수 있도록 도와주는 개발 통합 환경 IDE(Integrated Development Environment)인 PyCharm을 설치하도록 하겠다. PyCharm 설치 https://www.jetbrains.com/pycharm/ PyCharm: the Python IDE for Professional Developers by JetBrains The Python & Django IDE with intelligent code completion, on-the-fly error checking, quick-fixes, and much more... www.jetbrains.com PyCharm은 공식 홈페이지에서 실치 파일을 받을 수 있다. PyCharm은 유료 버전인 Profes..

AI/DeepLearning 2020.06.04

텐서플로우 개발 환경 구축 2 (텐서플로우 설치)

이전 글에서 아나콘다를 설치해보았다. https://soccerda.tistory.com/113 텐서플로우 개발 환경 구축 1 (아나콘다 설치) Tensorflow 공식 홈페이지 https://www.tensorflow.org/install 에 들어가 보면 운영 체제별 설치 방법을 확인할 수 있다. Install TensorFlow 2 Learn how to install TensorFlow on your system. Download a pip.. soccerda.tistory.com anaconda에는 Python 및 다양한 패키지가 포함되어 있어 별도로 Python을 설치할 필요가 없다. 텐서플로우를 설치하기 위해서 가상 환경을 만들어야 한다. 가상 환경에 설치하면 기존 시스템에 영향을 받지 않고 ..

AI/DeepLearning 2020.06.01

텐서플로우 개발 환경 구축 1 (아나콘다 설치)

Tensorflow 공식 홈페이지 https://www.tensorflow.org/install 에 들어가 보면 운영 체제별 설치 방법을 확인할 수 있다. Install TensorFlow 2 Learn how to install TensorFlow on your system. Download a pip package, run in a Docker container, or build from source. Enable the GPU on supported cards. www.tensorflow.org 크게 CPU버전과 GPU 버전으로 나눠져 있어 자신의 자신의 시스템에 맞게 설치하면 되는데 CPU 버전은 시스템에 NVIDIA GPU를 가지고 있다면 설치하면 되며 GPU보다 설치 시간이 절약된다. GPU ..

AI/DeepLearning 2020.05.26
반응형