Question: problem 1 and 2 please Problem 1) Simple Boolean logic operations. Assume we have four input data samples {(0,0), (0,1),(1,0),(1,1)} to a model. Perform the

Problem 1) Simple Boolean logic operations. Assume we have four input data samples {(0,0), (0,1),(1,0),(1,1)} to a model. Perform the followings in Python: a) Plot the four input data samples. Label the axes and title as appropriate. b) Write a function that takes two arguments as an input and performs AND operation. The function returns the result to the main program. c) Write two additional functions like in part (b); each would perform OR and XOR operations and return the result to the main program. d) Create a for loop to call the three functions each for data sample each time. e) Store the output of each function in a separate list/array. f) Print out the results for the three functions at the end of your program. g) Note: do not use the internal Boolean (AND, OR, XOR) functions in Python; instead, utilize conditional statements to perform the desired operations. Problem 2) Threshold-based Classifier. We have a two-class classification problem (i.e., C1 and C2). Each data sample is represented by two attributes (x,y). The three data samples in class C1 are {(2,3),(3,3),(3,4),(1,4),(4,1),(4,3)} and {(0,0),(0,3),(1,1),(1,2),(2,1),(2,2)} in class C2. Perform the followings in Python: a) Plot the data samples. The data points in classes C1 and C2 must be in two different colors and shapes. Label the axes and add legends as appropriate. b) The code asks the user to enter two thresholds hhx and thy. c) The code needs to use appropriate conditions to prevent common errors such as entering characters instead of numbers etc. d) Your code calculates and prints the training accuracy based on the user-entered thresholds. To do so, assume that for any data point (x,y) with x>=thx and y>=thy, the data sample belongs to class C1, and C2 if otherwise. Using this rule and the userentered thresholds, the code calculates the classification accuracy for the six data samples. The classification accuracy is defined as the number of correctly classified data points divided by the total number of data points ( 12 here). e) Plot the data samples, the selected thx, and the thx lines. f) Create a loop to continuously repeat parts (d) to (e) and enter different sets of thresholds each time. g) The program will exit the loop once the user writes ' x ' as an input for either threshold. h) Based on your observation from the results above, what is a suitable set of thresholds that will give the highest accuracy? Report your suggested thresholds and the corresponding classification accuracy. i) Tip: create separate functions for threshold entry, classification, accuracy calculation and plotting. Set the x and y axes ranges between [1,5] in your plots
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
