Beispiel #1
0
def gencurve(db, selection):
    print "Generating curve for " + str(selection)
    points = []
    labels = []
    for item in db.values():
        if item.match(selection):
            points.append((item.precision, item.recall))
            labels.append(item.getlabel())
    rp.plotPrecisionRecallDiagram(maketitle(selection), points, labels)

    pl.show()
Beispiel #2
0
def gencurve(db,selection):
    print "Generating curve for "+str(selection)
    points=[]
    labels=[]
    for item in db.values():
        if item.match(selection):
            points.append((item.precision,item.recall))
            labels.append(item.getlabel())
    rp.plotPrecisionRecallDiagram(maketitle(selection),points,labels)

    pl.show()
Beispiel #3
0
import scipy as sc
import pylab as pl
import recallPrecision as rp

users = [15, 21, 25, 26, 31, 33, 35, 50, 55, 61, 75, 193]
prs = [(0.0273556231003, 0.645161290323), (0.0279383429672, 0.709677419355),
       (0.00886699507389, 0.526315789474), (0.0140845070423, 0.652173913043),
       (0.0317297850563, 0.685714285714), (0.0179640718563, 0.8125),
       (0.0115942028986, 0.52380952381), (0.0128205128205, 0.55),
       (0.0462487153135, 0.620689655172), (0.0176579925651, 0.7),
       (0.0130718954248, 0.3), (0.00381315538608, 0.8)]
#sc.rand(15,2) # precision recall point list
labels = ["User " + str(i) for i in users]  # labels for the points

#labels=["foaf 0.5", "foaf 0.75", "foaf 0.25", "bar"]
#p = [0.0524857850999, 0.053760269644, 0.0174401705261, 0.0275735294118, 0.0606529980027, 0.0351509689049, 0.0226862593452, 0.0250569476082, 0.0860832137733, 0.034447034447, 0.0250521920668, 0.00759013282732]
rp.plotPrecisionRecallDiagram("Precision-Recall Before", prs, labels)
pl.savefig("PrecBegin.png", dpi=300)
pl.show()
#Instantiate the Evaluator
evaluator = RMSRecommenderEvaluator()
#Instantiate the Slope One Recommender
recommender = SlopeOneRecommender(model,True,False,False)

#Calculate the Root Mean Squared Error
rmse = evaluator.evaluate(recommender,model,0.7,1.0)

#Instantiate the IR Stats Recommender Evaluator
evaluator = IRStatsRecommenderEvaluator()

#Calculate the Precision, Recall and F1Score
result = evaluator.evaluate(recommender,model,25,1.0)

#1.04078332386 0.17222222222222 0.1722222222222 0.17222222222222
print rmse, result['precision'], result['recall'], result['f1Score']


#For plotting the graph.
import scipy as sc
import pylab as pl
import recallPrecision as rp
#Fetched these data manually (tuple - Precision, Recall) 
prs = [(0.0834,0.0856), (0.17222,0.172222), (0.17222,0.17222),(0.21023,0.21344)] # precision recall point list
labels = ["size=10", "size=20", "size=30", "size=40"] # labels for the points
rp.plotPrecisionRecallDiagram("Precision - Recall Diagram", prs, labels)
pl.show()



Beispiel #5
0
def random():

    prs = sc.rand(15, 2)  # precision recall point list
    labels = ["item " + str(i) for i in range(15)]  # labels for the points
    rp.plotPrecisionRecallDiagram("footitle", prs, labels)
    pl.show()
Beispiel #6
0
def random():

    prs = sc.rand(15,2) # precision recall point list
    labels = ["item " + str(i) for i in range(15)] # labels for the points
    rp.plotPrecisionRecallDiagram("footitle", prs, labels)
    pl.show()
Beispiel #7
0
import scipy as sc
import pylab as pl
import recallPrecision as rp
prs = sc.rand(15,2) # precision recall point list
labels = ["item " + str(i) for i in range(15)] # labels for the points
rp.plotPrecisionRecallDiagram("footitle", prs, labels)
pl.show()