You will train, validate and test your ANN on regression data of a Combined Cycle Power…
- User
You will train, validate and test your ANN on regression data of a Combined Cycle Power Plant Dataset given in http://archive.ics.uci.edu/ml/datasets/Combined+Cycle+Power+Plant which belongs to the UCI Machine Learning Data Repository. The given data consists of more than 9 thousand rows of 4 input variables and 1 output variable. In the dataset the variables are well defined and you don’t really need any knowledge of the underlying domain physics; just be aware that the relationships between the inputs and outputs are quite complicated; hence successful (i.e. highly accurate) acquisition of the same by your ANN will demonstrate the capability of these machine learning mechanisms to capture complicated functional relationships that characterize a process and are encapsulated within data generated by the running process. Building up the software from scratch (except for available Python libraries like numpy, matplotlib, etc., do not use Deep Learning libraries for this assignment) to productively-operating levels will also give you the confidence of having mastered the nuts and bolts of this complex machine learning mechanism; in future you will be using high-level libraries but not as a semi-ignoramus just using these like black boxes. Importantly, if your self-built software is indeed generating good (i.e. accurate) results at efficient speeds – it is like your property which you can use for multiple applications in diverse domains! Regarding each of the crucial ANN development aspects, you are to broadly follow the approaches outlined below: Guidelines:
- Data Splitting: Ideally, split the available data into 72 : 18 : 10 for training : validation : testing. While your training and validation data should be interspersed all across your given data set, your test data should be one or two continuous chunks from one or the other end of your data set. Your program should be written such that every epoch of training is followed by a run over all the validation data samples so that you get both the training error and validation error at every epoch. You may wonder why the numbers 72 : 18 – reason is that you should first pull out the 10% (testing) chunk, and what remains you can easily split into 80 : 20, i.e. create a loop where index divisible by 5 is sent to “validation data” while all else is sent to “training data”. Note you can also use Python libraries for performing this task.
- ANN architecture: Apart from the fact that the number of nodes in the input layer equals the number of input variables, and correspondingly for output layer, and that there has to be at least one hidden layer, the rest is your creation. Just remember one rule of thumb, the number of unknowns should not be more than half the number of training data samples. So one hidden layer will have some number of neurons, and if you increase the number of hidden layers then the nodes per layer will reduce by the above rule.
- Assistant
- User
the input is an ODS file containing 5 sheet with 5 columns and 9600 rows each, generate a complete python code to solve the problem
- Assistant
- User
generate complete code but first give me half the code and give the other half when give the prompt "continue"
- Assistant
Certainly, let's get started with the first half of the Python code:
import pandas as pd import numpy as np from sklearn.model_selection import train_test_split # Step 1: Reading the ODS File def read_ods(filename): sheets = pd.read_excel(filename, engine='odf', sheet_name=None) dataframes = [sheet for sheet in sheets.values()] return dataframes filename = 'your_dataset.ods' dfs = read_ods(filename) # Step 2: Data Preparation df = pd.concat(dfs) def normalize_data(df): for column in df.columns[:-1]: # Assuming the last column is the target max_val = df[column].max() min_val = df[column].min() df[column] = (2 * (df[column] - min_val) / (max_val - min_val)) - 1 return df df = normalize_data(df) X = df[df.columns[:-1]].values y = df[df.columns[-1]].values.reshape(-1, 1) X_train, X_temp, y_train, y_temp = train_test_split(X, y, test_size=0.28, random_state=42) X_val, X_test, y_val, y_test = train_test_split(X_temp, y_temp, test_size=(10/28), random_state=42) # Step 3: ANN Implementation (Part 1) class SimpleANN: def __init__(self, input_size, hidden_size, output_size): self.W1 = np.random.randn(input_size, hidden_size) * 0.1 self.W2 = np.random.randn(hidden_size, output_size) * 0.1 def forward(self, X): self.z2 = np.dot(X, self.W1) self.a2 = np.tanh(self.z2) # Hidden layer activation self.z3 = np.dot(self.a2, self.W2) y_hat = np.tanh(self.z3) # Output layer activation return y_hat - User
continue
- Assistant