(100 pts) Category: Custom Classes and Multithreading Objective: To understand and apply the principles of OpenMP for parallel calculations in a computationallyintensive problem related to the Electric Field calculations. Description: • Redo Lab1 but use OpenMP to create a multithreaded application. • You do not have to use the classes from Lab1. • Create a short one page report (pdf) describing your results with a graph showing the processing time results of a 1000 x 1000 grid for o 1 thread o 2 threads o 4 threads o 8 threads o 16 threadsOverView: Create an application that uses OpenMP for multithreading to calculate the electric field at a point in space. • Your program should query the user for how many threads to run concurrently when doing the calculation. • Your program needs to query the user for the size of the N x M array and the charge q. • Your program should continuously prompt the user if a new calculation is wanted. • Your program should use OpenMP to reduce the processing time taken. • After calculating the resultant electric field your program should output the Ex, Ey, Ez values and the resultant electric field strength. • Your program should also output how long it takes in microseconds from the time the user inputs the xyz location to just before the results are output to the screen. • Spaces separate the values when entering multiple inputs. • Make sure you check for valid inputs o N and M should be natural numbers. o Separation distances should be > 0.0 and be valid numerical values o Charge should be a valid numerical value. o Point location should be made up of valid numerical values.Sample Program Flow: Please enter the number of concurrent threads to use: 16 Please enter the number of rows and columns in the N x M array: 100 100 Please enter the x and y separation distances in meters: 0.01 0.03 Please enter the common charge on the points in micro C: 0.02 Please enter the location in space to determine the electric field (x y z) in meters: 1.0 2.0 3.0 The electric field at (1.0, 2.0, 3.0) in V/m is Ex = x.xxxx * 10^y Ey = x.xxxx * 10^y Ez = x.xxxx * 10^y |E| = x.xxxx * 10^y The calculation took x.xxxx microsec! Do you want to enter a new location (Y/N)? Y Please enter the location in space to determine the electric field (x y z) in meters: 2.0 2.0 2.0 The electric field at (2.0, 2.0, 2.0) in V/m is Ex = x.xxxx * 10^y Ey = x.xxxx * 10^y Ez = x.xxxx * 10^y |E| = x.xxxx * 10^y The calculation took x.xxxx microsec! Do you want to enter a new location (Y/N)? N Bye! Turn-In InstructionsPlace your files in a zip file called Lab1.zip and upload this zip file on the assignment section of Canvas.Grading Rubric:AUTOMATIC GRADING POINT DEDUCTIONS PER PROBLEM: Element Percentage Deduction Details Does Not Compile 40% Code does not compile on PACE-ICE! Does Not Match Output Up to 90% The code compiles but does not produce correct outputs. Runtime and efficiency of code setup Up to 20% The code generates the correct output but runs slower than expected. Clear Self-Documenting Coding Styles Up to 25% This can include incorrect indentation, using unclear variable names, unclear/missing comments, or compiling with warnings. (See Appendix A)LATE POLICY Element Percentage Deduction DetailsAppendix A: Coding Standards Indentation: When using if/for/while statements, make sure you indent 4 spaces for the content inside those. Also make sure that you use spaces to make the code more readable. For example: for (int i; i < 10; i++) { j = j + i; }If you have nested statements, you should use multiple indentions. Each { should be on its own line (like the for loop) If you have else or else if statements after your if statement, they should be on their own line. for (int i; i < 10; i++) { if (i < 5) { counter++; k -= i; } else { k +=1; } j += i; }Camel Case: This naming convention has the first letter of the variable be lower case, and the first letter in each new word be capitalized (e.g. firstSecondThird). This applies for functions and member functions as well! The main exception to this is class names, where the first letter should also be capitalized. Variable and Function Names: Your variable and function names should be clear about what that variable or function represents. Do not use one letter variables, but use abbreviations when it is appropriate (for example: “imag” instead of “imaginary”). The more descriptive your variable and function names are, the more readable your code will be. This is the idea behind self-documenting code.File Headers: Every file should have the following header at the top /* Author: your name Class: ECE4122 or ECE6122 (section)Description:What is the purpose of this file?*/Code Comments:1. Every function must have a comment section describing the purpose of the function, the input and output parameters, the return value (if any). 2. Every class must have a comment section to describe the purpose of the class. 3. Comments need to be placed inside of functions/loops to assist in the understanding of the flow of the code.
(100 pts) Category: Getting Started Problem 1:This problem is very simple. Write a C++ program using the insertion stream operator and escape sequences that outputs the following text to your terminal screen when executed:My name is: your first and last name separated by a space This (“) is a double quote. This (‘) is a single quote. This () is a backslash. This (/) is a forward slash.This program is very simple with no user input, command arguments, or file output. You can place all the code in your main() function in a file called Lab0_Problem1.cpp.Your PACE-ICE accounts have already been created.Problem 2: Sum of the Multiples of 3 or 5 (www.projecteuler.net) The write a console program that continuously takes in a natural number from the console and outputs to the console all the numbers below the entered number that are multiples of 3 or 5 and then outputs the sum of all the multiples. Entering a 0 ends the program. Make sure code checks for valid input values. Entries must be positive and be made up of numeric characters (0, 1, 2, 3, 4, 5, 6, 7, 8, 9). A sample sequence is shown below and your output should match the formatting shown in the sample. Place your code in the file Lab0_Problem2.cpp. Sample Sequence: > Please enter a natural number (0 to quit): 10 > The multiples of 3 below 10 are: 3, 6, 9. > The multiples of 5 below 10 are: 5. > The sum of all multiples is: 23. > Please enter a natural number (0 to quit): 0 > Program terminated. > Have a nice day!Turn-In InstructionsPlace your two cpp files in a zip file called Lab0.zip and upload this zip file on the assignment section of Canvas.Grading Rubric:AUTOMATIC GRADING POINT DEDUCTIONS PER PROBLEM: Element Percentage Deduction Details Does Not Compile 40% Code does not compile on PACE-ICE! Does Not Match Output 10%-90% The code compiles but does not produce correct outputs. Clear Self-Documenting Coding Styles 10%-25% This can include incorrect indentation, using unclear variable names, unclear/missing comments, or compiling with warnings. (See Appendix A)LATE POLICY Element Percentage Deduction DetailsAppendix A: Coding Standards Indentation: When using if/for/while statements, make sure you indent 4 spaces for the content inside those. Also make sure that you use spaces to make the code more readable. For example: for (int i; i < 10; i++) { j = j + i; }If you have nested statements, you should use multiple indentions. Each { should be on its own line (like the for loop) If you have else or else if statements after your if statement, they should be on their own line. for (int i; i < 10; i++) { if (i < 5) { counter++; k -= i; } else { k +=1; } j += i; }Camel Case: This naming convention has the first letter of the variable be lower case, and the first letter in each new word be capitalized (e.g. firstSecondThird). This applies for functions and member functions as well! The main exception to this is class names, where the first letter should also be capitalized. Variable and Function Names: Your variable and function names should be clear about what that variable or function represents. Do not use one letter variables, but use abbreviations when it is appropriate (for example: “imag” instead of “imaginary”). The more descriptive your variable and function names are, the more readable your code will be. This is the idea behind self-documenting code.File Headers: Every file should have the following header at the top /* Author: your name Class: ECE4122 or ECE6122 (section)Description:What is the purpose of this file?*/Code Comments:1. Every function must have a comment section describing the purpose of the function, the input and output parameters, the return value (if any). 2. Every class must have a comment section to describe the purpose of the class. 3. Comments need to be placed inside of functions/loops to assist in the understanding of the flow of the code.
Write a C++ application that uses a custom class(es) with OpenGL and a third-party library (i.e. ASSIMP) to load and display animated 3D objects in OBJ files. Your program should load and render the objects in the 3D screen. The animated 3D objects are frozen in place until the user presses the “g” key and then the objects start moving around at random speeds and rotating randomly about an axis. You must have at least four animated 3D objects and each object’s movements are calculated in a separate thread. The objects must be able to collide and bounce off each other. The objects should also be confined to the space around the center of the scene and cannot just float off into space. You are free to use your own objects if you prefer.1. (30 pts) Create an oversized floor with a textured image. There is one provided but you are free to use your own images. 2. (30 pts) The four objects are rendered correctly with lighting and material properties. Have some general ambient and diffuse lighting effects. 3. (50 pts) The four objects do not move and only start to move when the user presses the “g” key. 4. (40 pts) The four objects start to move and rotate randomly around the area. The object shall collide and bounce off each other and the floor. 5. (30 pts) Each of the four 3D objects has an internal light that randomly changes intensity. 6. (30 pts) The camera view should always point towards the center of the scene. 7. (30 pts) Pressing the up/down arrow keys should zoom in and out. 8. (30 pts) Pressing the left/right arrow keys rotate either the camera view or the model left and right. 9. (30 pts) Pressing the “u” and “d” keys causes the camera to rotate up or down. Pressing escape key ends the application.Add extra static objects to give the scene depth. Be careful not to add too many or it will slow down your application.Turn-in Instructions:Two methods: 1. a. Upload a video of your application running and demonstrate the requirements above. b. Put all the code files you created into a zip file called FinalProject.zip and upload to canvas. 2. b. You can use the tutorial09_Assimp example from class to develop your code. Place your new source code files in a subfolder called code. Once you have finished your development, zip the tutorial09_Assimp folder with your changes into a zip file called FinalProject.zip and upload to canvas.Grading Rubric AUTOMATIC GRADING POINT DEDUCTIONS PER PROBLEM: Element Percentage Deduction Details Does Not Compile 30% Code does not compile on PACE-ICE! Does Not Match Output Up to 100% The code compiles but does not produce the correct outputs. See point values above. Clear Self-Documenting Coding Styles 10%-25% This can include incorrect indentation, using unclear variable names, unclear/missing comments, or compiling with warnings. (See Appendix A)Appendix A: Coding Standards Indentation: When using if/for/while statements, make sure you indent 4 spaces for the content inside those. Also make sure that you use spaces to make the code more readable. For example: for (int i; i < 10; i++) { j = j + i; }If you have nested statements, you should use multiple indentions. Each { should be on its own line (like the for loop) If you have else or else if statements after your if statement, they should be on their own line. for (int i; i < 10; i++) { if (i < 5) { counter++; k -= i; } else { k +=1; } j += i; }Camel Case: This naming convention has the first letter of the variable be lower case, and the first letter in each new word be capitalized (e.g. firstSecondThird). This applies for functions and member functions as well! The main exception to this is class names, where the first letter should also be capitalized. Variable and Function Names: Your variable and function names should be clear about what that variable or function is. Do not use one letter variables, but use abbreviations when it is appropriate (for example: “imag” instead of “imaginary”). The more descriptive your variable and function names are, the more readable your code will be. This is the idea behind self-documenting code. File Headers: Every file should have the following header at the top /* Author: your name Class: ECE4122 or ECE6122 (section)Description:What is the purpose of this file?*/ Code Comments:1. Every function must have a comment section describing the purpose of the function, the input and output parameters, the return value (if any). 2. Every class must have a comment section to describe the purpose of the class. 3. Comments need to be placed inside of functions/loops to assist in the understanding of the flow of the code.
Instructions & Guidelines • For this coding assignment, you’re tasked with implementing and training three types of autoencoders: regular autoencoders, variational autoencoders (VAEs), and conditional variational autoencoders (CVAEs). Both the encoder and decoder architectures should follow the ResNet style. • No extensions will be granted for this assignment under any circumstances. • Use only data which is provided with this assignment • Submit only the file named as per the following convention: rollnoA3.py. Ensure strict adherence to this naming convention. Any deviation from it, including the presence of multiple files, .ipynb files, or additional files, will result in non-evaluation. For example, if your roll number is 1234567 or MT34567, your filename should be 1234567A3.py or MT34567A3.py Coding Guidelines • Use requirements.txt to setup the environment. • You will receive a pipeline for training the architectures. Within the folder, locate a file named changerollno.py. Your task is to edit only this specific file . • In test-set you must score SSIM above 0.6 to be eligible to get evaluated.1. Train a Denoising AutoEncoder, encoder and decoder must follow ResNet style and residual connection must be after 2 convolution / 2 convolution-batchnorm layer. You are free to pick all other design choices. Plot 3D TSNE embedding plot for logits/embeddings (output from encoder) of whole data after every 10 epochs. 2. Train a Denoising Variational AutoEncoder, encoder and decoder must follow ResNet style and residual connection must be after 2 convolution / 2 convolution-batchnorm layer. You are free to pick all other design choices. Plot 3D TSNE embedding plot for sampled logits/embeddings from logits/embeddings (output from encoder) of whole data after every 10 epochs. 1
Assignment 2 Trade off between Model size, Prompt type, Time Taken and Quality ❖ It is mandatory to maintain a github repository for assignments since subsequent assignments will require the same files and functions for update. ❖ You need to submit a zip with name ROLL_NUMBER.zip (eg:PhDXXXXX.zip) which should have: ● A pdf which should have all your results and conclusions mentioned and link to the github repository. ● Code files in .py/.ipynb format only, colab links will not be accepted. (Download your collab file and put in zip) ● Task: ○ Three publicly available LLMs of different sizes: ■ https://huggingface.co/google/gemma-2b-it ■ https://huggingface.co/microsoft/Phi-3.5-mini-instruct ■ https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct (NOTE: In case you observe that inference of 8B model is taking time you can use free api credits from https://together.ai/ , you can use these and many more similar api key exists) ○ Use this https://huggingface.co/datasets/cais/mmlu/viewer/college_mathematics dataset of Mathematics question answers to do this task. ○ Implement functions to perform inference using below type of prompts for all three LLMs. ■ ReAct Prompting For more clarity you can refer : https://www.promptingguide.ai/
Instructions: 1. Assignments are to be attempted individually. 2. Submit the assignment in a zipped file with name AI4 ⟨StudentName⟩ and contents including AI4 StudentName Result.pdf and ⟨StudentName⟩ gradient.py and the computational question as ⟨StudentName⟩ linear regression.py, and ⟨StudentName⟩ logistic regression.py depending on which question you solve. 3. STDOUT / python print outputs will be considered for evaluation. 5. Programming Language : Python 6. Use classes, functions etc. in your code in ways that make sense. 7. Extension and Penalty clause: • A penalty will be incurred if the submissions are late. Expanded equation form: y = w1 ∗ x1 + w2 ∗ x2 + w3 ∗ x3 + w4 ∗ x4 + w5 ∗ x5 + b Vector form: w y = w⊤x + b Here, w are the weights and b is the offset. Mean Squared Error:Here {(x(i),y(i));i = 1,2,…,N} are the labeled data samples available for the optimization. are the predictions from the linear regression model. Submit the derivation of the gradients for the above 5-dimensional example, both in the expanded equation form as well as the vector form. X = np. arange(−20, 20 , 0.1) np. random . shuffle (X) eps = np. random . rand (400) ∗ 10 y = 23∗X + 43 + eps EXAMPLE OUTPUT STDOUT: w = 23, b = 47 Please use the same notation in your python code’s print statement. Evaluation will take running time into account. Environment Setup: pip install ucimlrepo pandas scikit-learn By popular demand, it has been decided that only one of the following questions needs to be answered to complete the assignment. Please choose either Linear regression or Logistic regression and submit the filenames accordingly. Thanks. (a) Reference: Regression using continuous variables can be applied directly. Categorical variables, on the other hand, need some processing before they are used in regression. Look into the different approaches used here and implement your choice(s) by analyzing the data: https://stats.oarc.ucla.edu/spss/faq/coding-systems-for-categoricalvariables-in-regression-analysis-2/. Typically, one-hot encoding gives independence between the regression weights for the categories and assumes an independence between the categories that might not be useful and hence there are other ways people have come up with. (b) Dataset: Abalone (https://archive.ics.uci.edu/dataset/1/abalone) – use python to download the data instead of the web interface. (c) Accuracy: R2 score (d) Target variable: Rings (integer) Look into this for some context on the r2 metric: scikit-learn documentation:https://scikit-learn.org/stable/modules/generated/sklearn.metrics.r2s Examples: https://www.ncl.ac.uk/webtemplate/ask-assets/external/maths-resources/statistics/r and-correlation/coefficient-of-determination-r-squared.html. (g) Submission Format: ⟨StudentName⟩ linear regression.py • R2 score over entire dataset: R2 =0.537 minimum; R2 =0.56+ • R2 score over 15% test dataset: mean R2 score and standard deviation over 15% test dataset • The assessment will be automatic. Please use the EXACT STRINGS as shown in the example output • The only outputs needed are the performance metric numbers changed according to your results. (h) Example Output STDOUT: Full dataset train and eval R2 score: 0.54 70-15-15 Cross validation boxplot: mean=0.51, std=0.04 (j) HINT: You can try to use non-linear transformations of the data for performance ablations. (a) Reference: This question contains data with missing values. Here is a reference you can use for common strategies employed in regression datasets with missing values: http://www.stat.columbia.edu/ gelman/arm/missing.pdf. Consider using matching, mean value + random noise or more feature-specific random imputations of a single variable in your free time. For now, you can assign an UNKNOWN label to all missing values and try to approximate the results anyway. Note: Logistic regression uses LBFGS in the backend. (b) Dataset: Adult (https://archive.ics.uci.edu/dataset/2/adult) – use python to download the data instead of the web interface. (c) Accuracy: Classification score (d) Target variable: income (binary) (g) Submission Format: ⟨StudentName⟩ logistic regression.py • accuracy score over entire dataset: full accuracy: 0.80 ; train accuracy=0.79 ; test accuracy=0.78 • accuracy score over 15% test dataset: mean accuracy score and standard deviation over 15% test dataset • The assessment will be automatic. Please use the EXACT STRINGS as shown in the example output • The only outputs needed are the performance metric numbers changed according to your results. (h) Example Output STDOUT: Full dataset accuracy: full: 0.80, train: 0.79, test: 0.78 70-15-15 Cross validation boxplot: mean=0.74, std=0.08 END
Theory (ii) (1 mark) Verify that these propositions create a valid probability distribution. List the set of axioms that they satisfy. (iii) (1 mark) Populate the full joint probability distribution table. (a) About 82.5 % people have travelled and have caught either corona or other diseases. (b) Of the people who had travelled 15 % have mild and 22 percentage have severe cases of corona, respectively. (c) Given that a person travelled the chance they caught a disease other than corona is 0.485 rounded to 3 decimal places. (d) About 24 % of people died of diseases other than corona after travelling. (e) There is 0.025 probability that a person has not travelled and has severe case of corona. (f) Given a person has not travelled the probability that the person is severely sick is about 0.457 rounded to 3 decimal places. (g) The probability that a person has died and did have corona is 0.059. (h) About 70 % people had mild or severe cases of any disease. (i) There is 80 % chance that a person has travelled given that he is severely sick. (j) There is 50 % chance a person had corona whether they travelled or not. (a) (1 mark) Should you switch your choice to the other unopened door to maximize your chance of winning the key? (c) (1 mark) If you choose to switch, what is the conditional probability that you win the key if the man has mistakenly revealed the door that shows life lost? (d) (1 mark) Additionally, what is the conditional expectation of your prize (key/life lost) based on your choice to switch or stick, considering both possible scenarios? Would you choose to switch or stick based on the conditional expectation? Computational 1. Create a Bayesian Network (14) : (a) (2 mark) Dataset : Load the wine quality dataset https://archive.ics.uci.edu/ dataset/109/wine. The dataset is continuous and therefore discretization would be required to build the network. You can explore continuous/hybrid models also. Build classification model based on class variable in the data for performance evaluation (accuracy) https://scikit-learn.org/stable/modules/generated/sklearn.metrics. accuracy score.html of the network. You can use any available open-source packages to build the network, example bnlearn package {https://pypi.org/project/ bnlearn/}. (b) Instructions to Construct the network: You will need to construct and evaluate a total of three networks A, B and C as described below: • (2 mark) Construct a Bayesian network (A) for the data. Visualise the network and the probability distribution. Describe a few examples of parent and child nodes. • (1 mark) Prune the network (A) for better performance on the class variable. Let the new network be (B). Explain your method of pruning. • (1 mark) Compare the prediction performance based on the three models (A), (B) and (C). • There will be relative grading based on your explanation and innovative implementations. (c) Instruction for submission : Please follow the guidelines below to submit the findings. There are penalties for not following the format outlined below. • (-1 mark) The data should be imported correctly, and any pre-processing should be explained. Otherwise explain why there was no pre-processing. • (-1 mark) Make a proper pdf file with all the results. • (-3 mark) Make a table with the performance measures of the three Bayesian networks. • (-1 mark ) The explanations and descriptions should be proper. • (-1 mark) The code is incorrect. END
Theory 1. Suppose you decide not to keep the explored set (i.e., the place where the explored nodesare saved) in the A* algorithm.Computational 3. (a) Use the city “Road Distance” data given. Assume that only these roads between the cities exist. b. Write a Python program to search a road route from any city to any other cityusing this data. It should work for both cities that are directly connected (say, Ahmedabad to Indore) as well as for two cities that are not directly connected (say, Agartala to Hubli). c. Show Uniform Cost Search and A* search on this data. d. You should use Python features such as Lists, Input/ Output, Recursion, Backtracking etc. e. Your code should work for different inputs, i.e., the user should be able to inputany pair of cities as the origin-destination pair from the command line and the program should return the best found path. This means you must not hard-code your solution for a set of pairs. f. Design two different, non-trivial (e.g., a constant h(n) = c is a trivial heuristic) heuristics for A*. (1) The first one should be admissible. Empirically verify that the admissible heuristic yields the optimal solution. (2) Come up with an inadmissible heuristic function that will expand fewer nodes than your admissible heuristic in (1). Show this property for at least two origin-destination pairs in your code.
Theory (a) Write the sentences using logical connectives.(1) (b) Write the contra-positive of the sentence using logical connectives. (1) (c) What can be inferred and not inferred from the statement. (1) (d) Draw the And-OR graph (2) (a) Location (1) (b) Gender (1) Explain inheritance and multiple inheritance using examples from your Network. (2) Computational (a) Create a Travel advisory system in Python for travellers. It needs to suggest to aperson the locations(places) they can visit based on their preferences. (b) Advisory system here refers to a system that will take some inputs from the userand ask them questions related to their travel to narrow down choices and then suggest a destination according to their preferences. Write clauses and show explicit knowledge representation and reasoning. (c) You are free to make your own rules and facts. Create your own knowledge base,for example, you can consider the weather, activities of that location, places to visit nearby, connectivity, etc. (d) You are free to add any number of parameters. (e) Use Python features such as Lists, Input/ Output, Recursion, Backtracking, etc. (f) Should work for different inputs. Should not be hard-coded for one user. (g) Make your own advisory system. Make it as good as you can, but the advice shouldbe useful and practical. (h) Users must be able to add new destinations, rate them on a scale of 10, and providefeedback. They must also be able to check the already existing feedback. (i) You are free to make the program as interesting and complex as you want. • The complexity of the program (2 mark). • The kind of result generated (2 mark). • Example for Demo Program: Enter the preferred weather condition for the place. User: Cold Program: Enter Budget User: 30000 Program: Would you like to check feedback for a particular place ? User: No Program: The Recommended places are: Manali, Dehradun. Program: Would you like to add new destinations? User: Yes Prompt: Delhi Rating 8 Program: Would you like to give feedback on the place ? User: No Ends..
Instructions & Guidelines • For this coding assignment, you’re tasked with implementing and training three types of autoencoders: regular autoencoders, variational autoencoders (VAEs), and conditional variational autoencoders (CVAEs). Both the encoder and decoder architectures should follow the ResNet style. • No extensions will be granted for this assignment under any circumstances. • Use only data which is provided with this assignment • Submit only the file named as per the following convention: rollnoA3.py. Ensure strict adherence to this naming convention. Any deviation from it, including the presence of multiple files, .ipynb files, or additional files, will result in non-evaluation. For example, if your roll number is 1234567 or MT34567, your filename should be 1234567A3.py or MT34567A3.py Coding Guidelines • Use requirements.txt to setup the environment. • You will receive a pipeline for training the architectures. Within the folder, locate a file named changerollno.py. Your task is to edit only this specific file . • In test-set you must score SSIM above 0.6 to be eligible to get evaluated.1. Train a Denoising AutoEncoder, encoder and decoder must follow ResNet style and residual connection must be after 2 convolution / 2 convolution-batchnorm layer. You are free to pick all other design choices. Plot 3D TSNE embedding plot for logits/embeddings (output from encoder) of whole data after every 10 epochs. 2. Train a Denoising Variational AutoEncoder, encoder and decoder must follow ResNet style and residual connection must be after 2 convolution / 2 convolution-batchnorm layer. You are free to pick all other design choices. Plot 3D TSNE embedding plot for sampled logits/embeddings from logits/embeddings (output from encoder) of whole data after every 10 epochs. 1
Instructions & Guidelines • This coding assignment revolves around developing custom deep convolutional network and manually training it. Additional instructions for each question are provided accordingly. • No extensions will be granted for this assignment under any circumstances. • You have to submit only changerollno.py. Rename it according to your rollnumber. Ensure that you follow the naming convention as rollnoA2.py. Any submissions without adhering to the naming convention, having multiple files in submission including .ipynb files, and any additional files will not be evaluated. For instance, if your roll number is 1234567 / MT34567, the file name should be 1234567A2.py / MT34567A2.py. Coding Guidelines • Follow Readme.txt to setup the environment and start coding. • You will receive a pipeline for training the architectures. Within the pipeline folder, locate a file named changerollno.py. Your task is to edit only this specific file . • Minimum accuracy you have to achieve is 45% for each question to be eligible to get evaluated.All these networks are easily trainable on Google ColaboratoryFigure 1: Block diagram for different architectures. Figure 1 illustrates different blocks from various deep learning architectures. Your task is to implement these blocks and train them using two datasets: CIFAR-10 and SpeechCommand V0.02. Follow the provided instructions for each question. Only use PyTorch’s dataset library torchvision.datasets for image data and torchaudio.datasets for audio data when downloading the datasets. 1 1. ResNet In Figure.1, (A) represents a single ResNet block. Here, (3×3 Conv(1D/2D)) denotes a single convolution layer with a filter size of 3×3 for 2D data and 1×3 for 1D data, (Batch norm(1D/2D)) represents a single Batch normalization layer for 1D or 2D data, and (ReLU) represents the rectified linear unit activation function. Your task is to create a network comprising 18 such blocks and train it on both datasets. For the image dataset, use 2D Convolutions and Batch normalization, while for the audio dataset, use 1D Convolutions and Batch normalization. Utilize Cross-Entropy as the loss function and Adam as the optimizer with default parameters specified in the script. 2. VGG In Figure.1, (B) outlines the modified VGG architecture. After each pooling layer, the number of channels is reduced by 35%, and the kernel size is increased by 25% (with ceil rounding for float calculations). Here, (Conv n-m) denotes the nth block and mth layer within that block. Your task is to create a VGG network and train it on both image and audio datasets using the specified loss function and optimizer from the previous question. 3. Inception In Figure.1, (C) illustrates the configuration of a single inception block, where (n×n (CNA)) denotes a sequence of convolution, batch normalization, and ReLU activation with an n×n convolution filter. Your task is to construct a modified inception network comprising 4 such blocks and train it on both audio and image data, following similar configurations as in the previous two questions. 4. Design a custom network using the following combination of blocks and follow the channel reduction and kernel size increase as in VGG. Train it on both image and audio datasets, adhering to configurations similar to those in the previous questions. • Network Architecture (a) Input Layer (b) Residual Block × 2 (c) Inception Block × 2 (d) Residual Block × 1 (e) Inception Block × 1 (f) Residual Block × 1 (g) Inception Block × 1 (h) Residual Block × 1 (i) Inception Block × 1 (j) Classification Network • A classification network here refers to a combination of either nn.Linear or nn.Conv1d, nn.Conv2d layers that produce logits for the classification task. 2
Instructions. • This coding assignment revolves around developing a basic Multi-Layer Feedforward network and manually training it. Additional instructions for each question are provided accordingly. • You have to submit the GoogleColab file named as rollno-A1.ipynb. Files submitted without following naming convention, .py files and any other will not be evaluated. For example if your roll number is 1234567 / MT34567 file name must be 1234567-A1.ipynb / MT34567-A1.ipynb • No extensions will be granted for this assignment under any circumstances. • You can refer to the code available in the notebook shared on Google Classroom for guidance.1. Download the MNIST dataset (provide code to download in google colab) and create a custom dataloader using torch.utils.data.Dataset, DataLoader. Write another dataloader completely from scratch and compare the loading performance of your scratch implemented data loader with the one written with PyTorch classes across different batch sizes (128, 256, 512, 1024). Plot a graph illustrating the relationship between batch size and loading time. 2. Implement a Feed-Forward neural network architecture using torh.nn.Linear featuring four hidden layers, each comprising minimum 32 neurons (excluding input and output layers). Train the model using the most effective data loader identified in the previous question with ReLU activation function. Employ the Cross-Entropy loss function and opt for the Stochastic Gradient Descent (SGD) optimizer with default parameters, setting the learning rate to 0.0003. Plot graphs depicting the loss and accuracy during training, validation and testing for a total of 60 epochs. For this question you can use whatever PyTorch has to offer. 4. Execute the tasks outlined in questions 2 and 3, but this time, use a sigmoid activation function while keeping all other parameters and configurations unchanged. 1
General Instructions: ● Every assignment has to be attempted by four people. At least one subtask has to be done by one team member. All members need to have a working understanding of the entire code and assignment. ● Create separate .ipynb or .py files for each part. The file name should follow the format: “A4_.ipynb/.py” ● Carefully read the deliverables for all tasks. Along with the code files, submit all the other files mentioned for each task, strictly following the naming convention instructed. ● Only one person has to submit the zip file containing all the mentioned files and the report PDF. It will be named “A4_.zip”. The person with the alphabetically smallest name should submit it. ● You are required to submit your trained models. You must also retain all your checkpoints and load and run them during the demo. ● Your report must include the details of each group member’s contribution.This assignment is along the lines of the paper “Discovering Emotion and Reasoning its Flip in Multi-Party Conversations using Masked Memory Network and Transformer” Datasets The paper proposed a new dataset known as the MELD-FR for the novel task. We have modified the datasets that can be used to split for the train and val. TASK 1 – ERC (Emotion Recognition in conversation) What is ERC ? Emotion Recognition in Conversation (ERC) is a specialized field that focuses on automatically identifying and interpreting the emotional states expressed by individuals during conversations. Unlike traditional approaches that analyze emotions in isolated text, ERC aims to understand the nuanced emotional dynamics in conversational exchanges involving multiple speakers. It enables a deeper understanding of emotional processes and interactions, benefiting applications such as conversational agents and affective computing systems. What are you expected to do? 1. Train 2 models M1 & M2 with independent architectures which should be different from the architecture mentioned in the paper given above. (Note : If you are re-implementing the paper’s model architecture as one of the models, make sure that the papers results will be considered as the baselines and the other model’s scores should be at par with the one’s given in the paper) 2. Both these models should focus on emotion identification and also detecting the flips in emotion within a set of conversations. Reasoning of the shift is not important for this part of the assignment. 3. Submit both model checkpoints M1 and M2, and report the better model with proper reasoning. The same will be tested on the testing data which will be provided at the time of demos. Deliverables 1. Two model checkpoints M1 and M2 in proper format.[5*2=10] 2. Well labeled model architectures used for both M1 and M2.[5*2=10] (If implementing the paper’s model, ignore this deliverable for only one model but note the baselines.) 3. If you are implementing the paper’s architecture, then the other model should give results around at most 5% less than the paper’s results. It can defeat the paper’s results. [5 for comparable result on new model,5 for model architecture of of new model] 4. Properly mention which of the two architectures was better and why.[5] 5. Proper report explaining the intuition behind the models, splits and everything relevant.[5] 6. Add train loss and val loss vs epochs plots for each model in the report. [2.5*2*2=10] You can choose either point 2 or 3. TASK 2 – EFR (Emotion Flip Reasoning) What is EFR ?A snapshot from the paper itselfIn the above mentioned example note the emotional flip in a set of conversations between multiple individuals. The task is to note the emotional shift. The purple arrow in the example shows the switch in the emotion from Joy to Neutral and sadness to neutral in the second case. What are you expected to do? 4. Train 2 models M3 & M4 with independent architectures which should be different from the architecture mentioned in the paper given above. (Note : If you are re-implementing the paper’s model architecture, make sure that the papers results will be considered as the baselines and your scores should be at par with the one’s given in the paper) 5. Submit both model checkpoints M3 and M4, and report the better model with proper reasoning. The same will be tested on the testing data which will be provided at the time of demos. Deliverables 1. Two model checkpoints M3 and M4 in proper format.[5*2=10] 2. Well labeled model architectures used for both M3 and M4.[5*2=10] (If implementing the paper’s model, ignore this deliverable for only one model . For the other model you will have to but note the baselines.) 3. If you are implementing the paper’s architecture, then the other model should give results around at most 5% less than the paper’s results. It can defeat the paper’s results. [5 for comparable result on new model,5 for model architecture of of new model] 4. Properly mention which of the two architectures was better and why.[5] 5. Proper report explaining the intuition behind the models, splits and everything relevant.[5] 6. Add train loss and val loss vs epochs plots for each model in the report. [2.5*2*2=10] You can choose either point 2 or 3.
General Instructions: ● Every assignment has to be attempted by four people. At least one subtask has to be done by one team member. All members need to have a working understanding of the entire code and assignment. ● Create separate .ipynb or .py files for each part. The file name should follow the format: “A3_.ipynb/.py” ● Carefully read the deliverables for all tasks. Along with the code files, submit all the other files mentioned for each task, strictly following the naming convention instructed. ● Only one person has to submit the zip file containing all the mentioned files and the report PDF. It will be named “A3_.zip”. The person with the alphabetically smallest name should submit it. ● You are required to submit your trained models. You must also retain all your checkpoints and load and run them during the demo. ● Your report must include the details of each group member’s contribution.Task Definition – Given two sentences, calculate the similarity between these two sentences. The similarity is given as a score ranging from 0 to 5. Train datapoint examples – score sentence1 sentence2 2.400 A woman is playing the guitar. A man is playing guitar. For this task, you are required to implement three setups: ● Setup 1A – You are required to train a BERT model (google-bert/bert-base-uncased · Hugging Face) using HuggingFace for the task of Text Similarity. You are required to obtain BERT embeddings while making use of a special token used by BERT for separating multiple sentences in an input text and an appropriate linear layer or setting of BertForSequenceClassification (BERT) framework for a float output. Choose a suitable loss function. Report the required evaluation metric on the validation set. ● Setup 1B – You are required to make use of the Sentence-BERT model (https://arxiv.org/pdf/1908.10084.pdf) and the SentenceTransformers framework (Sentence-Transformers). For this setup, make use of the Sentence-BERT model to encode the sentences and determine the cosine similarity between these embeddings for the validation set. Report the required evaluation metric on the validation set. You must save and submit your model checkpoints for 1A and 1C in an appropriate format. scale of 1 for training the sentence transformers. Evaluation Metrics – Pearson Correlation ● Generate the following plots for Setup 1A and 1C: a) Loss Plot: Training Loss and Validation Loss V/s Epochs b) Analyse and Explain the plots obtained as well ● Provide a brief comparison and explanation for the performance differences between the three setups in the report. ● Provide all evaluation metrics for all the setups in your report pdf. The dataset is attached as a file in the assignment post. It contains the following files – ● A training data file of the name – ‘train.csv’ ● A validation data file of the name – ‘dev.csv’ ● a sample test file with the name – ‘sample_test.csv’ ● A sample of the CSV file to be generated during the demo – ‘sample_demo.csv’ To download the dataset, make use of HuggingFace datasets – Load a Dataset – Hugging Face For downloading the training dataset, use the command datasets.load_dataset(“wmt16″,”de-en”, split=”train[:50000]”) Each dataset sample consists of a piece of text in German and its translation in English. Use this data to train German-English translation models. You are required to implement the following setups – ● Setup 2A – Train an encoder-decoder transformer model using a deep learning library like PyTorch. (Transformer — PyTorch 2.2 documentation). Tutorial: Language Translation with nn.Transformer and torchtext — PyTorch Tutorials 2.2.1+cu121 documentation. You must train the sequence-to-sequence model from scratch for German-English translation and report the evaluation metrics on the validation and test datasets. ● Setup 2B – Perform zero-shot evaluation of the t5-small model (https://huggingface.co/google-t5/t5-small) for the task of machine translation from German to English. Zero-shot evaluation refers to testing of a language model without explicitly training or fine-tuning it for the given task. The t5-small model allows for this setup by prepending a prefix to the input sentence. This prefix is available through carefully reading the model documentation for the T5 model available at T5. Utilise this to generate the translations for the validation and testing sets and report the required You must save and submit your model checkpoints for 2A and 2C in an appropriate format. Evaluation Metrics – i) String-based metrics – BLEU (BLEU – a Hugging Face Space by evaluate-metric) and METEOR (METEOR – a Hugging Face Space by evaluate-metric) ii) Machine Learning Based Metric – BERTScore (BERT Score – a Hugging Face Space by evaluate-metric) ● Generate the following plots for Setup 2A and 2C: a) Loss Plot: Training Loss and Validation Loss V/s Epochs b) Analyse and Explain the plots obtained as well ● Provide a brief comparison and explanation for the performance differences between the three setups in the report. ● Provide all evaluation metrics for all the setups in your report pdf.
Assignment-4 CNN, PCA, K-means clusteringInstructions • Your submission should be a single zip file 2020xxx_HW1.zip (Where 2020xxx is your roll number). Include all the files (code and report with theory questions) arranged with proper names. A single .pdf report explaining your codes with results, relevant graphs, visualization and solution to theory questions should be there. The structure of submission should follow: 2020xxx_HW1 |− code_rollno.py/.ipynb |− report_rollno.pdf |− (All other files for submission) • Anything not in the report will not be graded. • Your code should be neat and well-commented. • You have to do either Section B or C. • Section A is mandatory.1. (10 points) Section A (Theoretical) The kernels are of shape h × w × I × O, representing height, width, number of input channels, and number of output channels, respectively. (a) What is the output image size? [2] (b) What is the significance of pooling in CNN? [1](c) Compute the total number of learnable parameters for the above CNN architecture (ignore bias) [2] (d) (1 mark) Explain the difference between linear and non-linear kernel or filters in CNN. 2. (15 points) Section B (Scratch Implementation) (a) For this problem, you have to implement Convolutional neural network from scratch. To implement the CNN from scratch you have to implement the following required functions by yourself: You are allowed to use NumPy, Matplotlib, and random libraries. OR 3. (15 points) Section C (Algorithm implementation using packages) Clustering Analysis using PCA and K-Means Dataset: Country Dataset The task is to perform a clustering analysis to categorize countries based on socioeconomic and health factors. You are provided with a dataset containing socio-economic Page 2 and health indicators for various countries. The columns include features such as child mortality, exports, health spending, imports, income, inflation, life expectancy, total fertility rate, and GDP per capita. Page 3
Assignment-2 Decision Trees, Random Forests and PerceptronInstructions • Your submission should be a single zip file 2020xxx_HW1.zip (Where 2020xxx is your roll number). Include all the files (code and report with theory questions) arranged with proper names. A single .pdf report explaining your codes with results, relevant graphs, visualization and solution to theory questions should be there. The structure of submission should follow: 2020xxx_HW2 |− code_rollno.py/.ipynb |− report_rollno.pdf |− (All other files for submission) • Anything not in the report will not be graded. • Your code should be neat and well-commented. • You have to do either Section B or C. • Section A is mandatory.1. (4 points) Section A (Theoretical) (b) (1 mark) Rahul decides to rely on a weather prediction app that claims to accurately forecast ’Rainy’ and ’Clear’ days. On any given day, the app predicts ’Rainy’ with a probability of 0.3 (30) and it predicts ’Clear’ with a probability of 0.7 (70percent )The app’s accuracy for predicting ’Rainy’ days is 80 percent, and its accuracy for predicting ’Clear’ days is 90percent. What is the probability that it’s going to rain on a day, given that the app predicts ’Rainy’?” Find the probability of all the possible outcomes and state the most likely outcome. 3. (15 points) Section B (Library Implementation) Decision Tree and Random Forests Perform classification task on the heart disease dataset using only the relevant attributes mentioned on the repository website. Dataset: Heart Disease – UCI Machine Learning Repository Page 2 4. (15 points) Section C (Algorithm implementation using packages) 1. Implement a Decision Tree from Scratch for Classification. Create a Decision Tree classifier from scratch using the NumPy and Pandas libraries. Design a class called MyDecisionTree (specifically for solving classification problems.) (a) cost_function(): Develop a cost function that could be either the Gini index or Information gain. This function should compute the impurity of a node or the gain achieved by a potential split. Gini index: 1- sum(proportion)2 proportion = number of values/count of rows (b) make_split(): Define the basic mechanism of splitting a node in the Decision Tree such that it selects the best feature and value to split on. (c) max_depth(): Define the maximum depth of the tree. (d) Pruning (optional): define a function to remove branches that doesn’t contribute much for improving accuracy. (e) predict() (f) score(): Create a function to evaluate the DT (performance metric) Provide proper documentation (well-commented codes) Page 3
Assignment-1 Linear and Logistic Regression, ML in PracticeInstructions • Your submission should be a single zip file 2020xxx_HW1.zip (Where 2020xxx is your roll number). Include all the files (code and report with theory questions) arranged with proper names. A single .pdf report explaining your codes with results, relevant graphs, visualization and solution to theory questions should be there. The structure of submission should follow: 2020xxx_HW1 |− code_rollno.py/.ipynb |− report_rollno.pdf |− (All other files for submission) • Anything not in the report will not be graded. • Your code should be neat and well-commented. • You have to do either Section B or C. • Section A is mandatory.1. (10 points) Section A (Theoretical) (e) (1 mark) The parameters to be estimated in the simple linear regression model Y = α+βx+ϵ ϵ N(0,σ) are: (a) α, β, σ (b) α, β, ϵ (c) a, b, s (d) ϵ, 0, σ (f) (1 mark) In a study of the relationship between X=mean daily temperature for the month and Y=monthly charges on the electric bill, the following data was gathered: X=[20, 30, 50, 60, 80, 90], Y= [125, 110, 95, 90,110, 130]. Which of the following seems the most likely model? (a) Y= α + βx + ϵ β0 (c) Y= α + β1x + β2×2+ϵ β2 < 0 (d) Y= α + β1x + β2×2+ϵ β2 > 0 2. (15 points) Section B (Scratch Implementation) Logistic Regression Dataset: Diabetes Healthcare Dataset Page 2 OR 3. (15 points) Section C (Algorithm implementation using packages) Implementation of linear regression using libraries:- Split the dataset into 80:20 (train: test) Dataset: CO2 Emissions Dataset Page 3
SECTION – A (a) No, the fact that two variables exhibit a strong correlation with a third variable does not necessarily imply that they will also display a high degree of correlation with each other. Correlation is a measure of the linear relationship between two variables, and each pair of variables can have its own unique relationship, regardless of their relationship with a third variable. Here’s an example to illustrate this: Let’s say you have three variables: A, B, and C. Variable A and Variable B both have a strong positive correlation with Variable C. This means that as the values of A and B increase, the values of C also tend to increase. (b) The defining criteria for a function to be classified as a logistic function include: 1. S-Shaped Curve: A logistic function must exhibit an S-shaped curve, which means that it starts with a gradual increase, becomes steeper as it progresses, and then levels off as it approaches the upper and lower limits (asymptotes). This characteristic S-shape is a fundamental property of logistic functions. 2. Range: The output of a logistic function should be constrained to a specific range, typically between 0 and 1. As the input becomes very large (positive or negative), the output approaches the asymptotes of 1 and 0. 3. Symmetry and Center: A logistic function is symmetric about its midpoint, which is typically located at x=0. This means that the values of the function are symmetrically distributed around this central point. 4. Monotonicity: A logistic function is monotonically increasing, which means that as the input increases, the output also increases. However, the rate of increase changes as input moves away from the center. 5. Continuity and Differentiability: Logistic functions are typically continuous and differentiable everywhere within their domain. This is important for many applications, including optimization and gradient-based algorithms. The most common form of the logistic function is the sigmoid function, which is given by: f(x) = 1/(1+e^-x) this function satisfies all above mentioned criterias sinh(x): It is not a valid logistic function. It does not exhibit an S-shaped curve, and its output range is not constrained within 0 and 1. sinh(x) = (e^x – e^(-x)) / 2cosh(x): It is not a valid logistic function either it lacks the S-shaped curve and the constrained output range between 0 and 1. cosh(x) = (e^x + e^(-x)) / 2tanh(x) : It is a valid logistic function. It exhibits an S-shaped curve and its output range is between -1 and 1. While it’s not constrained between 0 and 1, it still meets the criteria of an S-shaped curve and constrained range. tanh(x) = (e^x – e^(-x)) / (e^x + e^(-x))signum(x) : It is not a valid logistic function. It produces discrete outputs of -1, 0, and 1, and does not exhibit an S-shaped curve.(c) For very sparse datasets, the “Leave-One-Out Cross-Validation” (LOOCV) technique can be beneficial. LOOCV is particularly advantageous when dealing with sparse data because it utilizes each data point for validation individually, which helps in making the most of the limited available data. Leave-One-Out Cross Validation (LOOCV) is a model validation technique where a single sample from the dataset is used as the test set, and the remaining samples are used as the training set. The process is repeated n times, where n is the number of samples in the dataset. Each sample is used once as the test set and the model is trained on the remaining n-1 samples. The average performance score across all n iterations is used to validate the model. Difference from K-Fold Cross-Validation: In K-Fold Cross-Validation, the dataset is divided into K subsets (folds), and the model is trained K times, each time using K-1 folds for training and the remaining fold for validation. (d)(e) In the simple linear regression model: Y = α + βx + εSo, the correct answer is: (a) α, β, σ, because we can express ε in terms of σ hence we will directly estimate σ instead of ε (also clear from above formula) (f) Given data: X = [20, 30, 50, 60, 80, 90] Y = [125, 110, 95, 90, 110, 130]As clear from the above scatter plot we can observe an upward parabola so the coefficient of x^2 should be positive (β2 >0) hence option (d) Y= α + β1x + β2×2+ε β2 > 0 is correct. SECTION – B (a) Brief explanation of what the code does: 1. LogisticRegression Class: This class represents the logistic regression model. It has methods for sigmoid activation, cross-entropy loss calculation, training the model using SGD, and testing the model’s performance. 2. Sigmoid Function: The sigmoid function calculates the sigmoid activation of a given input z . 3. Cross-Entropy Loss: The cross_entropy_loss function computes the binary crossentropy loss between true labels ( y_true ) and predicted probabilities ( y_pred ). It also includes numerical stability improvements using epsilon. 4. Training: The train method trains the logistic regression model. It iterates through the training data for a specified number of iterations using SGD. In each iteration, it calculates the gradient of the loss with respect to the model’s parameters and updates the model’s parameters accordingly. It also calculates and tracks training and validation losses and accuracies during training. 5. Testing: The test method evaluates the trained model on a test dataset. It computes metrics such as accuracy, precision, recall, F1 score, and a confusion matrix. 6. Data Loading and Preprocessing: The code loads a dataset from a CSV file, separates features and labels, standardizes the features, and adds a bias term. 7. Hyperparameters: It allows the user to specify the learning rate and the number of training iterations. 8. Training and Visualization: It initializes the logistic regression model, trains it using the training data, and visualizes the training and validation loss and accuracy over iterations using matplotlib. 9. Testing and Metrics: Finally, it evaluates the trained model on a test dataset and prints out the confusion matrix, accuracy, precision, recall, and F1 score to assess the model’s performance. In each epoch of stochastic gradient descent I have calculated Training loss, validation loss, Training accuracy and Validation accuracy. Convergence : Model converges early for a high learning rate and converges late for a low leaning rate Comparison and analysis of plot:- (b) & (c) Learning rate = 1Confusion matrix: [[17, 14], [5, 42]] Accuracy: 0.7564102564102564 Precision: 0.7727272727272727 Recall: 0.5483870967741935 F1 Score: 0.32075471698113206 Learning rate = 0.1Confusion matrix: [[14, 17], [3, 44]] Accuracy: 0.7435897435897436 Precision: 0.8235294117647058 Recall: 0.45161290322580644 F1 Score: 0.29166666666666663 Learning rate = 0.01Confusion matrix: [[18, 13], [3, 44]] Accuracy: 0.7948717948717948 Precision: 0.8571428571428571 Recall: 0.5806451612903226 F1 Score: 0.34615384615384615 Learning rate = 0.001Confusion matrix: [[24, 7], [18, 29]] Accuracy: 0.6794871794871795 Precision: 0.5714285714285714 Recall: 0.7741935483870968 F1 Score: 0.3287671232876712 Analysis : As we decrease the learning rate steepness of loss and training graph decreases (graph becomes more smooth for decreasing learning rate) and we attain maximum accuracy and precision at 0.01 learning rate. (d) Just the modified the loss function by adding a penalty term New loss functions are:- Lasso regression: y_true*log(y_pred) + (1-y_true)*log((1-y_pred)) + λ* ∑∣wj∣where λ is L1 regularization parameter. This is the additional part specific to Lasso regression. It adds the absolute values of the coefficients (weights) of the features, multiplied by a regularization parameter (λ), to the loss function. gradient of this new loss function is (pedictions – y_i)*x_i + λ*(sign(weight)) Ridge regression: y_true*log(y_pred) + (1-y_true)*log((1-y_pred)) + λ* ∑(wj^2)where λ is L2 regularization parameter. This is the additional part specific to Ridge regression. It adds the sqaured values of the coefficients (weights) of the features, multiplied by a regularization parameter (λ), to the loss function. gradient of this new loss function is (pedictions – y_i)*x_i + 2λ*weight Used (0.001, 0.01, 0.1, 1, 10) values for penalty term in both Lasso and Ridge regression and got Best l1_penalty: 0.1 Best l2_penalty: 0.001 (Lasso regression for best L1 penalty):(Ridge regression for Best L2 penalty):(e) tanh(x) = (e^x – e^(-x)) / (e^x + e^(-x)) range of tanh(x) is [-1,1] so we adjust the range with a new function f(x) = (1+tanh(x))/2 to [0,1] and use the same loss function f(x) is simplified to be 1/(1+e^-2x) loss = y*log(f(x))+(1-y)*log(1-f(x)) gradient = 2*(f(x) – yi) * xi Smoothest graph for learning rate = 0.001 There is not much difference between the performance of model for using tan hyperbolic instead of sigmoid(f) Batch size = 2Batch size = 5Batch size = 8Batch size = 15As we increase the Batch size loss decreases more slower and acuuracies increase more slower In Normal SGD batch size = 1 so loss decreases more rapidly and accuracy increases more rapidly hence model converges earlier and for any other batch size as we increase the Batch size loss decreases more slower and acuuracies increase more slower so model will not converge too earlier as compared to SGD. SECTION – C (a) Insights: As engine size increases CO2 emission increases Fuel consumption comb (mpg) between 20 and 30 are in majority As fuel consumption comb (mpg) increases CO2 emission decreases As the number of cylinders increase Fuel consumption comb (mpg) decreases As Fuel Consumption comb (L/100 km) increases Fuel Consumption comb (mpg) decrease Fuel type X are in majority and Fuel type E has highest median (b)From above t-SNE Scatter plot data is separable in some regions overall data is not well separable (c)(d)As the number of components inceases Errors parameters decrease and R2 score increases and ence model’s preformance is increasing (e) After one hot encoding (it creates different coloumns for categorical features)In part (c) difference between train and testing error is very small and R2 score is close to 1 and hence overall performance of model is much better than (e) (f)As the number of component in PCA increases Train and Test MSE,RMSE, decreases and Test R2 score increase. (g)MSE, RMSE and MAE for Lasso is greater than RIdge, While R2_score, Adjusted_R2_score for Ridge is greater than Lasso (h)Performance is almost same as (c)