RAPLER / dst-1

Combine basic probability assignments with Dempster's rule of combination
6 stars 3 forks source link

Compute belplau of selected subsets #8

Closed RAPLER closed 1 year ago

RAPLER commented 1 year ago

Can we restrict the computation of belplau to selected subsets6

garyzhubc commented 1 year ago

Right now it's hard to locate from the belplau table which rows are the added ones and which are the generic ones.

RAPLER commented 1 year ago

I show here how function "addTobca" works, and the link that can be done with function "belplau". For this, I have added the parameter "sort_order" to the result of function "addTobca".

1) Function addTobca search for duplicate entries. If there are duplicates, they are removed from the list of new entries.

2) the new entries are put on top of the old ones.

3) subsets are sorted to find if the empty subset is there and put the empty set in first position of the augmented tt matrix. The order of the sort is called "sort_order"

I have added the parameter "sort_order" to the output of function "addTobca to the resulting bca. It can be used in the following way to find the added rows in the belplau result by doing:

result <- belplau (x) # x is your bca

result[x$sort_order,] # the first rows should be the added rows.

Also you can do:

(bcaprint)[x$sort_order,] # the first rows should be the added rows, all with zero mass.

Le mer. 12 juil. 2023 à 19:36, Peiyuan Zhu @.***> a écrit :

Right now it's hard to locate from the belplau table which rows are the added ones and which are the generic ones.

— Reply to this email directly, view it on GitHub https://github.com/RAPLER/dst-1/issues/8#issuecomment-1633335802, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5D5IO4JOVPH32IM7IWF2DXP4YHRANCNFSM6AAAAAAYOFHGMI . You are receiving this because you authored the thread.Message ID: @.***>

garyzhubc commented 1 year ago

Should I do nzdsr(x) before addToBca or after or does this matter at all?

garyzhubc commented 1 year ago

Here's how I did it but it doesn't look like the first few rows are legit.

bpa <- readRDS("../data/bpa.rds")

upstream_lof <- rep(0,101)
upstream_lof[61:101] = 1
lof <- rep(0,ncol(bpa$tt))
lof[40:60] = 1
downstream_lof <- rep(0,101)
downstream_lof[1:39] = 1

tt_<-rbind(upstream_lof,lof,downstream_lof)

bpa_mid<-addTobca(nzdsr(bpa),tt_)
bel_bpa_mid <- belplau(bpa_mid)
bel_bpa_mid_sort<-bel_bpa_mid[bpa_mid$sort_order,]
garyzhubc commented 1 year ago

I think the result is sorted by indices of strings

garyzhubc commented 1 year ago

I'm using R 4.1.3 latest of all packages.

RAPLER commented 1 year ago

A parameter "status" has been added to the "spec" of the bca in order to distinguish the new subsets added from the ones already present. It will allow to extract only the new subsets added.

result <- belplau (x) # x is your bca

result <- cbind(result, x$spec) # add the spec element to the table

result[which(result[,ncol(result)] == 1),] # will give the results for the new rows (subsets) only

It does'n matter if you do nzdsr(x) before addToBca or after. Personnally, I would do addTobca after, siince I don't need to normalize subsets with 0 mass

garyzhubc commented 1 year ago

From:

bpa <- readRDS("../data/bpa.rds")

upstream_lof <- rep(0,101)
upstream_lof[61:101] = 1
lof <- rep(0,ncol(bpa$tt))
lof[40:60] = 1
downstream_lof <- rep(0,101)
downstream_lof[1:39] = 1

tt_<-rbind(upstream_lof,lof,downstream_lof)

bpa_mid<-addTobca(nzdsr(bpa),tt_)
bel_bpa_mid <- belplau(bpa_mid)
bel_bpa_mid_ <- cbind(bel_bpa_mid, bpa_mid$spec)
bel_bpa_mid_[which(bel_bpa_mid_[,ncol(bel_bpa_mid_)] == 1),]

I got:

