GithubHelp home page GithubHelp logo

visitishan / navigation-path-prediction-and-probability Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 17 KB

Library to find the Probability Estimation of Navigation Paths and their Pattern Prediction.

Python 100.00%
transition-matrix transition-probability state state-estimation probability probability-calculator path-probabilities path-predictions markov path

navigation-path-prediction-and-probability's Introduction

Navigation Path Probability Estimation and Pattern Prediction

Build Status Build Status Build Status Build Status Build Status

A library to find the Probability Estimation of Navigation Paths and their Pattern Prediction.

The library helps in identifying the high probability trail path in a data. This navigation probability provides the means to analyze and predict the next link choice of unseen navigation sessions. Currently, the library allows three types of probability estimation from the path data -

  • State Probability
  • Transition Probability
  • Path or Trail Probability

State Probability -

The initial probability of a state is estimated as the proportion of times the corresponding state was requested by the user. This probability is obtained by dividing the number of times a state was browsed by the total number of states browsed.

Transition Probability -

The probability of a transition between two states is estimated by the ratio of the number of times the sequence was visited to the number of total paths where the from page was visited.

Path or Trail Probability -

The probability of a trail is estimated by the product of the initial probability of the first state in the trail and the transition probabilities of the next transitions taken in a path. The chain rule is applied in order to compute all path probabilities.

How to use -

For the probability estimations

import pandas as pd
import path_nav as nv

data = {
	"other_data": [1,4,5],
    "path": [
    	["A", "B", "C", "A", "C"],
    	["B", "D", "B", "A"],
    	["A", "C", "B", "A", "D"]
    ],
    "conversions": [0, 0, 1],
}

df = pd.DataFrame(data)
print(df)
   other_data             path  conversions
0           1  [A, B, C, A, C]            0
1           4     [B, D, B, A]            0
2           5  [A, C, B, A, D]            1
# To find the state probability
state_probability = nv.state_probability(df, 'path')
print(state_probability)
  State  State_probability
0     D           0.142857
1     A           0.357143
2     C           0.214286
3     B           0.285714
# To add the start and conversion values to the path (optional)
df = nv.add_start_end(df,'path','conversions')
print(df)
   other_data                                path  conversions
0           1        [start, A, B, C, A, C, exit]            0
1           4           [start, B, D, B, A, exit]            0
2           5  [start, A, C, B, A, D, conversion]            1
# To find the transition probability
transition_df = nv.transition_probability(df, 'path')
print(transition_df)
from_sitesection to_sitesection  transition_probability
             B           exit                0.000000
             B     conversion                0.000000
             B              D                0.333333
             B              A                0.666667
             B              C                0.333333
             D           exit                0.000000
             D     conversion                0.500000
             D              B                0.500000
             D              A                0.000000
             D              C                0.000000
         start           exit                0.000000
         start     conversion                0.000000
         start              B                0.333333
         start              D                0.000000
         start              A                0.666667
         start              C                0.000000
             A           exit                0.333333
             A     conversion                0.000000
             A              B                0.333333
             A              D                0.333333
             A              C                0.666667
             C           exit                0.500000
             C     conversion                0.000000
             C              B                0.500000
             C              D                0.000000
             C              A                0.500000
# To find the path probability
path_df = nv.path_probability(df, 'path', transition_df)
print(path_df)
   other_data                                path  conversions  path_probability
0           1        [start, A, B, C, A, C, exit]            0          0.012346
1           4           [start, B, D, B, A, exit]            0          0.012346
2           5  [start, A, C, B, A, D, conversion]            1          0.024691

Additional functions -

# To convert the path column to string data type
df = nv.convert_to_str(df, "path")


# To convert the path column to list data type
df = nv.convert_to_list(df, "path")

navigation-path-prediction-and-probability's People

Contributors

visitishan avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.