머신러닝(8)
-
[머신러닝] Support Vector Machine
import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn import datasets from sklearn.preprocessing import StandardScaler from sklearn.svm import SVC from sklearn.model_selection import train_test_split plt.close("all") iris=datasets.load_iris() X=iris["data"][50:150, (2, 3)] Y=iris["target"][50:150] scaler=StandardScaler() scaler.fit(X) X_std=scaler.transform(X) [X_tr..
2020.09.20 -
[머신러닝] Kerner Trick & Lagrangue Multiplier
import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn import datasets from sklearn.preprocessing import StandardScaler from sklearn.svm import SVC from sklearn.model_selection import train_test_split plt.close("all") [X, Y]=datasets.make_moons(n_samples=200, shuffle=True, noise=0.2, random_state=15) #[X, Y]=datasets.make_circles(n_samples=200, shuffle=True, noise=0...
2020.09.20 -
[머신러닝] Classification2 - Clustering
import pandas as pd import numpy as np import matplotlib.pylab as plt import scipy as sp import scipy.stats plt.close("all") dfLoad=pd.read_csv('https://sites.google.com/site/vlsicir/ClassificationSample2.txt', sep='\s+') samples=np.array(dfLoad) x=samples[:,0] y=samples[:,1] N=len(x) numK=2 #Initialize categorial distribution pi=np.ones([1, numK])*(1/numK) mx=np.mean(x) my=np.mean(y) sx=np.std(..
2020.09.20 -
[머신러닝] Classification1 - Mixture Model & Clustering
import pandas as pd import numpy as np import matplotlib.pylab as plt plt.close("all") dfLoad=pd.read_csv('https://sites.google.com/site/vlsicir/ClassificationSample.txt', sep='\s+') samples=np.array(dfLoad) x=samples[:,0] y=samples[:,1] N=len(samples) numK=2 f1=plt.figure(1) ax1=f1.add_subplot(111) ax1.plot(x, y, "b.") ax1.set_aspect("equal") mx=np.mean(x) my=np.mean(y) sx=np.std(x) sy=np.std(y..
2020.08.25 -
[머신러닝] k-NN Classification
from sklearn.datasets import load_iris iris=load_iris() from sklearn.model_selection import train_test_split X=iris.data y=iris.target X_train, X_test, y_train, y_test=train_test_split(X, y, test_size=0.4, random_state=42) from sklearn.neighbors import KNeighborsClassifier from sklearn import metrics knn=KNeighborsClassifier(n_neighbors=5) knn.fit(X_train, y_train) y_pred=knn.predict(X_test) sco..
2020.07.26 -
[머신러닝] Logistic Regression
import numpy as np import pandas as pd import matplotlib.pylab as plt dfLoad=pd.read_csv('https://sites.google.com/site/vlsicir/testData_workHour_vs_passFail.txt', sep="\s+"); xxRaw=np.array(dfLoad.values[:,0]) yyRaw=np.array(dfLoad.values[:,1]) plt.plot(xxRaw, yyRaw, "k.") def sigmoid(x): return 1.0/(1+np.exp(-x)) #xxTest=np.linspace(-10, 10, num=101) #plt.plot(xxTest, sigmoid(xxTest), "k-") N=..
2020.07.18