bel_bpamid[which(bel_bpamid[,ncol(bel_bpamid)] == 1),] Belief Plausibility Plty Ratio specnb mass

which is an empty matrix.

On Thu, Jul 13, 2023 at 6:44 PM Claude Boivin @.***> wrote:

A parameter "status" has been added to the "spec" of the bca in order to distinguish the new subsets added from the ones already present. It will allow to extract only the new subsets added.

result <- belplau (x) # x is your bca

result <- cbind(result, x$spec) # add the spec element to the table

result[which(result[,ncol(result)] == 1),] # will give the results for the new rows (subsets) only

It does'n matter if you do nzdsr(x) before addToBca or after. Personnally, I would do addTobca after, siince I don't need to normalize subsets with 0 mass

— Reply to this email directly, view it on GitHub https://github.com/RAPLER/dst-1/issues/8#issuecomment-1635137448, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHHVV36TY636XE3TGK52FV3XQCP65ANCNFSM6AAAAAAYOFHGMI . You are receiving this because you commented.Message ID: @.***>

garyzhubc commented 1 year ago

Ok maybe let me try reloading the package.

On Thu, Jul 13, 2023 at 7:05 PM Peiyuan Zhu @.***> wrote:

From:

bpa <- readRDS("../data/bpa.rds")

upstream_lof <- rep(0,101)
upstream_lof[61:101] = 1
lof <- rep(0,ncol(bpa$tt))
lof[40:60] = 1
downstream_lof <- rep(0,101)
downstream_lof[1:39] = 1

tt_<-rbind(upstream_lof,lof,downstream_lof)

bpa_mid<-addTobca(nzdsr(bpa),tt_)
bel_bpa_mid <- belplau(bpa_mid)
bel_bpa_mid_ <- cbind(bel_bpa_mid, bpa_mid$spec)
bel_bpa_mid_[which(bel_bpa_mid_[,ncol(bel_bpa_mid_)] == 1),]

I got:

bel_bpamid[which(bel_bpamid[,ncol(bel_bpamid)] == 1),] Belief Plausibility Plty Ratio specnb mass

which is an empty matrix.

On Thu, Jul 13, 2023 at 6:44 PM Claude Boivin @.***> wrote:

A parameter "status" has been added to the "spec" of the bca in order to distinguish the new subsets added from the ones already present. It will allow to extract only the new subsets added.

result <- belplau (x) # x is your bca

result <- cbind(result, x$spec) # add the spec element to the table

result[which(result[,ncol(result)] == 1),] # will give the results for the new rows (subsets) only

It does'n matter if you do nzdsr(x) before addToBca or after. Personnally, I would do addTobca after, siince I don't need to normalize subsets with 0 mass

— Reply to this email directly, view it on GitHub https://github.com/RAPLER/dst-1/issues/8#issuecomment-1635137448, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHHVV36TY636XE3TGK52FV3XQCP65ANCNFSM6AAAAAAYOFHGMI . You are receiving this because you commented.Message ID: @.***>

garyzhubc commented 1 year ago

Ok it looks like I'll need to redo the combination fully since you changed bca. Is there a way to get away with this? The whole combination takes a long time but I don't think we necessarily need to do that. :)

On Thu, Jul 13, 2023 at 7:07 PM Peiyuan Zhu @.***> wrote:

Ok maybe let me try reloading the package.

On Thu, Jul 13, 2023 at 7:05 PM Peiyuan Zhu @.***> wrote:

From:

bpa <- readRDS("../data/bpa.rds")

upstream_lof <- rep(0,101)
upstream_lof[61:101] = 1
lof <- rep(0,ncol(bpa$tt))
lof[40:60] = 1
downstream_lof <- rep(0,101)
downstream_lof[1:39] = 1

tt_<-rbind(upstream_lof,lof,downstream_lof)

bpa_mid<-addTobca(nzdsr(bpa),tt_)
bel_bpa_mid <- belplau(bpa_mid)
bel_bpa_mid_ <- cbind(bel_bpa_mid, bpa_mid$spec)
bel_bpa_mid_[which(bel_bpa_mid_[,ncol(bel_bpa_mid_)] == 1),]

