본문 바로가기

728x90
반응형
SMALL

머신러닝기초

(5)
[Python] 10. confusion matrix : precision,recall,f1,ROC from sklearn.datasets import make_classification, load_breast_cancer from sklearn.linear_model import LogisticRegression from sklearn.model_selection import train_test_split import pandas as pd import matplotlib.pyplot as plt import numpy as np import seaborn as sns from sklearn.pipeline import make_pipeline from sklearn.preprocessing import StandardScaler from sklearn.preprocessing import OneHo..
[Python] 8. Sigmoid & Logistic import numpy as np import pandas as pd import matplotlib.pyplot as plt import math x = np.array( [1., 2., 3., 4., 5., 6.] ) y = np.array( [ 5., 7., 9., 11., 13., 15.] ) w = 0 b = 0 n = len(x) epochs = 5000 learning_rate = 0.01 for i in range(epochs): hy = w*x + b # w=2, b=3 cost = np.sum((hy-y)**2)/n gradientW = np.sum(2*x*(w*x+b-y))/n gradientB = np.sum(2*1*(w*x+b-y))/n w=w-learning_rate*gradie..
[Python] 6. L1 norm, L2 norm import pandas as pd import numpy as np from numpy import linalg import matplotlib.pyplot as plt import warnings import math warnings.simplefilter('ignore') p = 1 L1 Norm p = 2 L2 Norm 출처 : en.wikipedia.org/wiki/Norm_(mathematics) Norm (mathematics) - Wikipedia Length in a vector space In mathematics, a norm is a function from a real or complex vector space to the nonnegative real numbers that be..
[Python] 1. 선형회귀분석 import pandas as pd import numpy as np import seaborn as sns from sklearn.datasets import load_boston, load_iris from sklearn.linear_model import LinearRegression,Ridge, SGDRegressor # SGDRegressor은 학습 나머지는 공식 from sklearn.neural_network import MLPRegressor # MLPRegressor은 딥러닝 학습 from sklearn.metrics import r2_score # 선형 모델(Linear Models) from sklearn.model_selection import train_test_split impo..
[Python] 4. 회귀 : cost(mse) test, gradient, scipy.stats 예제 import numpy as np import pandas as pd import matplotlib.pyplot as plt import scipy.stats as st cost(MSE) test def cost(x,y,w): c=0 for i in np.arange(len(x)): hx = w*x[i] c = c+(hx-y[i])**2 return c/len(x) x_data = [1,2,3] y_data = [1,2,3] print(cost(x_data,y_data,-1)) print(cost(x_data,y_data,0)) print(cost(x_data,y_data,1)) print(cost(x_data,y_data,2)) print(cost(x_data,y_data,3)) [OUT] : 18...

728x90
반응형
LIST