-
Notifications
You must be signed in to change notification settings - Fork 0
/
CUR.html
80 lines (77 loc) · 5.75 KB
/
CUR.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module CUR</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>CUR</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:d%3A%5Cstudies%5C3-1%5Cir%5Crecommender-systems%5Ccur.py">d:\studies\3-1\ir\recommender-systems\cur.py</a></font></td></tr></table>
<p></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="math.html">math</a><br>
<a href="numpy.html">numpy</a><br>
</td><td width="25%" valign=top><a href="os.html">os</a><br>
<a href="pickle.html">pickle</a><br>
</td><td width="25%" valign=top><a href="time.html">time</a><br>
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-CUR"><strong>CUR</strong></a>(A, num_dimensions, recomputeMatrix=False, energy_needed=1.0)</dt><dd><tt>Takes the user rating matrix and returns the computed C, U and R matrices.<br>
If it finds that the file CUR_Matrices.txt already exists, it unpickles it and returns them,<br>
else it computes them, pickles them and then returns them, You can recompute these matrices<br>
using the boolean flag recomputeMatrix .<br>
<br>
@type A: Numpy array<br>
@param A : matrix that has to be decomposed<br>
@type recomputeMatrix: boolean<br>
@param recomputeMatrix : as name suggests, recompute the decomposition matrices, pickle them and return the matrices<br>
@type: energy_needed: float in range [0,1]<br>
@param energy_needed: float, the energy that has to be retained during the decomposition<br>
@rtype (C,U,R) tuple of Numpy arrays <br>
@return (C,U,R): tuple of decomposed matrices</tt></dd></dl>
<dl><dt><a name="-Energy"><strong>Energy</strong></a>(A)</dt></dl>
<dl><dt><a name="-precisionTopK"><strong>precisionTopK</strong></a>(k, q, R)</dt><dd><tt>This function calculates the Precision Top K<br>
<br>
@type k : number<br>
@param k : The k in Precision Top k<br>
@type q: Square matrix (1D) (numpy Array)<br>
@parma q: Query Vector<br>
@type R: Square matrix (numpy Array)<br>
@param R: The V obtained from the SVD<br>
@rtype: number<br>
@return: Precision Top K value obtained</tt></dd></dl>
<dl><dt><a name="-query"><strong>query</strong></a>(q, R)</dt><dd><tt>This function queries the CUR matrix given a query vector<br>
<br>
@type q: Square matrix (1D) (numpy Array)<br>
@param q: Query vector<br>
@type R: Square matrix (numpy Array)<br>
@param R: The V obtained from the SVD<br>
@rtype: Square matrix (1D) (numpy Array)<br>
@return: The result vector obtained</tt></dd></dl>
<dl><dt><a name="-rmse"><strong>rmse</strong></a>(originalMatrix, C, U, R)</dt><dd><tt>Calculates the Root mean Squared Error(RMSE) incurred after CUR decomposition<br>
<br>
@param A: original matrix<br>
@param C: Vector numpy<br>
@param U: Vector numpy<br>
@param R:Vector numpy<br>
<br>
@return error: reconstruction error incurred while decomposing</tt></dd></dl>
<dl><dt><a name="-spearmanCoefficient"><strong>spearmanCoefficient</strong></a>(predicted_rating, test_rating)</dt><dd><tt>This function calculates the spearman coefficient of two vectors<br>
@type predicted_rank: Numpy array<br>
@param: predicted_rating: predicted rating by the decomposition<br>
@type test_rating: Numpy array<br>
@param: test_rating: actual rating<br>
@rtype: float<br>
@return rho: the spearman coefficient</tt></dd></dl>
</td></tr></table>
</body></html>