def __init__(self, myparams, nodesnotlinked):
        self.myparams = myparams
        qtyofNodesToProcess = len(nodesnotlinked)
        element = 0
        self.results = []

        for pair in nodesnotlinked:
            element = element + 1
            Formating.printProgressofEvents(
                element, qtyofNodesToProcess,
                "Calculating features for nodes not liked: ")
            neighbors_node1 = self.all_neighbors(pair[0])
            neighbors_node2 = self.all_neighbors(pair[1])
            len_neihbors_node1 = len(neighbors_node1)
            len_neihbors_node2 = len(neighbors_node2)
            CommonNeigbors = neighbors_node1.intersection(neighbors_node2)
            CommonNeigbors_Feature = len(CommonNeigbors)
            TS_Feature09 = float(0)
            TS_Feature08 = float(0)
            TS_Feature07 = float(0)
            TS_Feature06 = float(0)
            TS_Feature05 = float(0)
            TS_Feature04 = float(0)
            TS_Feature03 = float(0)
            TS_Feature02 = float(0)
            TS_Feature01 = float(0)

            if CommonNeigbors_Feature > 0:
                print "Calculando ", pair[0], pair[1], CommonNeigbors_Feature
                #x = (float)(len(neighbors_node1.union(neighbors_node2)))
                #if x > 0:
                #    JC_Feature = CommonNeigbors_Feature/x
                for pair_common_neighbor in CommonNeigbors:
                    #secondary_neighbors = self.all_neighbors(pair_common_neighbor)
                    #AAS_Feature += 1 / (numpy.log10(len(secondary_neighbors)) + 0.00001)

                    objectsNode1 = self.get_ObjectsofLinks(
                        myparams.trainnigGraph, pair[0], pair_common_neighbor)
                    objectsNode2 = self.get_ObjectsofLinks(
                        myparams.trainnigGraph, pair[1], pair_common_neighbor)

                    hm = 2 / ((1 / float(len(objectsNode1))) +
                              (1 / float(len(objectsNode2))))
                    #print pair[0], pair_common_neighbor, "Media Harmonica ", hm

                    timesofLinksNode1 = []
                    timesofLinksNode2 = []
                    bagofWordsNode1 = set()
                    bagofWordsNode2 = set()

                    for t1 in objectsNode1:
                        timesofLinksNode1.append(t1['time'])
                        for b1 in eval(t1['keywords']):
                            bagofWordsNode1.add(b1)
                    for t2 in objectsNode2:
                        timesofLinksNode2.append(t2['time'])
                        for b2 in eval(t2['keywords']):
                            bagofWordsNode2.add(b2)

                    timesofLinksNode1.sort(reverse=True)
                    timesofLinksNode2.sort(reverse=True)
                    timeofLinks = timesofLinksNode1 + timesofLinksNode2

                    #print  pair_common_neighbor, "publicacoes realizadas: ", timeofLinks

                    k = int(self.myparams.t0_) - int(max(timeofLinks))

                    #print  pair_common_neighbor, "K ", k
                    decayfunction09 = (0.9)**k
                    decayfunction08 = (0.8)**k
                    decayfunction07 = (0.7)**k
                    decayfunction06 = (0.6)**k
                    decayfunction05 = (0.5)**k
                    decayfunction04 = (0.4)**k
                    decayfunction03 = (0.3)**k
                    decayfunction02 = (0.2)**k
                    decayfunction01 = (0.1)**k

                    #print  pair_common_neighbor, "funcao de decaimento 0.5 ", decayfunction05

                    control = (
                        abs(max(timesofLinksNode1) - max(timesofLinksNode2)) +
                        1)

                    #print  pair_common_neighbor, "denominador inicial considerando apenas TS ", control
                    ts09 = (hm * decayfunction09) / control
                    ts08 = (hm * decayfunction08) / control
                    ts07 = (hm * decayfunction07) / control
                    ts06 = (hm * decayfunction06) / control
                    ts05 = (hm * decayfunction05) / control
                    ts04 = (hm * decayfunction04) / control
                    ts03 = (hm * decayfunction03) / control
                    ts02 = (hm * decayfunction02) / control
                    ts01 = (hm * decayfunction01) / control

                    #print  pair_common_neighbor, "TS ", ts05
                    TS_Feature09 = TS_Feature09 + ts09
                    TS_Feature08 = TS_Feature08 + ts08
                    TS_Feature07 = TS_Feature07 + ts07
                    TS_Feature06 = TS_Feature06 + ts06
                    TS_Feature05 = TS_Feature05 + ts05
                    TS_Feature04 = TS_Feature04 + ts04
                    TS_Feature03 = TS_Feature03 + ts03
                    TS_Feature02 = TS_Feature02 + ts02
                    TS_Feature01 = TS_Feature01 + ts01

                    #print  pair_common_neighbor, "conjuntos de palavras ", bagofWordsNode1, bagofWordsNode2

                    #jcDomain = self.get_jacard_domain(bagofWordsNode1, bagofWordsNode2)

                    #print  pair_common_neighbor, "JC ", jcDomain

                    #dts02 = (hm * decayfunction02) /  (control * ((0.2) ** jcDomain))
                    #dts05 = (hm * decayfunction02) /  (control * ((0.5) ** jcDomain))
                    #dts08 = (hm * decayfunction02) /  (control * ((0.8) ** jcDomain))

                    #print  pair_common_neighbor, "DTS ", dts05

                    #DTS_Feature02 = DTS_Feature02 + dts02
                    #DTS_Feature05 = DTS_Feature05 + dts05
                    #DTS_Feature08 = DTS_Feature08 + dts08

            self.results.append({
                'node1': pair[0],
                'node2': pair[1],
                'TS09': TS_Feature09,
                'TS08': TS_Feature08,
                'TS07': TS_Feature07,
                'TS06': TS_Feature06,
                'TS05': TS_Feature05,
                'TS04': TS_Feature04,
                'TS03': TS_Feature03,
                'TS02': TS_Feature02,
                'TS01': TS_Feature01
            })
