본문 바로가기

전체 글

(68)
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 가중치 무작위 초기화를 ..