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.

1. Can add any private attribute or functions needed

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:...))))

Thank you so much!

Can you read the following code and try to complete the TODOin class HomogeneousCriterion(Criterion), class HeterogeneousCriterion, and class LonelyMemberCriterion. If there is anypart that you are unsure about, mark it out if possible. Pleaseupload answer in screenshots or in proper indentation. 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 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 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!