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
import numpy as np # Import the necessary packages. | |
import pandas as pd | |
epsilon = list(range(4)) # Initialisation of epsilon which would store cost function for each value of 'k' after final iteration. | |
for k in range(2,6): # Number of clusters | |
cluster = pd.read_csv('/kaggle/input/clustering/k-means clustering.csv') # Read data file into 'cluster' | |
rows = cluster.shape[0] # 'rows' contains the total number of rows in cluster data. |
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
k = list(range(2,6)) # Range of 'k' | |
plt.figure(figsize=(20,10)) # Size of figure is adjusted. | |
plt.xticks(fontsize=20) # Size of number labels on x-axis is adjusted. | |
plt.yticks(fontsize=20) # Size of number labels on y-axis is adjusted. | |
plt.plot(k,epsilon,'go--', linewidth=1.5, markersize=4) # Graph is plotted. | |
plt.xlabel('Value of k',fontsize = 25) # x-axis is labelled. | |
plt.ylabel('Value of Epsilon',fontsize = 25) # y-axis is labelled. |
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
# Necessary packages are imported. | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
# Loading of data set into 'cluster'. | |
cluster = pd.read_csv('k-means clustering.csv') | |
k = 3 # Number of clusters |
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
import numpy as np # Import the necessary packages. | |
import pandas as pd | |
epsilon = list(range(4)) # Initialisation of epsilon which would store cost function for each value of 'k' after final iteration. | |
for k in range(2,6): # Number of clusters | |
cluster = pd.read_csv('k-means clustering.csv') # Read data file into 'cluster' | |
rows = cluster.shape[0] # 'rows' contains the total number of rows in cluster data. |
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
from keras.layers import Dropout | |
# Defining the model | |
def create_model(learning_rate,dropout_rate): | |
model = Sequential() | |
model.add(Dense(8,input_dim = 8,kernel_initializer = 'normal',activation = 'relu')) | |
model.add(Dropout(dropout_rate)) | |
model.add(Dense(4,input_dim = 8,kernel_initializer = 'normal',activation = 'relu')) | |
model.add(Dropout(dropout_rate)) |
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
# Defining the model | |
def create_model(activation_function,init): | |
model = Sequential() | |
model.add(Dense(8,input_dim = 8,kernel_initializer = init,activation = activation_function)) | |
model.add(Dropout(0.1)) | |
model.add(Dense(4,input_dim = 8,kernel_initializer = init,activation = activation_function)) | |
model.add(Dropout(0.1)) | |
model.add(Dense(1,activation = 'sigmoid')) | |
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
# Defining the model | |
def create_model(neuron1,neuron2): | |
model = Sequential() | |
model.add(Dense(neuron1,input_dim = 8,kernel_initializer = 'uniform',activation = 'tanh')) | |
model.add(Dropout(0.1)) | |
model.add(Dense(neuron2,input_dim = neuron1,kernel_initializer = 'uniform',activation = 'tanh')) | |
model.add(Dropout(0.1)) | |
model.add(Dense(1,activation = 'sigmoid')) | |
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
from sklearn.metrics import classification_report, accuracy_score | |
# Defining the model | |
def create_model(): | |
model = Sequential() | |
model.add(Dense(16,input_dim = 8,kernel_initializer = 'uniform',activation = 'tanh')) | |
model.add(Dropout(0.1)) | |
model.add(Dense(4,input_dim = 16,kernel_initializer = 'uniform',activation = 'tanh')) | |
model.add(Dropout(0.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
def create_model(learning_rate,dropout_rate,activation_function,init,neuron1,neuron2): | |
model = Sequential() | |
model.add(Dense(neuron1,input_dim = 8,kernel_initializer = init,activation = activation_function)) | |
model.add(Dropout(dropout_rate)) | |
model.add(Dense(neuron2,input_dim = neuron1,kernel_initializer = init,activation = activation_function)) | |
model.add(Dropout(dropout_rate)) | |
model.add(Dense(1,activation = 'sigmoid')) | |
adam = Adam(lr = learning_rate) | |
model.compile(loss = 'binary_crossentropy',optimizer = adam,metrics = ['accuracy']) |
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
# Initialize the dataframe 'numerical_nucleotide' of shape (106,(57*4)) | |
numerical_nucleotide = pd.DataFrame(np.random.randn(106,(57*4))) | |
# Define the dictionary 'key1' | |
key1 = {'a' : '1000','c' : '0100','g' : '0010','t' : '0001'} | |
# Assign values to 'numerical_nucleotide' | |
for i in range(nucleotide_sequence.shape[0]): |
OlderNewer