Posts

Logistic Regression Code in Python for absolute beginners

Image
  Brief about Logistic Regression Algorithm When we need to predict o the class where the predicted variable has a set of defined values like yes or no, we use Logistic Regression.  Difference between Logistic and Linear Regression In Linear Regression, the value predicted variable is continuous whereas, in Logistic Regression, the value predicted variable is discrete. Maths behind Logistic Regression Logistic Regression uses the Sigmoid function.  Its maximum value is  1  & the minimum value is  0  and  'e'  is Euler's number which is equal to  2.71828. now to perform classification in Logistic Regression, we replace z by the equation of a straight line, modifying the function to Note - to understand the equation of a straight line read   Linear Regression Code in Python for absolute beginners. How Classification is done? When the value of the function comes out to be  more than 0.5  then it will be class A and when...

Linear Regression Code in Python for absolute beginners.

Image
Brief about Linear Regression Algorithm In Linear Regression, there is one independent variable(x) and one dependent variable(y). Linear Regression assumes that there is a linear relationship between the independent variable x and dependent variable y.  The linear Regression algorithm tries to fit the equation of a straight line on to our data points.  y=mx+c where,  y= Dependent variable x= Independent variable m= Slope of the line c= y-intercept Training our Machine The machine will be trained on the training data set and the machine will compute the equation of line based on those data points ie. finding values of slope(m) and y-intercept(c). Predicting Dependent variable Now, as our machine is trained on the training data set, we can predict the values of the dependent variable and compare it against the actual values on our testing data set.  To check whether the machine is predicting accurate or not, we calculate the accuracy of the prediction. Code for Linear ...