Question: Can you read the following code and try to complete the TODO in class HomogeneousCriterion(Criterion), class HeterogeneousCriterion, and class LonelyMemberCriterion. If there is any part

Can you read the following code and try to complete the TODO in class HomogeneousCriterion(Criterion), class HeterogeneousCriterion, and class LonelyMemberCriterion. If there is any part that you are unsure about, mark it out if possible. Please upload answer in screenshots or in proper indentation. At last, please do not just copy a wrong answer from others.

1. Can add any private attribute or methods if needed

if you add any private abstract method to Criterion class and other class all inherit from this you have to implement all abstract method!

2. Can inherit from other class in file instead of Criterion if that is easier

3. try to not have loop if layers more than 4. example: (if:(if:(for:(if:...))))

4. can add a __eq__ to compare if needed!

Thank you so much!

Explanation:

1. HomogeneousCriterion: looks at the similarity, add the similarity of every two answers of all answers to take the average

2. HeterogeneousCriterion: 1 - HomogeneousCriterion's result. (Inheritance!!!)

3. LonelyMemberCriterion: if answer contains any unique answer( 0or 1) if there exists only one answer that is uniqueit is 0

if there exists two answerssame then no uniquenot the same then it is unique

2 2 4 4 4, not uniqueso it is 1

2 2 4 4 4 3, one uniqueso result is 0

Can you read the following code and try to complete the TODO

in class HomogeneousCriterion(Criterion), class HeterogeneousCriterion, and class LonelyMemberCriterion. If there is any

u can still make changes to class Criterion above if needed

part that you are unsure about, mark it out if possible. Pleaseupload answer in screenshots or in proper indentation. At last, please donot just copy a wrong answer from others. 1. Can add any

import ... if TYPE_CHECKING : from survey import Question, Answer Class InvalidAnswerError(Exception): "" "Error that should be raised when an answer is invalid for a given question. n"n Blass Criterion: "" "An abstract class representing a criterion used to evaluate the quality of a group based on the group members' answers for a given question. n"n def score_answers(self, question: Question, answers: list[Answer]) float: """Return score between . and 1. indicating how well the group of to the question satisfy this Criterion. Raise InvalidAnswerError if any answer in is not a valid answer to . Each implementation of this abstract class will measure satisfaction of a criterion differently. " " " raise NotImplementedError Version contral integration class HomogeneousCriterion(Criterion): "" "A criterion used to evaluate the quality of a group based on the group members' answers for a given question. This criterion gives a higher score to answers that are more similar. n"n def score_answers(self, question: Question, answers: list[Answer]) float: "" "Return a score between . and 1.0 indicating how similar the answers in are. This score is calculated by finding the similarity of every combination of two answers in and taking the average of all of these similarity scores. * Don't include a pair of answers twice while finding the similarity scores. For example, don't compare answer 1 and answer 2, then later compare answer 2 and answer 1. * Don't compare an answer with itself while computing the similarity scores. * Don't do any rounding. If there is only one answer in and it is valid, return 1.0 since a single answer is always identical to itself. answer to . Preconditions: - len(answers)>0 Problems D. Terminal Services ouilt Python packages shared indexes // Always download // Download once // Don't show again // Configure... (2023/3/1, 22:57) 85:1 LF UTF-8 4 spaces Python 3.10 A Python Console P Problems D. Terminal Services with pre-built Python packages shared indexes // Always download // Download once // Don't show again // Configu... (2023/3/1,22:57)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To complete the TODOs in the criterion classes lets look at how each class should ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!