Download as pdf or txt
Download as pdf or txt
You are on page 1of 35

fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

Fetal health analysis dense Model


In [1]: # importing the dependince
import os
import numpy as np

# Data
import pandas as pd

# Data Visualization
import seaborn as sns
import matplotlib.pyplot as plt

# Data Preprocessing
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import StratifiedShuffleSplit, train_test_

# Model
from keras import Sequential
from keras.layers import Dense, Dropout

# Callbacks
from keras.callbacks import EarlyStopping, ModelCheckpoint

# Model Performance
from sklearn.metrics import accuracy_score, precision_score, recall_sco

Data Collection
In [3]: #loading the dataset in pandas datafram
file_path = 'fetal_health.csv'
data = pd.read_csv(file_path)

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 1 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [4]: #check first five rows of the dataset


data.head()

Out[4]:
baseline
accelerations fetal_movement uterine_contractions light_decelerations severe_dece
value

0 120.0 0.000 0.0 0.000 0.000

1 132.0 0.006 0.0 0.006 0.003

2 133.0 0.003 0.0 0.008 0.003

3 134.0 0.003 0.0 0.008 0.003

4 132.0 0.007 0.0 0.008 0.000

5 rows × 22 columns

In [5]: #check last five rows of the dataset


data.tail()

Out[5]:
baseline
accelerations fetal_movement uterine_contractions light_decelerations severe_d
value

2121 140.0 0.000 0.000 0.007 0.0

2122 140.0 0.001 0.000 0.007 0.0

2123 140.0 0.001 0.000 0.007 0.0

2124 140.0 0.001 0.000 0.006 0.0

2125 142.0 0.002 0.002 0.008 0.0

5 rows × 22 columns

In [6]: #check shape of the dataset


data.shape

Out[6]: (2126, 22)

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 2 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [7]: #check mathamatci realtionship of the dataset


data.describe()

Out[7]:
baseline
accelerations fetal_movement uterine_contractions light_decelerations
value

count 2126.000000 2126.000000 2126.000000 2126.000000 2126.000000

mean 133.303857 0.003178 0.009481 0.004366 0.001889

std 9.840844 0.003866 0.046666 0.002946 0.002960

min 106.000000 0.000000 0.000000 0.000000 0.000000

25% 126.000000 0.000000 0.000000 0.002000 0.000000

50% 133.000000 0.002000 0.000000 0.004000 0.000000

75% 140.000000 0.006000 0.003000 0.007000 0.003000

max 160.000000 0.019000 0.481000 0.015000 0.015000

8 rows × 22 columns

In [8]: #check more infomation of the dataset


data.info()

<class 'pandas.core.frame.DataFrame'>
RangeIndex: 2126 entries, 0 to 2125
Data columns (total 22 columns):
# Column Non-N
ull Count Dtype
--- ------ -----
--------- -----
0 baseline value 2126
non-null float64
1 accelerations 2126
non-null float64
2 fetal_movement 2126
non-null float64
3 uterine_contractions 2126
non-null float64
4 light_decelerations 2126
non-null float64
5 severe_decelerations 2126
non-null float64
6 prolongued_decelerations 2126
non-null float64
7 abnormal_short_term_variability 2126
non-null float64
8 mean_value_of_short_term_variability 2126
non-null float64
9 percentage_of_time_with_abnormal_long_term_variability 2126
non-null float64
10 mean_value_of_long_term_variability 2126
non-null float64
http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 3 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

non-null float64
11 histogram_width 2126
non-null float64
12 histogram_min 2126
non-null float64
13 histogram_max 2126
non-null float64
14 histogram_number_of_peaks 2126
non-null float64
15 histogram_number_of_zeroes 2126
non-null float64
16 histogram_mode 2126
non-null float64
17 histogram_mean 2126
non-null float64
18 histogram_median 2126
non-null float64
19 histogram_variance 2126
non-null float64
20 histogram_tendency 2126
non-null float64
21 fetal_health 2126
non-null float64
dtypes: float64(22)
memory usage: 365.5 KB

In [10]: #check missing values of the dataset


data.isnull().sum()

Out[10]: baseline value 0


accelerations 0
fetal_movement 0
uterine_contractions 0
light_decelerations 0
severe_decelerations 0
prolongued_decelerations 0
abnormal_short_term_variability 0
mean_value_of_short_term_variability 0
percentage_of_time_with_abnormal_long_term_variability 0
mean_value_of_long_term_variability 0
histogram_width 0
histogram_min 0
histogram_max 0
histogram_number_of_peaks 0
histogram_number_of_zeroes 0
histogram_mode 0
histogram_mean 0
histogram_median 0
histogram_variance 0
histogram_tendency 0
fetal_health 0
dtype: int64

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 4 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

