- Keras Deep Learning Cookbook
- Rajdeep Dua Manpreet Singh Ghotra
- 245字
- 2021-06-10 19:38:54
Putting it all together
We will be using the diabetes dataset from Pima Indians.
This dataset is originally from the National Institute of Diabetes and Digestive and Kidney Diseases. The objective of the dataset is to diagnostically predict whether or not a patient has diabetes, based on certain diagnostic measurements included in the dataset. Several constraints were placed on the selection of these instances from a larger database. In particular, all patients here are females, at least 21 years old, and of Pima Indian heritage. The datasets consist of several medical predictor variables and one target variable, outcome. Predictor variables include the number of pregnancies the patient has had, their BMI, insulin level, age, and so on.
from keras.models import Sequential
from keras.layers import Dense
import numpy
# fix random seed for reproducibility
numpy.random.seed(7)
# load pima indians dataset
dataset = numpy.loadtxt("data/diabetes.csv", delimiter=",", skiprows=1)
# split into input (X) and output (Y) variables
X = dataset[:,0:8]
Y = dataset[:,8]
# create model
model = Sequential()
model.add(Dense(12, input_dim=8, activation='relu'))
model.add(Dense(8, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
# Compile model
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
# Fit the model
model.fit(X, Y, epochs=150, batch_size=10)
# evaluate the model
scores = model.evaluate(X, Y)
print("\n%s: %.2f%%" % (model.metrics_names[1], scores[1]*100))
The dataset shape is (768, 9).
Let's look at the value of the dataset:
Values of X, which is columns 0 to 7:
The value of Y is the 8th column of the dataset, as shown in the following screenshot:
推薦閱讀
- 機器學(xué)習(xí)實戰(zhàn):基于Sophon平臺的機器學(xué)習(xí)理論與實踐
- Mastering Hadoop 3
- 7天精通Dreamweaver CS5網(wǎng)頁設(shè)計與制作
- 精通Windows Vista必讀
- 新手學(xué)電腦快速入門
- 傳感器與物聯(lián)網(wǎng)技術(shù)
- 精通數(shù)據(jù)科學(xué)算法
- MATLAB/Simulink權(quán)威指南:開發(fā)環(huán)境、程序設(shè)計、系統(tǒng)仿真與案例實戰(zhàn)
- Applied Data Visualization with R and ggplot2
- 從零開始學(xué)SQL Server
- Mastering Exploratory Analysis with pandas
- 數(shù)字多媒體技術(shù)基礎(chǔ)
- 未來學(xué)徒:讀懂人工智能飛馳時代
- 工業(yè)機器人集成應(yīng)用
- 空間機器人智能感知技術(shù)