Friday 17 May 2019

Creating Custom Goal event for capturing payment value from web page

Hey guys,

Recently i started working on Google analytics and capturing events.

To make it so precise.

1. You guys must know and configured Tag manager Google Tag Manager for a site. Tag manger is wonderful tool to capture all events instead of creating them and triggering from code.

Instead of sending a event like
ga('send', 'event', 'Signup Form', 'submit', {
    hitCallback: function() {
      form.submit();
    }
  });
You can create a Tag in tag manager with trigger and Data Layer variables.

Naming Conventions and details about Tag manager : Here

Creation of custom event in tag manager :  Here


Set up to Creation of Tags : Here
 
   >  While creating tags , you will be specifying  Category, Action , Label and Value.

 >  My case i gave Category = payment , Action = on click of payment btn , Label = 'payment-price'  , value = Datalayer varible which will be passed from website via dataLayer.push() function.

  > You must link the google analytics UID here at the creation of Tag under Google Analytics Settings. or check the Enable overriding settings in this tag and give your GA Tracking ID.

Now i hope you guys are clear with tags creation , data layer variables and triggers :

> Lets port the event data we send from website to Goals now.

       creation of custom goals in google analytics : Here

Once you created the Goal and select Goal event fields :

>  You have Category, Action , Label and Value . Among these you can specify one or more conditions.

My case i would like to see overall category wise . so i gave only category == 'payment' (should be same as tag category value u created in tag manager.)

       Now , you can trigger event from the code like this .



dataLayer.push({
'event': 'onpaymentsuccess', // Event name you created as Custom Trigger
'payment-price': 7.8 // payment value u wanna pass . payment-price is data
layer variable defined in the Tag
});

   Now if you goto your GA dashboard and

  > Conversions > Goals > Overview > you must be able to see the event as a goal and its corresponding value.



 If you guys want complete Video on this : Create Custom Goal event










Tuesday 7 May 2019

Confusion Matrix Scikit Learn

Hey Guys,

I just started working on one of machine learning project in which i used python with few libraries.

One among them is Scikit-Learn which is amazing tool for doing machine learning techniques like
data preprocessing and data mining.

Official link to the site https://scikit-learn.org/stable/

In this today we talk about confusion matrix:

So , Basically we used some of the classification algorithms of scikit to classify the test data based on trained data.

A basic example if we take from scikit site :

Confusion_Matrix :
>>> from sklearn.metrics import confusion_matrix
>>> y_true = [2, 0, 2, 2, 0, 1]
>>> y_pred = [0, 0, 2, 2, 0, 2]
>>> confusion_matrix(y_true, y_pred)
array([[2, 0, 0],
       [0, 0, 1],
       [1, 0, 2]])

Now , consider this example where system predicted values [y_pred] are  [0, 0, 2, 2, 0, 2] but real values are

Here the classes (nothing but the values are 0,1,2)
so Lets put matrix like this


Predicted 0 1 2
True

0 2 0 0

1 0 0 1

2 1 0 2


How it is formed:

Lets take the true values array : [2, 0, 2, 2, 0, 1]. Lets go one by one
for 2 : y_pred array first element is 0 --> its predicted in-correctly. put 1 for (2,0)

for 0 : y_pred array second element is 0 --> its predicted correctly . put 1 for
(0,0)

for 2: y_pred array third element is 2 --> its predicted correctly . put 1 for
(2,2)

for 2: y_pred array fourth element is 2 --> its predicted correctly . increment 1 for (2,2) which becomes 2.

for 0: y_pred array fifth element is 0 --> its predicted correctly . increment 1 for (0,0) which becomes 2.

for 1: y_pred array sixth element is 2 --> its predicted in-correctly . put 1 for


(1,2)


Now you if you see the matrix diagonal, all are correct predicted values.

Hope you got it now. Thanks :)