반응형
Notice
Recent Posts
Recent Comments
Link
관리 메뉴

bro's coding

sklearn.kernel 기법 기초 본문

[AI]/python.sklearn

sklearn.kernel 기법 기초

givemebro 2020. 4. 16. 12:10
반응형

https://broscoding.tistory.com/145

 

머신러닝.make_circles 사용하기

import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.datasets import make_circles X,y=make_circles(factor=0.5,noise=0.1) # factor = R2/R1, noise= std) plt.scatter(X[:,..

broscoding.tistory.com

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 make_circles
X,y=make_circles(factor=0.5,noise=0.1) # factor = R2/R1, noise= std)
plt.scatter(X[:,0],X[:,1],c=y)
plt.colorbar()
                 
    

from sklearn.linear_model import LogisticRegression
model=LogisticRegression(C=10000)
model.fit(X,y)
model.score(X,y)
# 0.52

 

import mglearn
mglearn.plots.plot_2d_classification(model,X,y)
mglearn.discrete_scatter(X[:,0],X[:,1],y)

 

r=np.sqrt((X**2).sum(axis=1)).reshape(-1,1)
model=LogisticRegression(C=10000)
model.fit(r,y)

model.score(r,y)
# 1.0

-model.intercept_/model.coef_
# array([[0.72796165]])
반응형
Comments