일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- C언어
- CES 2O21 참가
- 머신러닝
- cudnn
- vscode
- inorder
- 대이터
- tensorflow
- 데이터전문기관
- 웹 용어
- web
- java역사
- 자료구조
- classification
- bccard
- discrete_scatter
- mglearn
- web 용어
- 재귀함수
- html
- web 개발
- broscoding
- web 사진
- KNeighborsClassifier
- Keras
- postorder
- paragraph
- pycharm
- 결합전문기관
- CES 2O21 참여
- Today
- Total
목록[AI]/python.sklearn (95)
bro's coding
StandardScaler : 각 속성들을 평균이 0, 표준편차가 1이 되도록 조정 MinMaxScaler : 최소값이 0, 최대값이 1이 되도록 비율을 조정 Normalizer : 속성(열)이 아니라 각각의 샘플(행)의 유클리디안 길이가 1이 되도록 조정 (지름이 1인 구 표면에 각각의 샘플을 투영) import numpy as np import pandas as pd import matplotlib.pyplot as plt X = np.arange(12).reshape(4,3) X ''' array([[ 0, 1, 2], [ 3, 4, 5], [ 6, 7, 8], [ 9, 10, 11]]) ''' # 각 속성(열)의 범위를 0~1 로 제한하고 싶을 경우 X_max = X.max(axis=0) X_mi..
https://broscoding.tistory.com/160 머신러닝.RandomForestClassifier.기초 import numpy as np import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from sklearn.datasets import load_breast_cancer cancer=load_breast_cancer() X_train,X_test,y_t.. broscoding.tistory.com model = RandomForestClassifier(n_estimators=100, max_depth=5) # default is 10 model.fit(cancer.data, cancer...
https://broscoding.tistory.com/160 머신러닝.RandomForestClassifier.기초 import numpy as np import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from sklearn.datasets import load_breast_cancer cancer=load_breast_cancer() X_train,X_test,y_t.. broscoding.tistory.com X=cancer.data[:,[0,1]] y=cancer.target X_train,X_test,y_train,y_test=train_test_split(X,y) model=RandomFores..
import numpy as np import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from sklearn.datasets import load_breast_cancer cancer=load_breast_cancer() X_train,X_test,y_train,y_test=train_test_split(cancer.data,cancer.target) from sklearn.ensemble import RandomForestClassifier model=RandomForestClassifier(n_estimators=100) model.fit(X_train,y_train) train_score=model...
1. 아나콘다에서 [pip install graphviz] 2. http://www.graphviz.org/ Graphviz - Graph Visualization Software Welcome to Graphviz Please join the brand new (March 2020) Graphviz forum to ask questions and discuss Graphviz. What is Graphviz? Graphviz is open source graph visualization software. Graph visualization is a way of representing structural information as www.graphviz.org 위 사이트에서 down load 에 가서 프..
import numpy as np import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from sklearn.datasets import load_breast_cancer cancer =load_breast_cancer() from sklearn.tree import DecisionTreeClassifier X_train,X_test,y_train,y_test=train_test_split(cancer.data,cancer.target) score_train=[] score_test=[] for depth in range(1,10): model=DecisionTreeClassifier(max_depth=d..
linear_model.LinearRegression. import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from sklearn.datasets import load_breast_cancer # data 준비 cancer =load_breast_cancer() # column 컨트롤러 col1=0 col2=6 # visualization plt.scatter(cancer.data[:,col1],cancer.data[:,col2],c=cancer.target,alpha=0.3) # 선형 회귀선 from sklearn.linear_mode..
from sklearn.linear_model import LinearRegression, Ridge, Lasso from sklearn.linear_model import LinearRegression, Ridge, Lasso from sklearn.datasets import load_iris iris = load_iris() X = iris.data[:, [0]] y = iris.data[:, 2] plt.scatter(X, y) plt.axis('equal') model = LinearRegression() model.fit(X, y) w = model.coef_[0] b = model.intercept_ print(model.score(X, y), model.coef_) # 0.759955310..
alphas = [10, 1, 0.1, 0.01, 0.001, 0.0001] train_scores = [] test_scores = [] ws = [] for alpha in alphas: lasso = Lasso(alpha=alpha) lasso.fit(X_train, y_train) ws.append(lasso.coef_) s1 = lasso.score(X_train, y_train) s2 = lasso.score(X_test, y_test) train_scores.append(s1) test_scores.append(s2) display(train_scores, test_scores, ws) [0.0, 0.40725895623295394, 0.900745787336254, 0.92796316315..
릿지(Ridge) 와 라쏘(Lasso) 는 오차값에 규제(Regulation) 항 또는 벌점(Penalty) 항을 추가해서, 좀 더 단순화된 모델 또는 일반화된 모델을 제공하는 방법이다. import numpy as np import matplotlib.pyplot as plt # graph size fig=plt.figure(figsize=[12,6]) # -10부터 10까지 100개로 분할함 rng=np.linspace(-10,10,100) # mse mse=(0.5*(rng-3))**2+30 # ridge's alpha = 1 l2=rng**2 # rasso's alpha = 5 l1=5*np.abs(rng) # ridge ridge=mse+l2 # lasso lasso=mse+l1 # visual..