示例#2
0
    def __init__(self, myparams, nodesnotlinked):
        self.myparams = myparams
        qtyofNodesToProcess = len(nodesnotlinked)
        element = 0
        self.results = []

        for pair in nodesnotlinked:
            element = element + 1
            Formating.printProgressofEvents(
                element, qtyofNodesToProcess,
                "Calculating features for nodes not liked: ")
            neighbors_node1 = self.all_neighbors(pair[0])
            neighbors_node2 = self.all_neighbors(pair[1])
            len_neihbors_node1 = len(neighbors_node1)
            len_neihbors_node2 = len(neighbors_node2)
            CommonNeigbors = neighbors_node1.intersection(neighbors_node2)
            CommonNeigbors_Feature = len(CommonNeigbors)
            AAS_Feature = 0
            JC_Feature = 0
            PA_Feature = len_neihbors_node1 * len_neihbors_node2
            TS_Feature08 = float(0)
            TS_Feature05 = float(0)
            TS_Feature02 = float(0)

            DTS_Feature02 = float(0)
            DTS_Feature05 = float(0)
            DTS_Feature08 = float(0)

            if CommonNeigbors_Feature > 0:
                print "Calculando ", pair[0], pair[1], CommonNeigbors_Feature
                x = (float)(len(neighbors_node1.union(neighbors_node2)))
                if x > 0:
                    JC_Feature = CommonNeigbors_Feature / x
                for pair_common_neighbor in CommonNeigbors:
                    secondary_neighbors = self.all_neighbors(
                        pair_common_neighbor)
                    AAS_Feature += 1 / (numpy.log10(len(secondary_neighbors)) +
                                        0.00001)

                    objectsNode1 = self.get_ObjectsofLinks(
                        myparams.trainnigGraph, pair[0], pair_common_neighbor)
                    objectsNode2 = self.get_ObjectsofLinks(
                        myparams.trainnigGraph, pair[1], pair_common_neighbor)

                    hm = 2 / ((1 / float(len(objectsNode1))) +
                              (1 / float(len(objectsNode2))))
                    #print pair[0], pair_common_neighbor, "Media Harmonica ", hm

                    timesofLinksNode1 = []
                    timesofLinksNode2 = []
                    bagofWordsNode1 = set()
                    bagofWordsNode2 = set()

                    for t1 in objectsNode1:
                        timesofLinksNode1.append(t1['time'])
                        for b1 in eval(t1['keywords']):
                            bagofWordsNode1.add(b1)
                    for t2 in objectsNode2:
                        timesofLinksNode2.append(t2['time'])
                        for b2 in eval(t2['keywords']):
                            bagofWordsNode2.add(b2)

                    timesofLinksNode1.sort(reverse=True)
                    timesofLinksNode2.sort(reverse=True)
                    timeofLinks = timesofLinksNode1 + timesofLinksNode2

                    #print  pair_common_neighbor, "publicacoes realizadas: ", timeofLinks

                    k = int(self.myparams.t0_) - int(max(timeofLinks))

                    #print  pair_common_neighbor, "K ", k

                    decayfunction08 = (0.8)**k
                    decayfunction05 = (0.5)**k
                    decayfunction02 = (0.2)**k

                    #print  pair_common_neighbor, "funcao de decaimento 0.5 ", decayfunction05

                    control = (
                        abs(max(timesofLinksNode1) - max(timesofLinksNode2)) +
                        1)

                    #print  pair_common_neighbor, "denominador inicial considerando apenas TS ", control

                    ts08 = (hm * decayfunction08) / control
                    ts05 = (hm * decayfunction05) / control
                    ts02 = (hm * decayfunction02) / control

                    #print  pair_common_neighbor, "TS ", ts05

                    TS_Feature08 = TS_Feature08 + ts08
                    TS_Feature05 = TS_Feature05 + ts05
                    TS_Feature02 = TS_Feature02 + ts02

                    #print  pair_common_neighbor, "conjuntos de palavras ", bagofWordsNode1, bagofWordsNode2

                    jcDomain = self.get_jacard_domain(bagofWordsNode1,
                                                      bagofWordsNode2)

                    #print  pair_common_neighbor, "JC ", jcDomain

                    dts02 = (hm * decayfunction02) / (control *
                                                      ((0.2)**jcDomain))
                    dts05 = (hm * decayfunction02) / (control *
                                                      ((0.5)**jcDomain))
                    dts08 = (hm * decayfunction02) / (control *
                                                      ((0.8)**jcDomain))

                    #print  pair_common_neighbor, "DTS ", dts05

                    DTS_Feature02 = DTS_Feature02 + dts02
                    DTS_Feature05 = DTS_Feature05 + dts05
                    DTS_Feature08 = DTS_Feature08 + dts08

            self.results.append({
                'node1': pair[0],
                'node2': pair[1],
                'cn': CommonNeigbors_Feature,
                'aas': AAS_Feature,
                'jc': JC_Feature,
                'pa': PA_Feature,
                'ts08': TS_Feature08,
                'ts05': TS_Feature05,
                'ts02': TS_Feature02,
                'dts08': DTS_Feature08,
                'dts05': DTS_Feature05,
                'dts02': DTS_Feature02
            })
 def __init__(self, myparams, nodesnotlinked):
     self.myparams = myparams
     qtyofNodesToProcess = len(nodesnotlinked)
     element = 0
     self.results = []
     
     for pair in nodesnotlinked:
         element = element+1
         Formating.printProgressofEvents(element, qtyofNodesToProcess, "Calculating features for nodes not liked: ")
         neighbors_node1 = self.all_neighbors(pair[0])
         neighbors_node2 = self.all_neighbors(pair[1])
         len_neihbors_node1 = len(neighbors_node1)
         len_neihbors_node2 = len(neighbors_node2)
         CommonNeigbors = neighbors_node1.intersection(neighbors_node2)
         CommonNeigbors_Feature = len(CommonNeigbors)
         TS_Feature09 = float(0)
         TS_Feature08 = float(0)
         TS_Feature07 = float(0)
         TS_Feature06 = float(0)
         TS_Feature05 = float(0)
         TS_Feature04 = float(0)
         TS_Feature03 = float(0)
         TS_Feature02 = float(0)
         TS_Feature01 = float(0)
         
         if CommonNeigbors_Feature > 0:
             print "Calculando ", pair[0], pair[1], CommonNeigbors_Feature
             #x = (float)(len(neighbors_node1.union(neighbors_node2)))
             #if x > 0:
             #    JC_Feature = CommonNeigbors_Feature/x
             for pair_common_neighbor in CommonNeigbors:
                 #secondary_neighbors = self.all_neighbors(pair_common_neighbor)
                 #AAS_Feature += 1 / (numpy.log10(len(secondary_neighbors)) + 0.00001)
             
                 objectsNode1 = self.get_ObjectsofLinks(myparams.trainnigGraph, pair[0], pair_common_neighbor)
                 objectsNode2 = self.get_ObjectsofLinks(myparams.trainnigGraph, pair[1], pair_common_neighbor)
                 
                 hm = 2 / ( (1/float(len(objectsNode1))) + (1/float(len(objectsNode2))))
                 #print pair[0], pair_common_neighbor, "Media Harmonica ", hm 
                 
                 timesofLinksNode1 = []
                 timesofLinksNode2 = []
                 bagofWordsNode1 = set()
                 bagofWordsNode2 = set()
         
                 for t1 in objectsNode1:
                     timesofLinksNode1.append(t1['time'])
                     for b1 in eval(t1['keywords']):
                         bagofWordsNode1.add(b1)
                 for t2 in objectsNode2:
                     timesofLinksNode2.append(t2['time'])
                     for b2 in eval(t2['keywords']):
                         bagofWordsNode2.add(b2)
                    
         
                 timesofLinksNode1.sort(reverse=True)
                 timesofLinksNode2.sort(reverse=True)
                 timeofLinks = timesofLinksNode1 + timesofLinksNode2
                 
                 #print  pair_common_neighbor, "publicacoes realizadas: ", timeofLinks 
                 
                 k =  int(self.myparams.t0_)  - int(max(timeofLinks))
                 
                 #print  pair_common_neighbor, "K ", k 
                 #decayfunction09 = (0.9) ** k
                 #decayfunction08 = (0.8) ** k
                 #decayfunction07 = (0.7) ** k
                 #decayfunction06 = (0.6) ** k
                 #decayfunction05 = (0.5) ** k
                 decayfunction04 = (0.9) ** k
                 #decayfunction03 = (0.3) ** k
                 #decayfunction02 = (0.2) ** k
                 #decayfunction01 = (0.1) ** k
                 
                 #print  pair_common_neighbor, "funcao de decaimento 0.5 ", decayfunction05 
                 
                 
                 control = ( abs( max(timesofLinksNode1) - max(timesofLinksNode2) ) + 1)
                 
                 jcDomain = self.get_jacard_domain(bagofWordsNode1, bagofWordsNode2)
                 
                 #print  pair_common_neighbor, "denominador inicial considerando apenas TS ", control 
                  
                 ts09 = (hm * decayfunction04) /  (control * ((0.9) ** jcDomain))
                 ts08 = (hm * decayfunction04) /  (control * ((0.8) ** jcDomain))
                 ts07 = (hm * decayfunction04) /  (control * ((0.7) ** jcDomain))
                 ts06 = (hm * decayfunction04) /  (control * ((0.6) ** jcDomain))
                 ts05 = (hm * decayfunction04) /  (control * ((0.5) ** jcDomain))
                 ts04 = (hm * decayfunction04) /  (control * ((0.4) ** jcDomain))
                 ts03 = (hm * decayfunction04) /  (control * ((0.3) ** jcDomain))
                 ts02 = (hm * decayfunction04) /  (control * ((0.2) ** jcDomain))
                 ts01 = (hm * decayfunction04) /  (control * ((0.1) ** jcDomain))
                 
                 #print  pair_common_neighbor, "TS ", ts05 
                 TS_Feature09 = TS_Feature09 + ts09
                 TS_Feature08 = TS_Feature08 + ts08
                 TS_Feature07 = TS_Feature07 + ts07
                 TS_Feature06 = TS_Feature06 + ts06
                 TS_Feature05 = TS_Feature05 + ts05
                 TS_Feature04 = TS_Feature04 + ts04
                 TS_Feature03 = TS_Feature03 + ts03
                 TS_Feature02 = TS_Feature02 + ts02
                 TS_Feature01 = TS_Feature01 + ts01
                 
                 #print  pair_common_neighbor, "conjuntos de palavras ", bagofWordsNode1, bagofWordsNode2 
                 
                 
                 
                 #print  pair_common_neighbor, "JC ", jcDomain 
                 
                 #dts02 = (hm * decayfunction02) /  (control * ((0.2) ** jcDomain))
                 #dts05 = (hm * decayfunction02) /  (control * ((0.5) ** jcDomain))
                 #dts08 = (hm * decayfunction02) /  (control * ((0.8) ** jcDomain))
                 
                 #print  pair_common_neighbor, "DTS ", dts05 
                 
                 #DTS_Feature02 = DTS_Feature02 + dts02
                 #DTS_Feature05 = DTS_Feature05 + dts05
                 #DTS_Feature08 = DTS_Feature08 + dts08
             
             
             
             
         self.results.append({'node1' : pair[0], 'node2': pair[1], 'TS09' : TS_Feature09, 'TS08' : TS_Feature08, 'TS07' : TS_Feature07, 'TS06' : TS_Feature06, 'TS05' : TS_Feature05,'TS04' : TS_Feature04,'TS03' : TS_Feature03, 'TS02'  : TS_Feature02, 'TS01'  : TS_Feature01 })
    def __init__(self, myparams, nodesnotlinked, weights, WillCombinate):
        self.myparams = myparams
        self.weights = weights
        self.WillCombinate = WillCombinate
        qtyofNodesToProcess = len(nodesnotlinked)
        element = 0
        calcutations = []
        self.results = []
        self.minCN = float(0)
        self.maxCN = float(0)
        self.minAAS = float(0)
        self.maxAAS = float(0)
        self.minJC = float(0)
        self.maxJC = float(0)
        self.minPA = float(0)
        self.maxPA = float(0)
        self.minTS08 = float(0)
        self.maxTS08 = float(0)
        self.minTS05 = float(0)
        self.maxTS05 = float(0)
        self.minTS02 = float(0)
        self.maxTS02 = float(0)

        for pair in nodesnotlinked:
            element = element + 1
            Formating.printProgressofEvents(
                element, qtyofNodesToProcess,
                "Calculating features for nodes not liked: ")
            neighbors_node1 = self.all_neighbors(pair[0])
            neighbors_node2 = self.all_neighbors(pair[1])
            CommonNeigbors = neighbors_node1.intersection(neighbors_node2)
            CommonNeigbors_Feature = len(CommonNeigbors)
            AAS_Feature = 0
            JC_Feature = 0
            PA_Feature = len(neighbors_node1) * len(neighbors_node2)
            TS_Feature08 = float(0)
            TS_Feature05 = float(0)
            TS_Feature02 = float(0)

            DTS_Feature = float(0)

            if CommonNeigbors_Feature > 0:
                print "Calculando ", pair[0], pair[1], CommonNeigbors_Feature
                x = (float)(len(neighbors_node1.union(neighbors_node2)))
                if x > 0:
                    JC_Feature = CommonNeigbors_Feature / x
                for pair_common_neighbor in CommonNeigbors:
                    secondary_neighbors = self.all_neighbors(
                        pair_common_neighbor)
                    AAS_Feature += 1 / (numpy.log10(len(secondary_neighbors)) +
                                        0.00001)

                    objectsNode1 = self.get_ObjectsofLinks(
                        myparams.trainnigGraph, pair[0], pair_common_neighbor)
                    objectsNode2 = self.get_ObjectsofLinks(
                        myparams.trainnigGraph, pair[1], pair_common_neighbor)
                    hm = 2 / ((1 / float(len(objectsNode1))) +
                              (1 / float(len(objectsNode2))))
                    timesofLinksNode1 = []
                    timesofLinksNode2 = []

                    for t1 in objectsNode1:
                        timesofLinksNode1.append(t1['time'])
                    for t2 in objectsNode2:
                        timesofLinksNode2.append(t2['time'])

                    timesofLinksNode1.sort(reverse=True)
                    timesofLinksNode2.sort(reverse=True)
                    timeofLinks = timesofLinksNode1 + timesofLinksNode2
                    k = int(self.myparams.t0_) - int(max(timeofLinks))
                    decayfunction08 = (1 - 0.8)**k
                    decayfunction05 = (1 - 0.5)**k
                    decayfunction02 = (1 - 0.2)**k

                    control = (
                        abs(max(timesofLinksNode1) - max(timesofLinksNode2)) +
                        1)
                    ts08 = (hm * decayfunction08) / control
                    ts05 = (hm * decayfunction05) / control
                    ts02 = (hm * decayfunction02) / control

                    TS_Feature08 = TS_Feature08 + ts08
                    TS_Feature05 = TS_Feature05 + ts05
                    TS_Feature02 = TS_Feature02 + ts02

            if CommonNeigbors_Feature < self.minCN:
                self.minCN = CommonNeigbors_Feature
            if CommonNeigbors_Feature > self.maxCN:
                self.maxCN = CommonNeigbors_Feature

            if AAS_Feature < self.minAAS:
                self.minAAS = AAS_Feature
            if AAS_Feature > self.maxAAS:
                self.maxAAS = CommonNeigbors_Feature

            if PA_Feature < self.minPA:
                self.minPA = PA_Feature
            if PA_Feature > self.maxPA:
                self.maxPA = PA_Feature

            if JC_Feature < self.minJC:
                self.minJC = JC_Feature
            if JC_Feature > self.maxJC:
                self.maxJC = JC_Feature

            if TS_Feature08 < self.minTS08:
                self.minTS08 = TS_Feature08
            if TS_Feature08 > self.maxTS08:
                self.maxTS08 = TS_Feature08

            if TS_Feature05 < self.minTS05:
                self.minTS05 = TS_Feature05
            if TS_Feature05 > self.maxTS05:
                self.maxTS05 = TS_Feature05

            if TS_Feature02 < self.minTS02:
                self.minTS02 = TS_Feature02
            if TS_Feature02 > self.maxTS02:
                self.maxTS02 = TS_Feature02

            calcutations.append({
                'node1': pair[0],
                'node2': pair[1],
                'cn': CommonNeigbors_Feature,
                'aas': AAS_Feature,
                'jc': JC_Feature,
                'pa': PA_Feature,
                'ts08': TS_Feature08,
                'ts05': TS_Feature05,
                'ts02': TS_Feature02,
                'dts': DTS_Feature
            })

        self.combination(calcutations)
 def __init__(self, myparams, nodesnotlinked):
     self.myparams = myparams
     qtyofNodesToProcess = len(nodesnotlinked)
     element = 0
     self.results = []
     
     for pair in nodesnotlinked:
         element = element+1
         Formating.printProgressofEvents(element, qtyofNodesToProcess, "Calculating features for nodes not liked: ")
         neighbors_node1 = self.all_neighbors(pair[0])
         neighbors_node2 = self.all_neighbors(pair[1])
         CommonNeigbors = neighbors_node1.intersection(neighbors_node2)
         CommonNeigbors_Feature = len(CommonNeigbors)
         AAS_Feature = 0
         JC_Feature = 0
         PA_Feature = len(neighbors_node1) * len(neighbors_node2)
         TS_Feature08 = float(0)
         TS_Feature05 = float(0)
         TS_Feature02 = float(0)
         
         DTS_Feature = float(0)
         
         if CommonNeigbors_Feature > 0:
             print "Calculando ", pair[0], pair[1], CommonNeigbors_Feature
             x = (float)(len(neighbors_node1.union(neighbors_node2)))
             if x > 0:
                 JC_Feature = CommonNeigbors_Feature/x
             for pair_common_neighbor in CommonNeigbors:
                 secondary_neighbors = self.all_neighbors(pair_common_neighbor)
                 AAS_Feature += 1 / (numpy.log10(len(secondary_neighbors)) + 0.00001)
             
                 objectsNode1 = self.get_ObjectsofLinks(myparams.trainnigGraph, pair[0], pair_common_neighbor)
                 objectsNode2 = self.get_ObjectsofLinks(myparams.trainnigGraph, pair[1], pair_common_neighbor)
                 hm = 2 / ((1/float(len(objectsNode1))) + (1/float(len(objectsNode2))))
                 timesofLinksNode1 = []
                 timesofLinksNode2 = []
                 bagofWordsNode1 = set()
                 bagofWordsNode2 = set()
         
                 for t1 in objectsNode1:
                     timesofLinksNode1.append(t1['time'])
                 #for bt1 in t1['keywords']:
                 #    bagofWordsNode1.add(bt1)
                 for t2 in objectsNode2:
                     timesofLinksNode2.append(t2['time'])
                 #    for bt2 in t2['keywords']:
                 #        bagofWordsNode2.add(bt2)
         
                 timesofLinksNode1.sort(reverse=True)
                 timesofLinksNode2.sort(reverse=True)
                 timeofLinks = timesofLinksNode1 + timesofLinksNode2
                 k =  int(self.myparams.t0_)  - int(max(timeofLinks))
                 decayfunction08 = (1 - 0.8) ** k
                 decayfunction05 = (1 - 0.5) ** k
                 decayfunction02 = (1 - 0.2) ** k
                 
                 control = (abs( max(timesofLinksNode1) - max(timesofLinksNode2) ) + 1)
                 ts08 = (hm * decayfunction08) / control
                 ts05 = (hm * decayfunction05) / control
                 ts02 = (hm * decayfunction02) / control
                 
                 TS_Feature08 = TS_Feature08 + ts08
                 TS_Feature05 = TS_Feature05 + ts05
                 TS_Feature02 = TS_Feature02 + ts02
                 
                 
                 #dts = (hm * decayfunction) /  (control * ((1 - self.myparams.domain_decay) ** self.get_jacard_domain(bagofWordsNode1, bagofWordsNode2)))
                 #DTS_Feature = DTS_Feature + dts
             
         self.results.append({'node1' : pair[0], 'node2': pair[1], 'cn' : CommonNeigbors_Feature, 'aas' : AAS_Feature, 'jc' : JC_Feature, 'pa' : PA_Feature, 'ts08' : TS_Feature08,'ts05' : TS_Feature05,'ts02' : TS_Feature02, 'dts'  : DTS_Feature })
 def __init__(self, myparams, nodesnotlinked, weights, WillCombinate):
     self.myparams = myparams
     self.weights = weights
     self.WillCombinate = WillCombinate
     qtyofNodesToProcess = len(nodesnotlinked)
     element = 0
     calcutations = []
     self.results = []
     self.minCN = float(0)
     self.maxCN = float(0)
     self.minAAS = float(0)
     self.maxAAS = float(0)
     self.minJC = float(0)
     self.maxJC = float(0)
     self.minPA = float(0)
     self.maxPA = float(0)
     self.minTS08 = float(0)
     self.maxTS08 = float(0)
     self.minTS05 = float(0)
     self.maxTS05 = float(0)
     self.minTS02 = float(0)
     self.maxTS02 = float(0)
     
     
     
     for pair in nodesnotlinked:
         element = element+1
         Formating.printProgressofEvents(element, qtyofNodesToProcess, "Calculating features for nodes not liked: ")
         neighbors_node1 = self.all_neighbors(pair[0])
         neighbors_node2 = self.all_neighbors(pair[1])
         CommonNeigbors = neighbors_node1.intersection(neighbors_node2)
         CommonNeigbors_Feature = len(CommonNeigbors)
         AAS_Feature = 0
         JC_Feature = 0
         PA_Feature = len(neighbors_node1) * len(neighbors_node2)
         TS_Feature08 = float(0)
         TS_Feature05 = float(0)
         TS_Feature02 = float(0)
         
         DTS_Feature = float(0)
         
         if CommonNeigbors_Feature > 0:
             print "Calculando ", pair[0], pair[1], CommonNeigbors_Feature
             x = (float)(len(neighbors_node1.union(neighbors_node2)))
             if x > 0:
                 JC_Feature = CommonNeigbors_Feature/x
             for pair_common_neighbor in CommonNeigbors:
                 secondary_neighbors = self.all_neighbors(pair_common_neighbor)
                 AAS_Feature += 1 / (numpy.log10(len(secondary_neighbors)) + 0.00001)
             
                 objectsNode1 = self.get_ObjectsofLinks(myparams.trainnigGraph, pair[0], pair_common_neighbor)
                 objectsNode2 = self.get_ObjectsofLinks(myparams.trainnigGraph, pair[1], pair_common_neighbor)
                 hm = 2 / ((1/float(len(objectsNode1))) + (1/float(len(objectsNode2))))
                 timesofLinksNode1 = []
                 timesofLinksNode2 = []
               
                 for t1 in objectsNode1:
                     timesofLinksNode1.append(t1['time'])
                 for t2 in objectsNode2:
                     timesofLinksNode2.append(t2['time'])
               
                 timesofLinksNode1.sort(reverse=True)
                 timesofLinksNode2.sort(reverse=True)
                 timeofLinks = timesofLinksNode1 + timesofLinksNode2
                 k =  int(self.myparams.t0_)  - int(max(timeofLinks))
                 decayfunction08 = (1 - 0.8) ** k
                 decayfunction05 = (1 - 0.5) ** k
                 decayfunction02 = (1 - 0.2) ** k
                 
                 control = (abs( max(timesofLinksNode1) - max(timesofLinksNode2) ) + 1)
                 ts08 = (hm * decayfunction08) / control
                 ts05 = (hm * decayfunction05) / control
                 ts02 = (hm * decayfunction02) / control
                 
                 TS_Feature08 = TS_Feature08 + ts08
                 TS_Feature05 = TS_Feature05 + ts05
                 TS_Feature02 = TS_Feature02 + ts02
                 
                 
                 
          
         if CommonNeigbors_Feature < self.minCN:
             self.minCN = CommonNeigbors_Feature
         if CommonNeigbors_Feature > self.maxCN:
             self.maxCN = CommonNeigbors_Feature
         
         if AAS_Feature < self.minAAS:
             self.minAAS = AAS_Feature
         if AAS_Feature > self.maxAAS:
             self.maxAAS = CommonNeigbors_Feature
         
         if PA_Feature < self.minPA:
             self.minPA = PA_Feature
         if PA_Feature > self.maxPA:
             self.maxPA = PA_Feature
         
         if JC_Feature < self.minJC:
             self.minJC = JC_Feature
         if JC_Feature > self.maxJC:
             self.maxJC = JC_Feature
         
         if TS_Feature08 < self.minTS08:
             self.minTS08 = TS_Feature08
         if TS_Feature08 > self.maxTS08:
             self.maxTS08 = TS_Feature08
         
         if TS_Feature05 < self.minTS05:
             self.minTS05 = TS_Feature05
         if TS_Feature05 > self.maxTS05:
             self.maxTS05 = TS_Feature05
         
         if TS_Feature02 < self.minTS02:
             self.minTS02 = TS_Feature02
         if TS_Feature02 > self.maxTS02:
             self.maxTS02 = TS_Feature02
                 
         calcutations.append({'node1' : pair[0], 'node2': pair[1], 'cn' : CommonNeigbors_Feature, 'aas' : AAS_Feature, 'jc' : JC_Feature, 'pa' : PA_Feature, 'ts08' : TS_Feature08,'ts05' : TS_Feature05,'ts02' : TS_Feature02, 'dts'  : DTS_Feature })
     
     self.combination(calcutations)    
             
     
 def __init__(self, myparams, nodesnotlinked):
     self.myparams = myparams
     qtyofNodesToProcess = len(nodesnotlinked)
     element = 0
     self.results = []
     
     for pair in nodesnotlinked:
         element = element+1
         Formating.printProgressofEvents(element, qtyofNodesToProcess, "Calculating features for nodes not liked: ")
         neighbors_node1 = self.all_neighbors(pair[0])
         neighbors_node2 = self.all_neighbors(pair[1])
         len_neihbors_node1 = len(neighbors_node1)
         len_neihbors_node2 = len(neighbors_node2)
         CommonNeigbors = neighbors_node1.intersection(neighbors_node2)
         CommonNeigbors_Feature = len(CommonNeigbors)
         AAS_Feature = 0
         JC_Feature = 0
         PA_Feature = len_neihbors_node1 * len_neihbors_node2
         TS_Feature08 = float(0)
         TS_Feature05 = float(0)
         TS_Feature02 = float(0)
         
         DTS_Feature02 = float(0)
         DTS_Feature05 = float(0)
         DTS_Feature08 = float(0)
         
         if CommonNeigbors_Feature > 0:
             print "Calculando ", pair[0], pair[1], CommonNeigbors_Feature
             x = (float)(len(neighbors_node1.union(neighbors_node2)))
             if x > 0:
                 JC_Feature = CommonNeigbors_Feature/x
             for pair_common_neighbor in CommonNeigbors:
                 secondary_neighbors = self.all_neighbors(pair_common_neighbor)
                 AAS_Feature += 1 / (numpy.log10(len(secondary_neighbors)) + 0.00001)
             
                 objectsNode1 = self.get_ObjectsofLinks(myparams.trainnigGraph, pair[0], pair_common_neighbor)
                 objectsNode2 = self.get_ObjectsofLinks(myparams.trainnigGraph, pair[1], pair_common_neighbor)
                 
                 hm = 2 / ( (1/float(len(objectsNode1))) + (1/float(len(objectsNode2))))
                 #print pair[0], pair_common_neighbor, "Media Harmonica ", hm 
                 
                 timesofLinksNode1 = []
                 timesofLinksNode2 = []
                 bagofWordsNode1 = set()
                 bagofWordsNode2 = set()
         
                 for t1 in objectsNode1:
                     timesofLinksNode1.append(t1['time'])
                     for b1 in eval(t1['keywords']):
                         bagofWordsNode1.add(b1)
                 for t2 in objectsNode2:
                     timesofLinksNode2.append(t2['time'])
                     for b2 in eval(t2['keywords']):
                         bagofWordsNode2.add(b2)
                    
         
                 timesofLinksNode1.sort(reverse=True)
                 timesofLinksNode2.sort(reverse=True)
                 timeofLinks = timesofLinksNode1 + timesofLinksNode2
                 
                 #print  pair_common_neighbor, "publicacoes realizadas: ", timeofLinks 
                 
                 k =  int(self.myparams.t0_)  - int(max(timeofLinks))
                 
                 #print  pair_common_neighbor, "K ", k 
                 
                 decayfunction08 = (0.8) ** k
                 decayfunction05 = (0.5) ** k
                 decayfunction02 = (0.2) ** k
                 
                 #print  pair_common_neighbor, "funcao de decaimento 0.5 ", decayfunction05 
                 
                 
                 control = ( abs( max(timesofLinksNode1) - max(timesofLinksNode2) ) + 1)
                 
                 #print  pair_common_neighbor, "denominador inicial considerando apenas TS ", control 
                 
                 ts08 = (hm * decayfunction08) / control
                 ts05 = (hm * decayfunction05) / control
                 ts02 = (hm * decayfunction02) / control
                 
                 #print  pair_common_neighbor, "TS ", ts05 
                 
                 TS_Feature08 = TS_Feature08 + ts08
                 TS_Feature05 = TS_Feature05 + ts05
                 TS_Feature02 = TS_Feature02 + ts02
                 
                 #print  pair_common_neighbor, "conjuntos de palavras ", bagofWordsNode1, bagofWordsNode2 
                 
                 jcDomain = self.get_jacard_domain(bagofWordsNode1, bagofWordsNode2)
                 
                 #print  pair_common_neighbor, "JC ", jcDomain 
                 
                 dts02 = (hm * decayfunction02) /  (control * ((0.2) ** jcDomain))
                 dts05 = (hm * decayfunction02) /  (control * ((0.5) ** jcDomain))
                 dts08 = (hm * decayfunction02) /  (control * ((0.8) ** jcDomain))
                 
                 #print  pair_common_neighbor, "DTS ", dts05 
                 
                 DTS_Feature02 = DTS_Feature02 + dts02
                 DTS_Feature05 = DTS_Feature05 + dts05
                 DTS_Feature08 = DTS_Feature08 + dts08
             
             
             
             
         self.results.append({'node1' : pair[0], 'node2': pair[1], 'cn' : CommonNeigbors_Feature, 'aas' : AAS_Feature, 'jc' : JC_Feature, 'pa' : PA_Feature, 'ts08' : TS_Feature08,'ts05' : TS_Feature05,'ts02' : TS_Feature02, 'dts08'  : DTS_Feature08, 'dts05'  : DTS_Feature05, 'dts02'  : DTS_Feature02 })