Skip to content

Commit 7383429

Browse files
authored
Added show_missing and drop_missing methods
1 parent 8475c6e commit 7383429

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

utils/NN_trainer.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ class Trainer(object):
55
Requirements: Numpy, Pandas, Matplotlib, Scikit-learn, Keras (TensorFlow)
66
"""
77

8-
import numpy as np
9-
import matplotlib.pyplot as plt
10-
import pandas as pd
11-
128
def __init__(self):
139
"""
1410
Initialization
@@ -113,6 +109,23 @@ def drop_static_cols(self):
113109
df2 = df1
114110
self.df = df2
115111

112+
def show_missing(self):
113+
"""
114+
Shows how many missing values are there
115+
"""
116+
print("The following table shows the number of missing values in the dataset (by the features)\n")
117+
print(self.df.isna().sum())
118+
119+
def drop_missing(self):
120+
"""
121+
Drops rows of data which have missing values.
122+
This method does not return a DataFrame but modifies the internal DataFrame.
123+
"""
124+
df1 = self.df
125+
df2 = df1.dropna(axis=0)
126+
127+
self.df = df2
128+
116129
def set_outputs(self, output_cols=None):
117130
"""
118131
Sets the list the output columns (to be modeled)
@@ -550,7 +563,11 @@ def model_in_plain_english(self):
550563
print("No model has been built yet!")
551564
return None
552565

553-
d = self.model.get_config()['layers']
566+
config = self.model.get_config()
567+
if type(config)==dict:
568+
d = config['layers']
569+
else:
570+
d = config
554571
num_layers = len(d)
555572
total_param = self.model.count_params()
556573
print("Here is the model description")

0 commit comments

Comments
 (0)