Data Visualization
In [13]: for i in data.columns:
plt.figure()
plt.hist(data[i])

In [17]: for i in data.columns:


sns.distplot(data[i])
tributions.py:2619: FutureWarning: `distplot` is a deprecated func
tion and will be removed in a future version. Please adapt your co
de to use either `displot` (a figure-level function with similar f
lexibility) or `histplot` (an axes-level function for histograms).
warnings.warn(msg, FutureWarning)
/Users/vikky/opt/anaconda3/lib/python3.9/site-packages/seaborn/dis
tributions.py:2619: FutureWarning: `distplot` is a deprecated func
tion and will be removed in a future version. Please adapt your co
de to use either `displot` (a figure-level function with similar f
lexibility) or `histplot` (an axes-level function for histograms).
warnings.warn(msg, FutureWarning)
/Users/vikky/opt/anaconda3/lib/python3.9/site-packages/seaborn/dis
tributions.py:2619: FutureWarning: `distplot` is a deprecated func
tion and will be removed in a future version. Please adapt your co
de to use either `displot` (a figure-level function with similar f
lexibility) or `histplot` (an axes-level function for histograms).
warnings.warn(msg, FutureWarning)
/Users/vikky/opt/anaconda3/lib/python3.9/site-packages/seaborn/dis
tributions.py:2619: FutureWarning: `distplot` is a deprecated func
tion and will be removed in a future version. Please adapt your co

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 5 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

Let's have a look a the Correlation among Features.

In [11]: corr = data.corr()

plt.figure(figsize=(15,10))
sns.heatmap(corr, annot=True)
plt.show()

Their are many relations let's have a look at the most strongest ones.

In [214]: def search_strong_relation(value):


if value >= 0.7:
return value
elif value<=-0.7:
return value
else:
return 0

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 6 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [215]: corr = data.corr()


corr = (corr>=0.7).astype('int')

plt.figure(figsize=(15,10))
plt.title("Strong Positive Relation")
sns.heatmap(corr, annot=True)
plt.show()

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 7 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [216]: corr = data.corr()


corr = (corr<-0.7).astype('int')

plt.figure(figsize=(15,10))
plt.title("Strong Negative Relation")
sns.heatmap(corr, annot=True)
plt.show()

You can change the Threshold Values if you want to, but I consider that the relation
should have a score >0.7(70%). Let's plot these relations. Before plotting the relations
we will also plot the individual column.

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 8 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [217]: plt.figure(figsize=(10,8))
sns.histplot(data['histogram_mode'], kde=True)
plt.show()

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 9 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [218]: sns.catplot(
data=data,
y='histogram_mode',
x='fetal_health',
kind='box',
aspect=1.5
)
plt.show()

The values are concentrated between 130 - 150.

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 10 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [219]: plt.figure(figsize=(10,8))
sns.histplot(data['baseline value'], kde=True)
plt.show()

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 11 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [220]: sns.catplot(
data=data,
y='baseline value',
x='fetal_health',
kind='box',
aspect=1.5
)
plt.show()

Here, the values are concentrated between 120 - 145.

Theya had a positive relation, let's see

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 12 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [221]: plt.figure(figsize=(10,8))
sns.scatterplot(
data=data,
x='histogram_mode',
y='baseline value',
hue='fetal_health'
)
plt.show()

Clearly they have a Positive Linear Relationship, the interesting this is the *class
distribution :

Class 1 and 3 are easily seperable.


But class 2 and 3 are mixed together.

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 13 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [222]: plt.figure(figsize=(10,8))
sns.histplot(data['histogram_mean'], kde=True)
plt.show()

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 14 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [223]: sns.catplot(
data=data,
y='histogram_mean',
x='fetal_health',
kind='box',
aspect=1.5
)
plt.show()

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 15 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [224]: plt.figure(figsize=(10,8))
sns.histplot(data['histogram_median'], kde=True)
plt.show()

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 16 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [225]: sns.catplot(
data=data,
y='histogram_median',
x='fetal_health',
kind='box',
aspect=1.5
)
plt.show()

Both belong to the same distribution that's why the data distribution range is roughly
the same.

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 17 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [226]: plt.figure(figsize=(10,8))
sns.scatterplot(
data=data,
x='histogram_mean',
y='baseline value',
hue='fetal_health'
)
plt.show()

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 18 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [227]: plt.figure(figsize=(10,8))
sns.scatterplot(
data=data,
x='histogram_median',
y='baseline value',
hue='fetal_health'
)
plt.show()

