This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dropping the TBG column as it contains extremely high number of null values | |
dataset.drop('TBG', axis = 1, inplace=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Replacing ? into NaN values | |
dataset.replace(to_replace='?', inplace=True, value=np.NaN) | |
# Count the number of null values | |
dataset.isnull().sum() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mapping the values into binary | |
dataset["target"] = dataset["target"].map({"negative":0,"hypothyroid":1}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gan_model_inputs(real_dim, z_dim): | |
""" | |
Creates the inputs for the model. | |
Arguments: | |
---------- | |
:param real_dim: tuple containing width, height and channels | |
:param z_dim: The dimension of Z | |
---------- | |
Returns: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gan_model_loss(input_real, input_z, output_channel_dim, alpha): | |
""" | |
Get the loss for the discriminator and generator | |
Arguments: | |
--------- | |
:param input_real: Images from the real dataset | |
:param input_z: Z input | |
:param out_channel_dim: The number of channels in the output image | |
--------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gan_model_optimizers(d_loss, g_loss, disc_lr, gen_lr, beta1): | |
""" | |
Get optimization operations | |
Arguments: | |
---------- | |
:param d_loss: Discriminator loss Tensor | |
:param g_loss: Generator loss Tensor | |
:param disc_lr: Placeholder for Learning Rate for discriminator | |
:param gen_lr: Placeholder for Learning Rate for generator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generator_output(sess, n_images, input_z, output_channel_dim, image_mode, image_path): | |
""" | |
Save output from the generator. | |
Arguments: | |
---------- | |
:param sess: TensorFlow session | |
:param n_images: Number of Images to display | |
:param input_z: Input Z Tensor (noise vector) | |
:param output_channel_dim: The number of channels in the output image |