1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Scikit-learn Diabetesデータセットを使ってみる

Last updated at Posted at 2021-04-03

scikit-learnに、糖尿病患者のデータベースというのがある。

重回帰用のデータである。
ロードしてみる。。。

データはdataとtargetに分かれる。

diabetes.data
diabetes.target


import numpy as np
import pandas as pd

from sklearn.datasets import load_diabetes

# X_feature_names = ['age', 'gender', 'body mass index', 'average blood pressure','bl_0','bl_1','bl_2','bl_3','bl_4','bl_5']

df = pd.DataFrame(diabetes.data, columns=("age", "gender", "boby mass index", "average blood pressure", "tc", "ldl", "hdl", "tch", "ltg", "glu"))
df['target'] = diabetes.target

df.head()

data.targetだが、おそらくこれは血圧だと思われる。

image.png

サンプリングして表示してみる。。


import matplotlib.pyplot as plt
plt.figure()
plt.subplot(211)
plt.plot(X)
plt.subplot(212)

ダウンロード (4).png

サンプリング(ヒストグラム)して表示してみる。。


bins = 50*np.arange(8)
binned_y = np.digitize(y, bins)

from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2,stratify=binned_y)

ダウンロード (5).png

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?