사이킷런의 linear_regression 사용하기 위한 패키지 importimport numpy as npimport matplotlib.pyplot as pltfrom sklearn import linear_modelfrom sklearn.datasets import load_diabetes 비만 데이터 LoadX, y = load_diabetes(return_X_y=True)print(X[:5])print(X.shape, y.shape) [[ 0.03807591 0.05068012 0.06169621 0.02187235 -0.0442235 -0.03482076 -0.04340085 -0.00259226 0.01990842 -0.01764613][-0.00188202 -0.04464164 -0.051..
분류 전체보기
패키지가 이용 방법이 KNN과 거의 비슷하다. """Naive Bayes 알고리즘Naive Bayes 분류기(Classifier)를 사용한 iris 품종 분류""" from sklearn import datasetsfrom sklearn.metrics import confusion_matrix, classification_reportfrom sklearn.model_selection import train_test_splitfrom sklearn.naive_bayes import GaussianNBfrom sklearn.preprocessing import StandardScaler iris = datasets.load_iris()print(type(iris))# Bunch 클래스: {'data': []..
Python 67_ kNN 직접 구현하기 >> 에 이어서 작업해주시면 됩니다. # 데이터 프레임을 이용해서 각 특성(변수)들과 Class(레이블)과의 관계 그래프iris_by_class = iris.groupby(by='Class')for name, group in iris_by_class: # print(name, len(group)) plt.scatter(group['sepal_length'], group['sepal_width'], label=name)plt.legend()plt.xlabel('sepal_length')plt.ylabel('sepal_width')plt.show() for name, group in iris_by_class: # print(name, len(group)) plt.sc..
"""scikit-learn 패키지를 이용한 kNN(k Nearest Neighbor: 최근접 이웃)"""import numpy as npimport pandas as pdimport matplotlib.pyplot as pltfrom sklearn.model_selection import train_test_splitfrom sklearn.neighbors import KNeighborsClassifierfrom sklearn.preprocessing import StandardScalerfrom sklearn.metrics import confusion_matrix, classification_report # 1. 데이터 준비col_names = ['sepal-length', 'sepal-width'..