Thursday, February 12, 2009

Portfolio Assignment 3

So, Last.FM. This assignment proved to be a bit trickier than I had first anticipated. Initially, I was somewhat put off by the complete lack of documentation on the Pylastfm API. It was very sparse, and basically just had rudimentary instructions on how to "install" the module. This by itself gave me trouble, as I was not sure if the file should be put in the "lib" folder or in the general Python folder. The instructions were also designed for a Unix environment, so it took some figuring out for me to get it working. Finally, however, I was in fact able to get it installed in my Python directory, and succesfully connected with Last.FM to do some basic functions.

This is the code we used for this test:
import pylast

print "Welcome to the Team 3 Pylast Recommender!"
print "To find an artist similar to your artist, press (1)"
print "To find a list of top tracks by an artist, press (2)"
print "To find a list of songs similar to a particular song, press (3)"
print "To quit, press (4)"

input = raw_input(">")
print input

if (input=="1"):
print "Please enter the name of an Artist"
similarArtistName = raw_input(">")
similarArtist = pylast.Artist("similarArtistName", "bd46f9bce716e11a6d311d77c06d2159", "a313f7a6a587763c71eeb3cac498ca40", '')
print similarArtist.get_similar()
elif (input=="2"):
print "Please enter the name of an Artist"
trackArtistName = raw_input(">")
trackArtist = pylast.Artist("trackArtistName", "bd46f9bce716e11a6d311d77c06d2159", "a313f7a6a587763c71eeb3cac498ca40", '')
print pylast.Artist.get_top_tracks(trackArtist)


The track recommender did not work, and we were never able to figure out why. (Later on, we discovered that it secretly required an artist as well as track, despite the general API explicitly stating the opposite). At this point, we were able to connect with Will, and as we reviewed our total progress before, we realized that as a group, we had a substantial amount of combined knowledge of PHP, and none of us had any idea of how to implement a GUI in python. We did not want to be limited to a command line-style interface, so we decided that the best couse of action would be to change to a PHP driven website for the Recommender.

Here is a link to the final product we made via PHP:

http://rosemary.umw.edu/~wboyd/datamining/portfolio3/

It was again tricky to implement because the PHP api is different and more involved than the python one, and also because again several of the functions take more paramaters as input than the API would suggest. Still, we feel like it was a great success in implementing a recommender program on a dynamic website, with really cool feature we found in the API for listing the top artists and tracks of the userbase from various countries!

No comments:

Post a Comment