본문 바로가기

AI

(8)
머신러닝 기초 - 읽어보기 머신러닝? 1.3 머신러닝 시스템의 종류 1.2 왜 머신러닝을 사용하는가? | 목차 | 1.4 머신러닝의 주요 도전 과제 머신러닝 시스템의 종류는 굉장히 많으므로 다음을 기준으로 넓은 범주에서 분류하면 도움이 됩니다. 사람의 감독 하에 tensorflow.blog 분류 문제 - OvR 방식? OvO 방식? One-vs-Rest and One-vs-One for Multi-Class Classification Not all classification predictive models support multi-class classification. Algorithms such as the Perceptron, Logistic Regression, and Support Vector Machines were […..
1209 - 의사결정나무 딥러닝 기초 - DecisionTree & RandomForest 의사결정나무 정보 이득 : '부모 노드'와 '자식 노드'의 불순도 합의 차이 자식 노드의 불순도가 낮을수록 정보 이득이 커짐 불순도 지표 : 지니 불순도, 엔트로피, 분류 오차 불순도 조건을 바꾸는 것보다 가지치기 수준을 바꾸면서 튜닝하는게 성적 향상에 도움됨 - 설명이 중요할 때 아주 유용한 모델 - 뿌리부터 정보 이득이 최대가 되는 특성으로 가지를 나눔 - 모든 이파리가 순수해질 때까지 반복 - 이 과정에서 과대적합될 가능성 高 → 따라서 최대 나무 가지 수를 제한 하는 등 가지치기 과정 필요 세가지 불순도 기준을 시각적으로 비교 import matplotlib.pyplot as plt import numpy as np def gini..
1208 - 서포트백터머신 딥러닝 기초 - Support Vector Machine SVM from sklearn.svm import SVC svm = SVC(kernel = 'linear', C = 1.0, random_state=1) svm.fit(X_train_std, y_train) plot_decision_regions(X_combined_std, y_combined, classifier = svm, test_idx = range(105, 150)) plt.xlabel('petal length [standardized]') plt.ylabel('petal width [standardized]') plt.legend(loc = 'upper left') plt.tight_layout() plt.show() SVM-SGD fr..
1207 - 로지스틱회귀 딥러닝 기초 - Logistic Regression Gradient Descent 시그모이드 함수 import matplotlib.pyplot as plt import numpy as np def sigmoid(z): return 1.0 / (1.0 + np.exp(-z)) z = np.arange(-7, 7, 0.1) phi_z = sigmoid(z) plt.plot(z, phi_z) plt.axvline(0.0, color='k') plt.ylim(-.1, 1.1) plt.xlabel('z') plt.ylabel('$\phi (z)$') # y축의 눈금과 격자선 plt.yticks([0.0, 0.5, 1.0]) ax = plt.gca() ax.yaxis.grid(True) plt.tight_layou..
1207 - 아달린 SGD 딥러닝 기초 - Adaptive Linear Stochastic Gradient Descent 확률적 경사 하강법은 경사 하강법보다 가중치가 더 자주 업데이트되기 때문에 수렴 속도가 훨씬 빠름. - 훈련 샘플 순서를 무작위하게 주입 - 에포크마다 훈련 데이터셋을 섞음 ; class AdalineSGD(object): """ ADAptive Linear Neuron 분류기 매개변수 ------------- learning_rate : float 학습률 (0.0과 1사이) n_iter : int 훈련 데이터셋 반복 횟수 shuffle : bool (default: True) True로 설정하면 같은 반복이 되지 않도록 에포크마다 훈련 데이터를 섞음. random_state : int 가중치 무작위 초기화를 ..
1202 - 아달린 딥러닝 기초 - Adaptive Linear Gradient Descent Iris 꽃 분류 문제를 해결하기위한 아달린 모델 구현 class AdalineGD(object): """ 적응형 선형 뉴런 분류기 매개변수 ------------ learning_rate : float 학습률 (0.0과 1.0 사이) n_iter : int 훈련 데이터셋 반복 횟수 random_state : int 가중치 무작위 초기화를 위한 난수 생성기 시드 속성 ------------- w_ : 1d-array 학습된 가중치 cost_ : list 에포크마다 누적된 비용 함수의 제곱합 """ def __init__(self, learning_rate=0.01, n_iter=50, random_state=1): self.lea..
1201 - 퍼셉트론 딥러닝 기초 - Perceptron Iris 꽃 분류 문제를 해결하기위한 퍼셉트론 모델 구현. import numpy as np class Perceptron(object): """ 퍼셉트론 분류기 매개변수 ------------ learning_rate : float 학습률 (0.0과 1.0 사이) n_iter : int 훈련 데이터셋 반복 횟수 random_state : int 가중치 무작위 초기화를 위한 난수 생성기 시드 속성 ------------ w_ : 1d-array 학습된 가중치 errors_ : list 에포크마다 누적된 분류 오류 """ def __init__(self, learning_rate=0.01, n_iter=50, random_state=1): self.learning_rat..
Kaggle 준비 해보기(1) Optiver Realized Volatility Prediction * Optiver는 제조 회사인지 금융 회사인지 모르겠지만 어쨌든 무슨 회사 이름이다. 아래는 대략적인 개요. (더보기 누르면 보인다.) 더보기 Volatility is one of the most prominent terms you’ll hear on any trading floor – and for good reason. In financial markets, volatility captures the amount of fluctuation in prices. High volatility is associated to periods of market turbulence and to large price swings, while lo..