본문 바로가기
728x90
반응형
SMALL

AI-driven Methodology/Artificial Intelligence22

[AI] 와인 품질 예측 와인 품질 : 3 ~ 9 숫자 값으로 예측 import pandas as pd # 데이터 로드 # 원본 파일은 분리자가 세미콜론 red_df = pd.read_csv('./winequality-red.csv', sep=';') white_df = pd.read_csv('./winequality-white.csv', sep=';') red_df.head() white_df.head() # 분리자를 콤마로 사본 저장 (일반적으로 csv 파일 세미콜론이 아닌 콤마로 분리자를 사용) red_df.to_csv('./winequality-red2.csv', index=False) white_df.to_csv('./winequality-white2.csv', index=False) red_df = pd.read_cs.. 2022. 7. 24.
[AI] 표준화 (Standardization) import matplotlib import pandas as pd from matplotlib import pyplot as plt df = pd.read_csv('./kaggle_diabetes.csv') df.head() df.hist() plt.tight_layout() plt.show() df['BloodPressure'].hist() plt.tight_layout() plt.show() df.info() df.isnull().sum() for col in df.columns: missing_rows = df.loc[df[col] == 0].shape[0] print(col + ": " + str(missing_rows)) import numpy as np # outlier 처리 df['Gluc.. 2022. 7. 24.
[AI] 분류 (Classification) 분류 (Classification) import tensorflow as tf from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Flatten, Dense from tensorflow.keras.optimizers import SGD, Adam import numpy as np try: loaded_data = np.loadtxt('./example.csv', delimiter=',') x_data = loaded_data[ :, 0:-1] t_data = loaded_data[ :, [-1]] print(x_data.shape, t_data.shape) except Exception as err: prin.. 2022. 7. 23.
[AI] 다변수 선형 회귀 Sequential API import tensorflow as tf import numpy as np from numpy import genfromtxt from tensorflow.keras.models import Sequential, Model from tensorflow.keras.layers import Flatten, Dense, Input from tensorflow.keras.optimizers import SGD, Adam my_data = genfromtxt('csv.csv', delimiter=',') print(my_data) x_data = my_data[ : , :-1] t_data = my_data[ : , [-1]] print('loaded_data.shape = ', my.. 2022. 7. 17.
[AI] Basic Architecture TensorFlow TensorFlow는 텐서 (Tensor)를 흘려 보내면서 (Flow) 딥러닝 알고리즘을 수행하는 프레임워크이다. ① 사용자 친화적 (Keras as High Level API) ② 코드 가독성과 직관성을 높이는 Eager Execution 적용 Keras Keras 창시자 프랑소와 숄레 (François Chollet)가 TF 2.0 개발에 참여하였고, TF 2.0 에서 공식적이고 유일한 High-Level API로써 Keras가 선정되었다. 또한, 프랑소와 숄레는 앞으로 native Keras 보다는 tf.keras를 사용할 것을 권장하고 있다. 사용자 친근성 (User Friendliness) : 직관적인 API를 이용하면 ANN, CNN, RNN 또는 이를 조합한 딥러닝 모델을.. 2022. 7. 17.
[AI] Feed Forward ∙ One Hot Encoding ∙ Softmax Feed Forward 신경망의 입력층 (input layer)으로 데이터가 입력되고, 1개 이상으로 구성되는 은닉층 (hidden layer)을 거쳐서 출력층(output layer)으로 출력 값을 내보내는 과정이다. import numpy as np # 활성화함수 sigmoid def sigmoid(x): return 1 / (1 + np.exp(-x)) input_data = np.array([1, 2]) # 입력데이터 target_data = np.array([1]) # 정답데이터 input_nodes = 2 # 입력노드 hidden_nodes = 3 # 은닉노드 output_nodes = 1 # 출력노드 W2 = np.random.rand(input_nodes, hidden_nodes) b2 =.. 2022. 7. 17.
[AI] 로지스틱 회귀 (Logistic Regression) 로지스틱 회귀 (Logistic Regression) 선형 회귀에서 확장한 것으로 독립 변수의 선형 결합을 이용하여 사건의 발생 가능성을 예측하는데 사용되는 통계 기법이다. numerical_derivative, sigmoid 함수 정의 import numpy as np from datetime import datetime np.random.seed(0) def numerical_derivative(f, x): delta_x = 1e-4 # 0.0001 grad = np.zeros_like(x) it = np.nditer(x, flags=['multi_index'], op_flags=['readwrite']) while not it.finished: idx = it.multi_index tmp_val =.. 2022. 7. 10.
[AI] 수치 해석 수치 미분 (Numerical Derivative) 데이터 관점에서 미분은 loss를 줄이기 위해 x를 조금씩 변화시키는 것이다. import numpy as np # 미분 함수 def numerical_derivative(f, x): delta_x = 1e-4 grad = np.zeros_like(x) it = np.nditer(x, flags=['multi_index'], op_flags=['readwrite']) while not it.finished: idx = it.multi_index tmp_val = x[idx] x[idx] = float(tmp_val) + delta_x fx1 = f(x) # f(x+delta_x) x[idx] = float(tmp_val) - delta_x fx2 = f.. 2022. 7. 10.
[AI] 러닝 아키텍처 러닝 아키텍처 학습이란, 계산 값 Y와 정답 T와의 차이를 나타내는 손실 값 (또는 손실함수) loss가 최소가 될 때까지 가중치 W와 bias b를 최적화시키는 과정이다. 손실 함수 (Loss function) MAE MSE RMSE BCE CCE GAN YOLO 개발 프로세스 1. Data Preparation 2. Initialize weights and bias 3. define loss function and output, y 4. learning for epochs for steps 5. evaluate and predict 아키텍처 Linear Regression Logistic Regression Deep Learning 2022. 7. 9.
[AI] 인공지능 ∙ 머신러닝 ∙ 딥러닝 인공지능 ∙ 머신러닝 ∙ 딥러닝 인공지능 (Artificial Intelligence) 인공적으로 만들어진 지능 머신러닝 (Machine Learning) 데이터를 이용하여 데이터의 특성과 패턴을 학습하여, 그 결과를 바탕으로 미지의 데이터 에 대한 그것의 미래 결과 (값, 분포)를 예측 딥러닝 (Deep Learning) 머신러닝의 한 분야로서 신경망(Neural Network)을 통하여 학습하는 알고리즘의 집합 Machine Learning Type ① 지도 학습 (Supervised Learning) ② 비지도 학습 (Unsupervised Learning) ③ 강화 학습 (Reinforcement Learning) 지도 학습 (Supervised Learning) 정답 데이터 (label) 형태와.. 2022. 7. 9.
728x90
반응형
LIST