# Solve Machine Learning Mathmetical Problems | Sample Assignment

**1**. Consider a dataset with attributes ** x**,

**, and**

*y***where the decision attribute is**

*z,***. Suppose that we have determined that there are two**

*z***support vectors**: the

**point**

__2D__**(-7, 10)**which corresponds to an instance in the dataset that has

**= -7,**

*x***= 10, and**

*y***= -1, and the**

*z***point**

__2D__**(-6, 9)**which corresponds to an instance in the dataset that has

**= -6,**

*x***= 9, and**

*y***= 1.**

*z*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!

### Get help with an affordable prices if you face any problem in machine learning and send your request at __contact@codersarts.com__

__contact@codersarts.com__