As an AI language model, I do not have the capability to create Google Collab notebooks and run code. However, I can provide an outline of the steps and code snippets needed to perform the tasks you have outlined.
- Import the necessary libraries:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import tensorflow as tf
from tensorflow.keras.layers import Dense, Dropout, Input
from tensorflow.keras.models import Model
- Load the dataset:
url = "https://www.kaggle.com/datasets/muthuj7/weather-dataset"
dataset = pd.read_csv(url)
- Prepare the data:
X_train = dataset.iloc[:, :-1].values
y_train = dataset.iloc[:, -1].values
- Define the model:
inputs = Input(shape=(X_train.shape[1],))
x = Dense(128, activation='relu')(inputs)
x = Dropout(0.2)(x)
x = Dense(64, activation='relu')(x)
x = Dropout(0.2)(x)
outputs = Dense(1, activation='sigmoid')(x)
model = Model(inputs=inputs, outputs=outputs)
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
- Train the model:
history = model.fit(X_train, y_train, epochs=10, batch_size=32, validation_split=0.2)
- Visualize the results:
# Training loss and accuracy
plt.plot(history.history['loss'], label='Training Loss')
plt.plot(history.history['accuracy'], label='Training Accuracy')
plt.legend()
plt.show()
# Test accuracy
plt.plot(history.history['val_accuracy'], label='Test Accuracy')
plt.legend()
plt.show()
- Change the loss function and re-train the model:
model.compile(optimizer='adam', loss='mean_squared_error', metrics=['accuracy'])
history = model.fit(X_train, y_train, epochs=10, batch_size=32, validation_split=0.2)
- Change the learning rate and re-train the model:
optimizer = tf.keras.optimizers.Adam(learning_rate=0.1)
model.compile(optimizer=optimizer, loss='binary_crossentropy', metrics=['accuracy'])
history = model.fit(X_train, y_train, epochs=10, batch_size=32, validation_split=0.2)
optimizer = tf.keras.optimizers.Adam(learning_rate=0.01)
model.compile(optimizer=optimizer, loss='binary_crossentropy', metrics=['accuracy'])
history = model.fit(X_train, y_train, epochs=10, batch_size=32, validation_split=0.2)
optimizer = tf.keras.optimizers.Adam(learning_rate=0.001)
model.compile(optimizer=optimizer, loss='binary_crossentropy', metrics=['accuracy'])
history = model.fit(X_train, y_train, epochs=10, batch_size=32, validation_split=0.2)
optimizer = tf.keras.optimizers.Adam(learning_rate=0.0001)
model.compile(optimizer=optimizer, loss='binary_crossentropy', metrics=['accuracy'])
history = model.fit(X_train, y_train, epochs=10, batch_size=32, validation_split=0.2)
- Change the batch size and re-train the model:
history = model.fit(X_train, y_train, epochs=10, batch_size=8, validation_split=0.2)
history = model.fit(X_train, y_train, epochs=10, batch_size=16, validation_split=0.2)
history = model.fit(X_train, y_train, epochs=10, batch_size=32, validation_split=0.2)
history = model.fit(X_train, y_train, epochs=10, batch_size=64, validation_split=0.2)
history = model.fit(X_train, y_train, epochs=10, batch_size=128, validation_split=0.2)
- Visualize the predicted labels:
y_pred = model.predict(X_train[:100])
plt.scatter(range(100), y_pred, label='Predicted')
plt.scatter(range(100), y_train[:100], label='Actual')
plt.legend()
plt.show()
Overall, the full code would be a combination of the above snippets, but the exact details and adjustments may depend on the specific dataset and requirements of the research.