Processing math: 100%
Skip to main content

[Machine Learning]: #7 Classification Introduction


[Machine Learning] #7 Classification Introduction


****************************************
[What is Classification Problem]:
if or not problem/ yes or no problem.
Is it a spam email? Are you a good boy? Do you like this girl?...... 

[Logistic Regression Model]:
Linear Regression performs badly in the classification problems. because the classification problem is not 'Continuous'. Intuitively, it also doesn't make sense for Hθ(x) which is larger than 1 or smaller than 0 we when knowing the y={0,1}, y is just 0 or 1.
So we try to make the value of  Hθ(x) between 0 and 1, how can we do that? Yes, Logistic Function.
Hθ(x)=g(θTx)
z=θTx
g(z)=11+ez
And the following image shows that what the function looks like:
[What does the funtion means]:
Hθ(x) gives us the probability that the output is 1.
For example.  Hθ(x)=0.8 means that we have 80% probability that the output is 1, on the contrary, the output is 0 's probability is 0.3. We use P(y=1|x;θ)=0.8 to represent that the probabilty of y=1 is 0.8 in the case of x and θ.

[Decision Bounary]:
In order to get our discrete 0 or 1 classification, we can translate the output of the hypothesis function Hθ(x) as follows:
when, 
Hθ(x)0.5>class1Hθ(x)<0.5>class2
So, what does it means?
Hθ(x)=g(θTx)0.5class1
which means
θTx0class1
From the above statments we can say that:
θTx0class1θTx<0class2
The Decision Boundary is the line to seperate the area where y=0 and y=1.

[An Example]:
In this case, if we consider that when θTx0class1
then x12+x221
[How to find the Decision Boundary ?]:

Please check the next [Machine Learning]#8







Comments

Popular posts from this blog

[LeetCode Solution 230]: Kth Smallest Element in a BST

Question: Given a binary search tree, write a function  kthSmallest  to find the  k th smallest element in it. ************************************************************************************************************************************ Write Infront To read to a tutorial, please to read the tutorial of in-order traversal of BST, please check: LeetCode Solution 94: Binary Tree Inorder Traversal We are going to solve this question using the following 4 methods: ->Binary Search ->Recursive ->Iterative ->Morris  Approach #1 Binary Search [Accepted] Detail Explanation The first method to solve this problem is using Binary Search. The idea is very easy and extremely to think. We use BST's property that the left child of the root is smaller than the root while the right child of the root is always bigger. We consider that the root is the pivot, and find the number of the nodes in the left subtree and the number of ...

[LeetCode Solution 145] Binary Tree Postorder Traversal

[LeetCode Solution 145]: Binary Tree Postorder Traversal Question: Given a binary tree, return the  postorder  traversal of its nodes' values. For example: Given binary tree  {1,#,2,3} , 1 \ 2 / 3 return  [3,2,1] . Approach #1 Recursive [Accepted] Detail Explanation The first method to solve this problem is using recursive. This is the classical method and straightforward. we can define a helper function to implement recursion. The java code is as follows: Java public class Solution { public List<Integer> postorderTraversal (TreeNode root) { List<Integer> res = new ArrayList<>(); helper(root, res); return res; } public void helper (TreeNode root, List<Integer> res) { if (root != null ) { if (root.left != null ) { helper(root.left, res); } if (root.right != null ) { helper(root.right, res); } res.add(root.val); } } } Complexity Analysis Ti...

[Interview]: URLify

[Interview]  URLify: -------------------------------------------------------------------------------------------------------------------------- Question: URLify: Write a method to replace all spaces in a string with ‘%20’, you may assume that the string has sufficient space at the end to hold the additional characters. Example  input: ' mr john smith '  output: ' mr %20john%20smith' --------------------------------------------------------------------------------------------------------------------------   Idea 1:  Start from the back and start replacing until the character is not ' ', and replace the characters in reverse order. Solution 1: public class Solution{ public String replace(char[] str) { boolean flag = false; StringBuffer sb = new StringBuffer(); for (int i = str.length - 1; i >= 0; i--) { if (str[i] != ' ') flag = true; if (flag == true) { if (str[i] == ' ') { s...