Skip to main content

Posts

Showing posts from May, 2021

%matplotlib inline vs %matplotlib notebook

While working on exploring a data set you might all definitely need to visualize the different features and for that you will import matplotlib. But while importing matplotlib we sometimes happen to write either  %matplotlib inline or %matplotlib notebook in our Jupyter notebook. Let us understand what they do. %matplotlib %matplotlib is one of the magic functions you can use in Jupyter notebook. The magic functions can be used to add some dynamic capabilities to the outputs we get, as in general the output of these plots look more like reports. Writing the above magic function sets up necessary background features for python to work with matplotlib. %matplotlib inline %matplotlib inline is used to display the plots inline and on the next cell below the code which outputs the plot. It is used to store the plots in the notebook itself. So if the next time after saving the work done in the notebook, if you again wish to see the visualizations, it will still be available in the notebook

%matplotlib inline vs %matplotlib notebook

While working on exploring a data set you might all definitely need to visualize the different features and for that you will import matplotlib. But while importing matplotlib we sometimes happen to write either  %matplotlib inline or %matplotlib notebook in our Jupyter notebook. Let us understand what they do. %matplotlib %matplotlib is one of the magic functions you can use in Jupyter notebook. The magic functions can be used to add some dynamic capabilities to the outputs we get, as in general the output of these plots look more like reports. Writing the above magic function sets up necessary background features for python to work with matplotlib. %matplotlib inline %matplotlib inline is used to display the plots inline and on the next cell below the code which outputs the plot. It is used to store the plots in the notebook itself. So if the next time after saving the work done in the notebook, if you again wish to see the visualizations, it will still be available in the notebook

Gradient Boosting Classifier

Gradient Boosting is one of the Boosting Ensemble methods that has been used a lot lately in both regression and classification problems. As the heading suggests we are going to understand Gradient Boosting in classification. But first, let's have a brief introduction to what are ensemble methods. Ensemble Methods Ensemble methods are used in machine learning to create a better and more optimized model and it can do so by learning from other models. Ensemble method uses a sample of models with their results and combines them together to get a more optimized result and therefore it doesn't have to depend on a single predictive model. One of the ways to perform ensemble technique in a classification problem is to use Gradient Boosting Classifier. Gradient Boosting in classification In Gradient Boosting we have multiple decision trees and we use the individual tree to gather their predictions and then combine it with the next decision tree we build. Let's understand the workin

Log Loss Function: Performance of Logistic Regression

Logistic Regression (Binary classification) is used to classify data into two groups, where one group denoted by 0 and other by 1. And to check the performance of the logistic regression model, we use Log Loss function. Before understanding about the log loss function, we should first ask that why Mean Squared Error which is used in linear regression can't be used in logistic regression. Why Log Loss and not Mean Squared Error? Mean squared error is used to calculate the average of the squared difference between actual value and estimated value. When using mean squared error in logistic regression, it becomes very difficult and complex to apply Gradient Descent, which is used to optimize our model by finding the coefficients for different features to minimize the cost function. In logistic regression we use the hypothesis function to find estimated values which consist of all necessary features and their coefficients. This hypothesis function we use is similar to the sigmoid functi