top of page
Search

# Solve Machine Learning Mathmetical Problems | Sample Assignment

1. Consider a dataset with attributes x, y, and z, where the decision attribute is z. Suppose that we have determined that there are two support vectors: the 2D point (-7, 10) which corresponds to an instance in the dataset that has x = -7, y = 10, and z = -1, and the 2D point (-6, 9) which corresponds to an instance in the dataset that has x = -6, y = 9, and z = 1.

The equations for the support vector machine are shown below where s1 = (-7 10 1) is the augmented support vector for (-7, 10), s2 = (-6 9 1) is the augmented support vector for (-6, 9), and Î±1 and Î±2 are the respective parameters for the support vectors that will be used to define the 2D hyperplane.

Î±1Ï†(s1) â€¢ Ï†(s1) + Î±2Ï†(s2) â€¢ Ï†(s1) = -1

Î±1Ï†(s1) â€¢ Ï†(s2) + Î±2Ï†(s2) â€¢ Ï†(s2) = 1

For Ï†, use Ï†(x y) = ( x+y 10-y )

a. Solve for each Î±i showing ALL of your work! (2 pts.)

b. Using your results from part a., define the discriminating 2D hyperplane for this dataset; that is, give an equation for the 2D hyperplane. Show your work! (2 pts.)

c. Using the support vector machine you have defined, predict the value for the decision attribute (z) for an instance that has x = 2 and y = 5. Show your work! (2 pts.)

2. Write a Python function which, given a dataframe, constructs (and returns) a NaÃ¯ve Bayesian network.

You can assume that all of the attributes have nominal values and that the decision attribute is the last attribute in the dataframe.

Apply Laplace smoothing to the conditional probabilities of the attributes (as explained in class) using a value of Î» = 1.

Output the conditional probability table for each node in the Bayesian network so that your work can be checked!

Test your function by running it on contact-lenses.csv AND hypothyroid.csv (both of which are posted on Canvas with this assignment). Note that you can check your work by running Classify -> weka -> Classifiers -> bayes -> NaiveBayesSimple in Weka.

ALSO demonstrate that you have successfully created these particular Bayesian networks by executing code that predict the following:

For contact-lenses:

contact-lenses = soft, age = presbyopic, other attributes = None

For hypothyroid:

class = negative, sex = U, other attributes = None

Note: You will NOT get full credit for your solution if you hard-code your code to work just for the specified test datasets!