This distribution is much more the same.

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 19 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [228]: plt.figure(figsize=(10,8))
sns.histplot(data['histogram_width'], kde=True)
plt.show()

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 20 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [229]: plt.figure(figsize=(10,8))
sns.histplot(data['histogram_number_of_peaks'], kde=True)
plt.show()

Number of Peaks continuosly decreases.

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 21 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [230]: plt.figure(figsize=(10,8))
sns.scatterplot(
data=data,
x='histogram_number_of_peaks',
y='histogram_width',
hue='fetal_health'
)
plt.show()

The Linear Relation is clear but the classes are not clearly seperable.

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 22 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [231]: sns.catplot(
data=data,
y='histogram_width',
x='fetal_health',
kind='box',
aspect=1.5
)
plt.show()

This confirms that the classes are overlapping each other. The overlapping is high, this
variable alone cannot decide the class.

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 23 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [232]: plt.figure(figsize=(10,8))
sns.scatterplot(
data=data,
x='histogram_mode',
y='histogram_mean',
hue='fetal_health'
)
plt.show()

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 24 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [233]: plt.figure(figsize=(10,8))
sns.scatterplot(
data=data,
x='histogram_mode',
y='histogram_median',
hue='fetal_health'
)
plt.show()

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 25 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [234]: plt.figure(figsize=(10,8))
sns.scatterplot(
data=data,
x='histogram_median',
y='histogram_mean',
hue='fetal_health'
)
plt.show()

This had to be the case after-all they are statically related. The classes are seperable,
thus it can be easy for the model to detect the hidden pattern.

It's time for Negative Relations.

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 26 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [235]: plt.figure(figsize=(10,8))
sns.histplot(data['histogram_min'], kde=True)
plt.show()

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 27 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [236]: sns.catplot(
data=data,
y='histogram_min',
x='fetal_health',
kind='box',
aspect=1.5
)
plt.show()

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 28 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [237]: plt.figure(figsize=(10,8))
sns.scatterplot(
data=data,
x='histogram_min',
y='histogram_width',
hue='fetal_health'
)
plt.show()

The Negative Relationship can easily be noted, however the classes are not easily
seperable. We are done with data understanding it's time for the model to understand
the data. But before doing that, we need to prepared the data.

Data Splitting
The Features are not on the same scale, let's bring them all to one scale.

In [238]: y = data.pop('fetal_health') - 1 # To bring values from 1-3 to 0-2


X = data

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 29 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [239]: scaler = StandardScaler()


X_scaled = scaler.fit_transform(X) # Return A Numpy Array

Let's split the data into training, testing and validation data. To maintain the Class
Distribution, we will using Stratified Splitting.

In [240]: splitter = StratifiedShuffleSplit(n_splits=3)


for train_ids, test_ids in splitter.split(X_scaled, y):
X_train_full, y_train_full = X_scaled[train_ids], y[train_ids]
X_test, y_test = X_scaled[test_ids], y[test_ids]

