|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.cutunes.server.Analyzer
Handles most of the analysis and data archiving Does the following tasks:
Field Summary | |
java.sql.Connection |
dbConnect
|
static int |
SIMILARITY_CUT_OFF
between 1 and 100, can be used to limit complexity/improve results |
Constructor Summary | |
Analyzer()
Constructor Connects to the database |
Method Summary | |
void |
calculateAndLoadArtistDist(java.lang.String directory)
Calculate Artist Distance data from the data in a directory and load that data into the sql database |
void |
calculateAndLoadRecs(java.util.Vector userSimInfo)
Calculate and load recs given user similarity info |
java.util.Vector |
calculateAndLoadUserCompatibility(java.lang.String directory)
Calculate User Compatibility data from the data in a directory and load that data into the sql database |
void |
clearRecsForUser(int userID1,
java.lang.String type,
java.lang.String playCountType)
Clear recs for current user |
java.lang.String |
collectData()
Collect data from the database, and archive it to a file |
void |
connectToDatbase()
Connects to CUtunes Database |
void |
formatDataForMatlab(java.lang.String directory,
java.lang.String outputDirectory)
Format data to be read into matlab |
java.util.Vector |
getAllItems(java.lang.String type,
java.lang.String play_count_type)
Get a list of items (either songs, albums, or artists) The number of items returned is limited by the global parameters NUM_ITEMS |
void |
getAndLoadReccomendaton(int userID1,
java.util.Vector userIDs,
int userIndex1,
java.lang.String type,
java.lang.String playCountType,
int[][] similarity)
Gets reccomendations for current user and loads them into the db |
java.util.Vector |
getArtistDistanceInfo(java.lang.String directory,
java.lang.String play_count_type,
int limit)
Calculate artist compatibility info |
java.util.Vector |
getItemInfo(java.lang.String directory,
java.lang.String type,
java.lang.String play_count_type)
Get item info from archived data, items can be songs, albums, or artists |
void |
getNNewItems(int userID2,
int n,
java.util.Hashtable myItems,
java.util.Hashtable newItems,
int simRank,
java.lang.String type,
java.lang.String playCountType)
Gets N new songs/albums/artists from another user This method should probably be replaced by a more efficient sql query Scores for recs are weighted by similarity with that user |
int |
getTotalPlays(int userID,
java.lang.String playCountType)
Get total play counts for a user |
java.util.Vector |
getUserCompatibilityInfo(java.lang.String directory,
java.lang.String type,
java.lang.String play_count_type)
Calculate user compatibility info |
java.util.Vector |
getUserInfo(java.lang.String directory)
Get user info from an archived set of data |
java.util.Vector |
getUserItems(java.lang.String type,
java.lang.String play_count_type,
int user_id)
Get a list of items for a given user, items can be either songs, albums, or artists |
java.util.Vector |
getUsers()
get list of user_ids, and userinfo to print to text file |
double |
KLdistanceMetric(double p,
double q)
Distance metric for comparing two users of an item |
java.util.Hashtable |
loadHashtable(int userID1,
java.lang.String type,
java.lang.String playCountType)
This method loads a hashtable with all of the users song It is used to identify songs in common, and quickly retrieve play counts |
void |
loadRecIntoDB(int userID1,
java.lang.String s,
int r,
java.lang.String type,
java.lang.String playCountType)
Load a reccomendation into the db for current user |
static void |
main(java.lang.String[] args)
The main method |
void |
printData(jmp.SparseColumnMatrix theMat)
Debug method for printing the first 20 items in the matrix parameter theMat |
void |
printList(java.util.Vector v,
java.lang.String filename)
Print a vector of strings to a file |
jmp.SparseColumnMatrix |
readMatrixDataFile(java.lang.String filename)
Read a matrix from a file |
double |
userDistanceMetric(double p,
double q)
Distance metric for comparing two items of a user (one dimension) |
void |
writeDistanceSQL(java.lang.String filename,
int[][] dists,
java.util.Vector names)
Write distance information to an sql file |
void |
writeMatrixDataFile(jmp.SparseColumnMatrix mat,
java.lang.String filename)
Write a matrix to a file |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int SIMILARITY_CUT_OFF
public java.sql.Connection dbConnect
Constructor Detail |
public Analyzer()
Method Detail |
public static void main(java.lang.String[] args)
args
- public void calculateAndLoadArtistDist(java.lang.String directory)
directory
- public void formatDataForMatlab(java.lang.String directory, java.lang.String outputDirectory)
directory
- directory of the dataoutputDirectory
- output directorypublic java.util.Vector calculateAndLoadUserCompatibility(java.lang.String directory)
directory
-
public java.util.Vector getUserCompatibilityInfo(java.lang.String directory, java.lang.String type, java.lang.String play_count_type)
directory
- directory of the archivetype
- "song", "album", or "artist"play_count_type
- "play_count", "play_count_week"
public java.util.Vector getArtistDistanceInfo(java.lang.String directory, java.lang.String play_count_type, int limit)
directory
- directory of the archiveplay_count_type
- "play_count", "play_count_week"
public double userDistanceMetric(double p, double q)
p
- q
-
public double KLdistanceMetric(double p, double q)
p
- q
-
public void writeDistanceSQL(java.lang.String filename, int[][] dists, java.util.Vector names)
dists
- 2d array containing distance informationnames
- Vector of namespublic java.util.Vector getItemInfo(java.lang.String directory, java.lang.String type, java.lang.String play_count_type)
directory
- directory of the archivetype
- "song", "album", or "artist"play_count_type
- "play_count", "play_count_week"
public java.util.Vector getUserInfo(java.lang.String directory)
directory
- the directory of the archive
public jmp.SparseColumnMatrix readMatrixDataFile(java.lang.String filename)
filename
-
public java.lang.String collectData()
public void writeMatrixDataFile(jmp.SparseColumnMatrix mat, java.lang.String filename)
mat
- filename
- public void printList(java.util.Vector v, java.lang.String filename)
v
- filename
- public void calculateAndLoadRecs(java.util.Vector userSimInfo)
userSimInfo
- A vector containing the following items:
public void getAndLoadReccomendaton(int userID1, java.util.Vector userIDs, int userIndex1, java.lang.String type, java.lang.String playCountType, int[][] similarity)
userID1
- the userIDuserIDs
- all user IDsuserIndex1
- the index of userID in similarity tabletype
- song, album, or artistplayCountType
- all time, or weeksimilarity
- 2d array containing similarity infopublic void clearRecsForUser(int userID1, java.lang.String type, java.lang.String playCountType)
type
- name (song name), album, artistplayCountType
- play_count or play_count_weekpublic void loadRecIntoDB(int userID1, java.lang.String s, int r, java.lang.String type, java.lang.String playCountType)
s
- the reccomendation to loadr
- the value for how strong the reccomendation istype
- name (song name), album, artistplayCountType
- play_count or play_count_weekpublic void getNNewItems(int userID2, int n, java.util.Hashtable myItems, java.util.Hashtable newItems, int simRank, java.lang.String type, java.lang.String playCountType)
userID2
- The other user to get recs fromn
- number of items to collectmyItems
- hashtable of current users musicnewItems
- hashtable of new itemssimRank
- similarity with other usertype
- name (song name), album, artistplayCountType
- play_count or play_count_weekpublic java.util.Hashtable loadHashtable(int userID1, java.lang.String type, java.lang.String playCountType)
userID1
- type
- name (song name), album, artistplayCountType
- play_count or play_count_week
public java.util.Vector getUserItems(java.lang.String type, java.lang.String play_count_type, int user_id)
type
- type of item to return, can be "song", "album", or "artist"play_count_type
- either "play_count" or "play_count_week"user_id
-
public java.util.Vector getAllItems(java.lang.String type, java.lang.String play_count_type)
type
- type of item to return, can be "song", "album", or "artist"play_count_type
- either "play_count" or "play_count_week"
public java.util.Vector getUsers()
public void printData(jmp.SparseColumnMatrix theMat)
theMat
- public int getTotalPlays(int userID, java.lang.String playCountType)
userID
- playCountType
-
public void connectToDatbase()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |