Tuesday, February 25, 2020

Decision tree visualisation

Le code promis pour avoir l'arbre du TP5:


#En plus : Plot the decision tree
plotDecisTree <- function(decisTree){
GetNodeLabel <- function(node) switch(node$type,
                                      terminal = paste0( '$ ', format(node$payoff, scientific = FALSE, big.mark = ",")),
                                      paste0('ER\n', '$ ', format(node$payoff, scientific = FALSE, big.mark = ",")))

GetEdgeLabel <- function(node) {
  if (!node$isRoot && node$parent$type == 'chance') {
    label = paste0(node$name, " (", node$p, ")")
  } else {
    label = node$name
  }
  return (label)
}

GetNodeShape <- function(node) switch(node$type, decision = "box",
                                      chance = "circle", terminal = "house")


SetEdgeStyle(decisTree, fontname = 'helvetica', label = GetEdgeLabel)
SetNodeStyle(decisTree, fontname = 'helvetica', label = GetNodeLabel, shape = GetNodeShape)
SetGraphStyle(decisTree, rankdir = "LR")
plot(decisTree)
}

plotDecisTree(decisTree)


#sulp ne

Saturday, February 22, 2020

Test N°1

TEST SysAiD


pour les L3 (ISIL)

Mardi 25 fevrier 2020 à 12:50.

Amphi 7

Thursday, February 13, 2020

TP 5 material

Arbre d'analyse de décision

1. Fichier YAML
name: newProdTree
type: decision
capt: root_D
AnnulTest:
  type: terminal
  capt: annulTest_T
  payoff: 0.0
TestProd:
  type: chance
  capt: testProd_C
  testFail:
    type: terminal
    capt: testFail_T
    p: 0.7
    payoff: -100000
  testSucc:
    type: decision
    capt: testSucc_D
    p: 0.3
    SmallPlant:
        type: chance
        capt: smallPlant_C
        noCompet:
          type: terminal
          capt: smallNoCompet_T
          p: 0.6
          payoff: 310000 
        compet:
          type: terminal
          capt: smallCompet_T
          p: 0.4
          payoff: -110000
    LargePlant:
        type: chance
        capt: largePlant_C
        noCompet:
          type: terminal
          capt: largeNoCompet_T
          p: 0.6
          payoff: 700000
        compet:
          type: terminal
          capt: largeCompet_T
          p: 0.4
          payoff: -140000


2. Script R
fileName <- 'exCoursNewProd.yaml'
cat(readChar(fileName, file.info(fileName)$size))#on s'assure q ttVaB1
library(data.tree)
library(yaml)
l <- yaml.load_file(fileName)
decisTree <- as.Node(l)
#arbre avant resolution
print(decisTree, "type", "payoff", "p")

#resolution
payoff <- function(node){
  if (node$type == 'chance'){
    node$payoff <- sum(sapply(node$children, function(child) child$payoff * child$p))}
  else if (node$type == 'decision'){
    vChildrenPayoff <-sapply(node$children, function(child) child$payoff)

    node$payoff <- max(vChildrenPayoff)}
}

decisTree$Do(payoff, traversal = "post-order", filterFun = isNotLeaf)

#resultat
print("Decision à entreprendre:")
affichPathDecis <- function(node)  if(node$payoff==node$parent$payoff)
                                      cat(node$name,' --> ')
decisTree$Do(affichPathDecis, filterFun = isNotRoot, traversal = "pre-order")
cat('EMV -->',decisTree$payoff,'\n')


Bibliographie/Further reading

Tuesday, January 28, 2020

Arbre d'analyse de décision


Exercice 




Une entreprise veut analyser la décision de soumissionner ou non pour un certain contrat. Elle estime que la simple préparation de l'offre coûtera 10 000 U. Si l’entreprise soumissionne, elle estime qu'il y a 50% de chances que son offre soit classée dans la "liste restreinte", sinon son offre sera rejetée.
Une fois présélectionnée, l ‘entreprise devra fournir des informations détaillées supplémentaires (entraînant des coûts estimés à 5 000 U). Après cette étape, l’offre sera soit acceptée, soit rejetée.
L’entreprise estime que les coûts de main-d'œuvre et de matériaux liés au contrat s'élèvent à 127 000 U. Elle envisage trois offres possibles, à savoir 155 000 U, 170 000 U et 190 000 U. Elle estime que la probabilité d'acceptation de ces offres (une fois qu'elles ont été sélectionnées) est respectivement de 0,90, 0,75 et 0,35.
Que doit faire l’entreprise et quelle est la valeur monétaire attendue du plan d’action proposé?