In [241]: X_train, X_valid, y_train, y_valid = train_test_split(X_train_full,

Feature Selection
This is an optional step, as we will be using a Dense Model it will automatically perform
Feature Selection, but if you are using a Machine Learning Model you can use it.

In [242]: from sklearn.ensemble import RandomForestClassifier

In [243]: rfc = RandomForestClassifier()


rfc.fit(X_train, y_train)
feature_imps = rfc.feature_importances_
feature_names = data.columns

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 30 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [244]: plt.figure(figsize=(10,8))
sns.barplot(
x=feature_names,
y=feature_imps
)
plt.axhline(np.mean(feature_imps), color='k', linestyle="--", alpha
plt.xticks(rotation=90)
plt.legend()
plt.show()

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 31 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

Many features are below the Mean Importance, you can drop them it will no affect the
model much. Dense Models can do this on their own, so we don't have to worry about
it. You can do multiple runs and get the mean, that will be a Robust Prediction but it
will generally be the same.

Dense Model
In [325]: name = "dense"
# Model Architecture
model = Sequential([
Dense(32, activation='relu', kernel_initializer='he_normal'),
Dense(64, activation='relu', kernel_initializer='he_normal'),
Dense(128, activation='relu', kernel_initializer='he_normal'),
Dropout(0.2),
Dense(3, activation='softmax'),
], name=name)

# Compile
model.compile(
loss='sparse_categorical_crossentropy',
optimizer='adam',
metrics=['accuracy']
)

# Callbacks
cbs = [EarlyStopping(patience=3, restore_best_weights=True), ModelCheck

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 32 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

In [326]: model.fit(X_train, y_train, validation_data=(X_valid, y_valid), epochs

Epoch 1/15
48/48 [==============================] - 1s 7ms/step - loss: 0.627
3 - accuracy: 0.7876 - val_loss: 0.3977 - val_accuracy: 0.8590
Epoch 2/15
48/48 [==============================] - 0s 3ms/step - loss: 0.380
6 - accuracy: 0.8497 - val_loss: 0.3139 - val_accuracy: 0.8721
Epoch 3/15
48/48 [==============================] - 0s 3ms/step - loss: 0.313
9 - accuracy: 0.8778 - val_loss: 0.2940 - val_accuracy: 0.8825
Epoch 4/15
48/48 [==============================] - 0s 3ms/step - loss: 0.283
3 - accuracy: 0.8869 - val_loss: 0.2761 - val_accuracy: 0.8825
Epoch 5/15
48/48 [==============================] - 0s 3ms/step - loss: 0.245
8 - accuracy: 0.8987 - val_loss: 0.2667 - val_accuracy: 0.8930
Epoch 6/15
48/48 [==============================] - 0s 3ms/step - loss: 0.224
5 - accuracy: 0.9033 - val_loss: 0.2658 - val_accuracy: 0.8956
Epoch 7/15
48/48 [==============================] - 0s 5ms/step - loss: 0.219
1 - accuracy: 0.9111 - val_loss: 0.2634 - val_accuracy: 0.9008
Epoch 8/15
48/48 [==============================] - 0s 3ms/step - loss: 0.203
4 - accuracy: 0.9255 - val_loss: 0.2414 - val_accuracy: 0.9034
Epoch 9/15
48/48 [==============================] - 0s 3ms/step - loss: 0.194
6 - accuracy: 0.9255 - val_loss: 0.2468 - val_accuracy: 0.9060
Epoch 10/15
48/48 [==============================] - 0s 3ms/step - loss: 0.182
9 - accuracy: 0.9261 - val_loss: 0.2375 - val_accuracy: 0.9034
Epoch 11/15
48/48 [==============================] - 0s 3ms/step - loss: 0.171
2 - accuracy: 0.9294 - val_loss: 0.2466 - val_accuracy: 0.8982
Epoch 12/15
48/48 [==============================] - 0s 3ms/step - loss: 0.158
2 - accuracy: 0.9320 - val_loss: 0.2364 - val_accuracy: 0.9086
Epoch 13/15
48/48 [==============================] - 0s 3ms/step - loss: 0.145
5 - accuracy: 0.9418 - val_loss: 0.2488 - val_accuracy: 0.9060
Epoch 14/15
48/48 [==============================] - 0s 3ms/step - loss: 0.154
1 - accuracy: 0.9366 - val_loss: 0.2660 - val_accuracy: 0.8956
Epoch 15/15
48/48 [==============================] - 0s 3ms/step - loss: 0.144
5 - accuracy: 0.9412 - val_loss: 0.2246 - val_accuracy: 0.9138

Out[326]: <keras.callbacks.History at 0x7fa7cc6ed190>

Evaluation
http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 33 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

The training is promising, let's check model's performance on the data ir has never seen
before.

In [327]: model.evaluate(X_test, y_test)

7/7 [==============================] - 0s 2ms/step - loss: 0.2408


- accuracy: 0.9202

Out[327]: [0.24079568684101105, 0.920187771320343]

Performance Analysis
Let's see model's performance on various metrics.

In [328]: # Make Prediction


pred = np.argmax(model.predict(X_test), axis=1)

# Calculate Score
acc_score = accuracy_score(y_test, pred)
pre_score = precision_score(y_test, pred, average='macro')
re_score = recall_score(y_test, pred, average='macro')
f_score = f1_score(y_test, pred, average='macro')

# Show Prediction
print("Accuracy Score : {:.6}".format(acc_score))
print("Precision Score : {:.6}".format(pre_score))
print("Recall Score : {:.6}".format(re_score))
print("f1 Score : {:.6}".format(f_score))

Accuracy Score : 0.920188


Precision Score : 0.857048
Recall Score : 0.849928
f1 Score : 0.853406

In [331]: print(classification_report(y_test, pred))

precision recall f1-score support

0.0 0.95 0.96 0.95 166


1.0 0.79 0.76 0.77 29
2.0 0.83 0.83 0.83 18

accuracy 0.92 213


macro avg 0.86 0.85 0.85 213
weighted avg 0.92 0.92 0.92 213

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 34 of 35
fetal-health-analysis-dense-model-acc-94 - Jupyter Notebook 28/02/23, 11:07 PM

http://localhost:8888/notebooks/Downloads/fetal-health-analysis-dense-model-acc-94.ipynb#Data Page 35 of 35

You might also like