hw5solutions

pdf

School

University of Massachusetts, Amherst *

*We aren’t endorsed by this school

Course

210

Subject

Computer Science

Date

Jan 9, 2024

Type

pdf

Pages

6

Uploaded by DoctorPorpoiseMaster992

Report
ECE 241 – HOMEWORK 5 Fall 2023 Solution 1. Regular expressions. a) For the state machine shown in Figure 1, which of the following expression will result in a match? (The process starts at state 1 and can end in either state 4 or 6.) (6 Points) Figure 1 Choose from the following: de abcd abc*|d+k dec abc ddee Answer: de and abc b) List 4 additional valid expressions (not listed above) for the state machine shown in the figures! E.g., abcc is a valid expression. (Matching up to 6 letters is sufficient!) Answer: 1 2 3 4 5 a b c d d e
abc, de, dde, abcc c) Create a state machine (similar to the one shown in Figure 1) that matches the regular expression ab*a and a second one that matches the regular expression ( a|b)c Answer: d) Write a version for the class Edge that represents an edge in a finite state machine. class Edge: def __init__ ( self , c , dest): Answer: class Edge: def __init__ ( self , c , dest): self .destination = dest self .character = c e) Complete the missing lines in the code for the class Vertex that represents a vertex in a finite state machine. (10 points) class Vertex: def __init__ ( self , n): self . number = n self . edgeList = [] self .isAcceptingState = def setAcceptingState ( self ):
def addEdge ( self , e): def followEdge ( self , c): return Answer: class Vertex: def __init__ ( self , n): self . number = n self . edgeList = [] self .isAcceptingState = None def setAcceptingState ( self ): self .isAcceptingState = True def addEdge ( self , e): self .edgeList.append(e) def followEdge ( self , c): for i in self .edgeList:
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
if i.character == c : return i.destination return None 2. Machine Learning (50 pts) We have seen that Linear Regression is one of the many approaches to build a model in Machine Learning, which can be used to predict labels based on a certain set of features. a. [35 points] A Linear Regression example is shown below. First specify the general equation that defines the Mean Square Error. Based on that equation calculate the Mean Square Error. To allow us to give you partial credit, calculate the error value for each data point and use these values for your Mean Square Error. X-Axis Y-Axis Error MSE 1 2 3 4 5 6 7 0 2 4 6 8 10 12 14 16 0 2 4 6 8 10 12 Chart Title
8 9 10 Total MSE: Answer: b. [10 points] The example below shows one potential model for the data points (shown as red dots). Can this model be improved? If so, draw a new line that represents the improved model in the figure and explain why it is a better model. X-Axis Y-Axis MSE 1 1 0 0 2 3 -1 1 3 2 1 1 4 6 -2 4 5 4 1 1 6 8 -2 4 7 5 2 4 8 8 0 0 9 11 -2 4 10 14 -4 16 3.5
Answer: c. [5 points] and Given a dataset that contains the information shown below. Your goal is to develop a Machine Learning approach that predicts chance of heart disease. Based on the given information in the table below, which columns identify potential features, which identify labels? Weight Diet Blood Pressure Age High Cholesterol Chance of Heart Disease Answer: All columns besides the last one are potential features. Last one is the label 0 2 4 6 8 10 12 14 16 0 2 4 6 8 10 12 Chart Title 0 2 4 6 8 10 12 14 16 0 2 4 6 8 10 12 Chart Title
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help