본문 바로가기

분류 전체보기

(20)
K-mean clustering, AffinityPropagation K-mean clustering 실습 from sklearn import cluster from sklearn import datasets import matplotlib.pyplot as plt iris = datasets.load_iris() data = iris['data'] #model = cluster.KMeans( n_clusters = 5 ) model = cluster.AffinityPropagation() model.fit(data) print(model.labels_) labels = model.labels_ ldata = data[labels == 0] plt.scatter(ldata[:,2], ldata[:,3], c='black', alpha=0.3, s=100, marker="o..
강의 슬라이드 전체 (최종) 최종 버전입니다.
Numpy, Pandas cheat sheet, 컨닝 페이퍼 수업에 사용한 numpy, pandas cheat sheet 입니다.
머신러닝 5장: clustering 5장 슬라이드 다운로드
로지스틱 회기 (logistic regression) 실습 코드: 날씨 예측의 예 import numpy as np from sklearn.linear_model import LogisticRegression X_train = np.r_[np.random.normal(3,1,size=50), np.random.normal(-1,8,size=50)].reshape((100,-1)) y_train = np.r_[np.ones(50), np.zeros(50)] model = LogisticRegression() model.fit(X_train, y_train) print(model.predict_proba([[0],[1],[2]])[:,1])
Logistic Regression 실습 날씨 예측 문제 import numpy as np from sklearn.linear_model import LogisticRegression import matplotlib.pyplot as plt X_train = np.r_[np.random.normal(3,1,size=50), np.random.normal(-1,8,size=50)].reshape(100,1) y_train = np.r_[np.ones(50), np.zeros(50)] model = LogisticRegression() model.fit(X_train,y_train) print(model.predict_proba([[-1],[0],[2]])[:,0]) print(model.coef_) print(model.intercept_) pr..
과적합 (overfitting) 체험 overfitting 체험 오버피팅된 모델의 train data와 test data에 대한 결정계수 비교 import numpy as np import matplotlib.pyplot as plt from sklearn import linear_model from sklearn import svm x = np.random.rand(100,1) x = x * 2 - 1 #y = 4x3 - 3x2 + 2x - 1 y = 4 * x**3 - 3 * x**2 + 2 * x -1 y += np.random.randn(100,1) x_train = x[:30] y_train = y[:30] x_test = x[30:] y_test = y[30:] """ plt.subplot(1,3,1) plt.scatter(x,y..
Non-Linear Regression 비선형 회귀 import math import numpy as np import matplotlib.pyplot as plt from sklearn import linear_model from sklearn import svm from sklearn import ensemble from sklearn import neighbors x = np.random.rand(1000,1) x = x * 20 - 10 y = np.array([math.sin(v) for v in x]) y += np.random.randn(1000) #model = linear_model.LinearRegression() #model = svm.SVR() model = ensemble.RandomForestRegressor() #m..
머신러닝 4장: regression 머신러닝 4장 슬라이드 다운로드
과제1 •iris 데이터에 대해 오늘 배운 모든 classification 알고리즘을 적용해보고 성능을 비교해보자