I got:

bel_bpamid[which(bel_bpamid[,ncol(bel_bpamid)] == 1),] Belief Plausibility Plty Ratio specnb mass

which is an empty matrix.

On Thu, Jul 13, 2023 at 6:44 PM Claude Boivin @.***> wrote:

A parameter "status" has been added to the "spec" of the bca in order to distinguish the new subsets added from the ones already present. It will allow to extract only the new subsets added.

result <- belplau (x) # x is your bca

result <- cbind(result, x$spec) # add the spec element to the table

result[which(result[,ncol(result)] == 1),] # will give the results for the new rows (subsets) only

It does'n matter if you do nzdsr(x) before addToBca or after. Personnally, I would do addTobca after, siince I don't need to normalize subsets with 0 mass

— Reply to this email directly, view it on GitHub https://github.com/RAPLER/dst-1/issues/8#issuecomment-1635137448, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHHVV36TY636XE3TGK52FV3XQCP65ANCNFSM6AAAAAAYOFHGMI . You are receiving this because you commented.Message ID: @.***>

garyzhubc commented 1 year ago

Wait no it's just addToBca so let me try again.

On Thu, Jul 13, 2023 at 7:12 PM Peiyuan Zhu @.***> wrote:

Ok it looks like I'll need to redo the combination fully since you changed bca. Is there a way to get away with this? The whole combination takes a long time but I don't think we necessarily need to do that. :)

On Thu, Jul 13, 2023 at 7:07 PM Peiyuan Zhu @.***> wrote:

Ok maybe let me try reloading the package.

On Thu, Jul 13, 2023 at 7:05 PM Peiyuan Zhu @.***> wrote:

From:

bpa <- readRDS("../data/bpa.rds")

upstream_lof <- rep(0,101)
upstream_lof[61:101] = 1
lof <- rep(0,ncol(bpa$tt))
lof[40:60] = 1
downstream_lof <- rep(0,101)
downstream_lof[1:39] = 1

tt_<-rbind(upstream_lof,lof,downstream_lof)

bpa_mid<-addTobca(nzdsr(bpa),tt_)
bel_bpa_mid <- belplau(bpa_mid)
bel_bpa_mid_ <- cbind(bel_bpa_mid, bpa_mid$spec)
bel_bpa_mid_[which(bel_bpa_mid_[,ncol(bel_bpa_mid_)] == 1),]

I got:

bel_bpamid[which(bel_bpamid[,ncol(bel_bpamid)] == 1),] Belief Plausibility Plty Ratio specnb mass

which is an empty matrix.

On Thu, Jul 13, 2023 at 6:44 PM Claude Boivin @.***> wrote:

A parameter "status" has been added to the "spec" of the bca in order to distinguish the new subsets added from the ones already present. It will allow to extract only the new subsets added.

result <- belplau (x) # x is your bca

result <- cbind(result, x$spec) # add the spec element to the table

result[which(result[,ncol(result)] == 1),] # will give the results for the new rows (subsets) only

It does'n matter if you do nzdsr(x) before addToBca or after. Personnally, I would do addTobca after, siince I don't need to normalize subsets with 0 mass

— Reply to this email directly, view it on GitHub https://github.com/RAPLER/dst-1/issues/8#issuecomment-1635137448, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHHVV36TY636XE3TGK52FV3XQCP65ANCNFSM6AAAAAAYOFHGMI . You are receiving this because you commented.Message ID: @.***>

RAPLER commented 1 year ago

You should not have to redo the combination. The parameter "status" has only be added by "addTobca" function.

RAPLER commented 1 year ago

If you have the last version of function "addTobca" the column names of your output of bel_bpamid[which(bel_bpamid[,ncol(bel_bpamid)] == 1),] should look like this:

Belief Plausibility Plty Ratio specnb mass status