From f67fcbe57239334e6c090b0b51c941151e38a492 Mon Sep 17 00:00:00 2001 From: Anurag Agrawal Date: Thu, 9 Jul 2015 17:52:09 -0700 Subject: [PATCH] Delete MoiveTweets.py~ --- examples/MoiveTweets/MoiveTweets.py~ | 285 --------------------------- 1 file changed, 285 deletions(-) delete mode 100644 examples/MoiveTweets/MoiveTweets.py~ diff --git a/examples/MoiveTweets/MoiveTweets.py~ b/examples/MoiveTweets/MoiveTweets.py~ deleted file mode 100644 index 1eda12a..0000000 --- a/examples/MoiveTweets/MoiveTweets.py~ +++ /dev/null @@ -1,285 +0,0 @@ -##Ml-100k### - - -import psycopg2 -import sys -import time -import os -def main(): - - host = raw_input("Enter the host address of postgresql: ") - - dbname = raw_input("Enter the database name: ") - - user = raw_input("Enter the username of postgresql: ") - - password = raw_input("Enter the password of postgresql: ") - - UserDataPath = raw_input("Enter the abs path for user data(.CSV file): ") - - ItemDataPath = raw_input("Enter the abs path for item data(.CSV file):: ") - - RatingDataPath = raw_input("Enter the abs path for ratings data(.csv file): ") - - - #Define our connection string - conn_string = "host='"+host+"' dbname='"+dbname+"' user='"+user+"' password='"+password+"'" - - # print the connection string we will use to connect - print "Connecting to database\n ->%s" % (conn_string) - - # get a connection, if a connect cannot be made an exception will be raised here - conn = psycopg2.connect(conn_string) - cursor = conn.cursor() - - print "Data copying from .csv file to postgresql database" - - import os - path = os.getcwd() - - executionStart = time.time() - - cursor.execute("create table if not exists ratings (userid int, itemid int, rating int);"); - conn.commit() - executionTime = time.time() - executionStart - print "\n" - print (" Execution time is :-", executionTime) - - executionStart = time.time() - query = "copy ratings(userid, itemid, rating) from "+RatingDataPath+" DELIMITER ':';" - cursor.execute(query); - conn.commit() - executionTime = time.time() - executionStart - print "\n" - print (" Execution time is :-", executionTime) - - cursor.execute("create table if not exists users(userid int, other real);"); - conn.commit() - - query = "copy users(userid, other) from "+UserDataPath+" DELIMITER ':';" - cursor.execute(query); - conn.commit() - - - cursor.execute("create table if not exists moives( itemid int, name varchar, genre varchar, other varchar);"); - conn.commit() - - query = "copy moives(itemid, name, genre, other) from "+ItemDataPath+" DELIMITER ':';" - cursor.execute(query); - conn.commit() - - - - - print "Recommendation query being shooted with ItemCosCF technique" - - ############### - - print "\n \n Creating Recommender.." - executionStart = time.time() - cursor.execute("CREATE RECOMMENDER mtitemcos on ratings Users FROM userid Items FROM itemid Events FROM rating Using ItemCosCF;"); - conn.commit() - executionTime = time.time() - executionStart - print "\n" - print (" Execution time is :-", executionTime) - - ############### - - print "\n \n Selection of movie for single user.." - executionStart = time.time() - cursor.execute("select itemid from ratings RECOMMEND itemid to userid ON rating Using ItemCosCF where userid =21;"); - conn.commit() - executionTime = time.time() - executionStart - print "\n" - print (" Execution time is :-", executionTime) - - ############### - - print "\n \n Single Join Query.." - executionStart = time.time() - cursor.execute("select r.userid, r.itemid, r.rating, b.other from ratings r, moives a, users b Recommend itemid to userid ON rating using ItemCosCF where r.userid = b.userid and r.userid = 21;"); - conn.commit() - executionTime = time.time() - executionStart - print "\n" - print (" Execution time is :-", executionTime) - - ################ - - - print "\n \n Order by 10 .." - executionStart = time.time() - cursor.execute("select itemid from ratings RECOMMEND itemid to userid ON rating Using ItemCosCF where userid=21 order by rating DESC limit 10;"); - conn.commit() - executionTime = time.time() - executionStart - print "\n" - print (" Execution time is :-", executionTime) - - ################ - - print "\n \n Order by 50 .." - executionStart = time.time() - cursor.execute("select itemid from ratings RECOMMEND itemid to userid ON rating Using ItemCosCF where userid =21 order by rating DESC limit 50;"); - conn.commit() - executionTime = time.time() - executionStart - print "\n" - print (" Execution time is :-", executionTime) - - ################ - - print "\n \n Order by 100.." - executionStart = time.time() - cursor.execute("select itemid from ratings RECOMMEND itemid to userid ON rating Using ItemCosCF where userid=21 order by rating DESC limit 100;"); - conn.commit() - executionTime = time.time() - executionStart - print "\n" - print (" Execution time is :-", executionTime) - - ################ - ################ - - print "\n Recommendation query being shooted with ItemPearCF technique" - - ############### - - print "\n \n Creating Recommender.." - executionStart = time.time() - cursor.execute("CREATE RECOMMENDER mtitempear on ratings Users FROM userid Items FROM itemid Events FROM rating Using ItemPearCF;"); - conn.commit() - executionTime = time.time() - executionStart - print "\n" - print (" Execution time is :-", executionTime) - - ############### - - print "\n \n Selection of movie for single user.." - executionStart = time.time() - cursor.execute("select itemid from ratings RECOMMEND itemid to userid ON rating Using ItemPearCF where userid =21;"); - conn.commit() - executionTime = time.time() - executionStart - print "\n" - print (" Execution time is :-", executionTime) - - ############### - - print "\n \n Single Join Query.." - executionStart = time.time() - cursor.execute("select r.userid, r.itemid, r.rating from ratings r, moives a Recommend itemid to userid ON rating using ItemPearCF where r.itemid = a.itemid and a.itemid = 35423;"); - conn.commit() - executionTime = time.time() - executionStart - print "\n" - print (" Execution time is :-", executionTime) - - ################ - - - print "\n \n Order by 10 .." - executionStart = time.time() - cursor.execute("select itemid from ratings RECOMMEND itemid to userid ON rating Using ItemPearCF where userid =21 order by rating DESC limit 10;"); - conn.commit() - executionTime = time.time() - executionStart - print "\n" - print (" Execution time is :-", executionTime) - - ################ - - print "\n \n Order by 50 .." - executionStart = time.time() - cursor.execute("select itemid from ratings RECOMMEND itemid to userid ON rating Using ItemPearCF where userid =21 order by rating DESC limit 50;"); - conn.commit() - executionTime = time.time() - executionStart - print "\n" - print (" Execution time is :-", executionTime) - - ################ - - print "\n \n Order by 100.." - executionStart = time.time() - cursor.execute("select itemid from ratings RECOMMEND itemid to userid ON rating Using ItemPearCF where userid =21 order by rating DESC limit 100;"); - conn.commit() - executionTime = time.time() - executionStart - print "\n" - print (" Execution time is :-", executionTime) - - ################ - ################ - - print "\n Recommendation query being shooted with SVD technique" - - ############### - - print "\n \n Creating Recommender.." - executionStart = time.time() - cursor.execute("CREATE RECOMMENDER mtitemsvd on ratings Users FROM userid Items FROM itemid Events FROM rating Using SVD;"); - conn.commit() - executionTime = time.time() - executionStart - print "\n" - print (" Execution time is :-", executionTime) - - ############### - - print " \n \n Selection of movie for single user.." - executionStart = time.time() - cursor.execute("select itemid from ratings RECOMMEND itemid to userid ON rating Using SVD where userid =21;"); - conn.commit() - executionTime = time.time() - executionStart - print "\n" - print (" Execution time is :-", executionTime) - - ############### - - print " \n \n Single Join Query.." - executionStart = time.time() - cursor.execute("select r.userid, r.itemid, r.rating from ratings r, moives a Recommend itemid to userid ON rating using SVD where r.itemid = a.itemid and a.itemid = 35423;"); - conn.commit() - executionTime = time.time() - executionStart - print "\n" - print (" Execution time is :-", executionTime) - - ################ - - print "\n \n Order by 10 .." - executionStart = time.time() - cursor.execute("select itemid from ratings RECOMMEND itemid to userid ON rating Using SVD where userid =21 order by rating DESC limit 10;"); - conn.commit() - executionTime = time.time() - executionStart - print "\n" - print (" Execution time is :-", executionTime) - - ################ - - print "\n \n Order by 50 .." - executionStart = time.time() - cursor.execute("select itemid from ratings RECOMMEND itemid to userid ON rating Using SVD where userid =21 order by rating DESC limit 50;"); - conn.commit() - executionTime = time.time() - executionStart - print "\n" - print (" Execution time is :-", executionTime) - - ################ - - print "\n \n Order by 100.." - executionStart = time.time() - cursor.execute("select itemid from ratings RECOMMEND itemid to userid ON rating Using SVD where userid =21 order by rating DESC limit 100;"); - conn.commit() - executionTime = time.time() - executionStart - print "\n" - print (" Execution time is :-", executionTime) - - ################ - - cursor.execute("drop table ratings;"); - conn.commit() - - cursor.execute("drop table users;"); - conn.commit() - - cursor.execute("drop table moives;"); - conn.commit() - - - - -if __name__ == "__main__": - main() - -