Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 following in Python:

  1. 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.
  2. The code asks the user to enter two thresholds thx and thy.
  3. The code must use appropriate conditions to prevent common errors such as entering characters instead of numbers etc.
  4. 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 user-entered 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).
  5. Plot the data samples, the selected thx, and the thx lines.
  6. Create a loop to continuously repeat parts (4) to (5) and enter different sets of thresholds each time.
  7. The program will exit the loop once the user writes 'x' as an input for either threshold.
  8. 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.

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Accounting

Authors: Susan S. Hamlen, Ronald J. Huefner, James A. Largay III

2nd edition

1934319309, 978-1934319307

More Books

Students also viewed these Algorithms questions