Skip to content

Instantly share code, notes, and snippets.

View merishnaSuwal's full-sized avatar
🎯
Focusing

Merishna S. Suwal merishnaSuwal

🎯
Focusing
View GitHub Profile
# Size of latent (noise) vector to generator
z_dim = 100
# Learning ratess
learning_rate_D = .00005
learning_rate_G = 2e-4
# Batch size
batch_size = 4
# Number of epochs
show_images = 5
# Plot the images from last epoch
data_images = helper.get_batch(glob(os.path.join("./generated_images/epoch_" + str(num_epochs-1) +"/", '*.jpg'))[:show_images], 64, 64, 'RGB')
plt.imshow(helper.images_square_grid(data_images, 'RGB'))
# Renaming the first column as target
dataset = dataset.rename(columns = {dataset.columns[0]:"target"})
# Check the count of data in target
dataset["target"].value_counts()
# mapping the values into binary
dataset["target"] = dataset["target"].map({"negative":0,"hypothyroid":1})
# Displaying the categories in different columns
print("Unique categories in the column 'pregnant'", dataset['pregnant'].unique())
print("Count of categories in the column 'pregnant' \n", dataset["pregnant"].value_counts())
print("\nUnique categories in the column 'T3 measured'", dataset['T3_measured'].unique())
print("Count of categories in the column 'T3 measured' \n", dataset["T3_measured"].value_counts())
print("\nUnique categories in the column 'Gender'", dataset['Gender'].unique())
print("Count of categories in the column 'Gender' \n", dataset["Gender"].value_counts())
# Replacing ? into NaN values
dataset.replace(to_replace='?', inplace=True, value=np.NaN)
# Count the number of null values
dataset.isnull().sum()
# Dropping the TBG column as it contains extremely high number of null values
dataset.drop('TBG', axis = 1, inplace=True)
# Selecting columns with data type as 'object'
columns = dataset.columns[dataset.dtypes.eq('object')]
# Convert to numeric values
dataset[columns] = dataset[columns].apply(pd.to_numeric, errors='coerce')
# Viewing the details
dataset.info()
# Plot the histogram of different features
dataset.hist(figsize = (20,20));
# Replacing null values by mean
dataset['Age'].fillna(dataset['Age'].mean(), inplace = True)
dataset['T4U'].fillna(dataset['T4U'].mean(), inplace = True)
# Replacing null values by median
dataset['TSH'].fillna(dataset['TSH'].mean(), inplace = True)
dataset['T3'].fillna(dataset['T3'].median(), inplace = True)
dataset['TT4'].fillna(dataset['TT4'].median(), inplace = True)
dataset['FTI'].fillna(dataset['FTI'].median(), inplace = True)