Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: PriyaB272/particle
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: fnumegha/BookLook
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.

Commits on Apr 27, 2018

  1. Update header.html

    fnumegha authored Apr 27, 2018
    Copy the full SHA
    2e5ebbf View commit details
  2. Update header.html

    fnumegha authored Apr 27, 2018
    Copy the full SHA
    3b80db3 View commit details
  3. Update header.html

    fnumegha authored Apr 27, 2018
    Copy the full SHA
    41231a3 View commit details
  4. Update results.html

    fnumegha authored Apr 27, 2018
    Copy the full SHA
    fdb209e View commit details
  5. Create none

    fnumegha authored Apr 27, 2018
    Copy the full SHA
    41554c7 View commit details
  6. Add files via upload

    fnumegha authored Apr 27, 2018
    Copy the full SHA
    a4af6c8 View commit details
  7. Delete none

    fnumegha authored Apr 27, 2018
    Copy the full SHA
    799be4e View commit details
  8. Update default.html

    fnumegha authored Apr 27, 2018
    Copy the full SHA
    2eea132 View commit details
  9. Copy the full SHA
    7d614c0 View commit details
  10. Copy the full SHA
    099e7bd View commit details
  11. Create codelogistics.html

    fnumegha authored Apr 27, 2018
    Copy the full SHA
    4af441b View commit details
  12. Update header.html

    fnumegha authored Apr 27, 2018
    Copy the full SHA
    e615bdc View commit details
  13. Update header.html

    fnumegha authored Apr 27, 2018
    Copy the full SHA
    6d2b573 View commit details
  14. Update footer.html

    fnumegha authored Apr 27, 2018
    Copy the full SHA
    337180d View commit details
  15. Update README.md

    fnumegha authored Apr 27, 2018
    Copy the full SHA
    09ffffd View commit details
  16. Add files via upload

    fnumegha authored Apr 27, 2018
    Copy the full SHA
    cd7c83f View commit details
  17. Update projects.html

    fnumegha authored Apr 27, 2018
    Copy the full SHA
    a8f0e60 View commit details
  18. Update projects.html

    fnumegha authored Apr 27, 2018
    Copy the full SHA
    8c49d10 View commit details
  19. Update projects.html

    fnumegha authored Apr 27, 2018
    Copy the full SHA
    460569b View commit details
  20. Add files via upload

    fnumegha authored Apr 27, 2018
    Copy the full SHA
    8550d74 View commit details
  21. Delete BookLook_final.ipynb

    fnumegha authored Apr 27, 2018
    Copy the full SHA
    f09d74e View commit details
  22. Copy the full SHA
    5581b66 View commit details
  23. Delete BookLook_final.ipynb

    fnumegha authored Apr 27, 2018
    Copy the full SHA
    0505196 View commit details
  24. Add files via upload

    fnumegha authored Apr 27, 2018
    Copy the full SHA
    6aa0126 View commit details
1 change: 1 addition & 0 deletions Code/BookLook_RBM.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"RBM_bookLook.ipynb","version":"0.3.2","views":{},"default_view":{},"provenance":[]},"kernelspec":{"display_name":"Python 2","language":"python","name":"python2"}},"cells":[{"metadata":{"id":"bZ7J1PgBxzG0","colab_type":"code","colab":{"autoexec":{"startup":false,"wait_interval":0}}},"cell_type":"code","source":["## Implementing RBM\n","import numpy as np\n","import pandas as pd\n","import torch\n","import torch.nn as nn # for building neural network\n","import torch.nn.parallel # for parallel computing\n","import torch.optim as optim # for optimisation\n","import torch.utils.data \n","from torch.autograd import Variable # for stocastic gradient descent"],"execution_count":0,"outputs":[]},{"metadata":{"id":"jrkPw02JxzG5","colab_type":"code","colab":{"autoexec":{"startup":false,"wait_interval":0}}},"cell_type":"code","source":["df = pd.read_csv('BX-Book-Ratings.csv', names=[\"User-ID\", \"ISBN\", \"Book-Rating\"], delimiter=\";\")\n","\n","df_mat = df.as_matrix()[1:]\n","\n","df_mat[:,0] = df_mat[:,0].astype('int64')\n","df_mat[:,2] = df_mat[:,2].astype('int64')\n","\n","usercount = (len(np.unique(df_mat[:,0])))\n","bookcount = (len(np.unique(df_mat[:,1])))\n","\n"],"execution_count":0,"outputs":[]},{"metadata":{"id":"rlLnseH2xzG9","colab_type":"code","colab":{"autoexec":{"startup":false,"wait_interval":0}}},"cell_type":"code","source":["rating_matrix = np.ndarray(shape=(10000,10000), dtype = 'int64')\n","rating_matrix = np.zeros(shape=(10000,10000))\n"],"execution_count":0,"outputs":[]},{"metadata":{"id":"cwfyYLS5xzHB","colab_type":"code","colab":{"autoexec":{"startup":false,"wait_interval":0}}},"cell_type":"code","source":["rating_matrix_test = np.zeros(shape=(10000,10000))\n","rating_matrix_test = np.ndarray(shape=(10000,10000), dtype = 'int64')"],"execution_count":0,"outputs":[]},{"metadata":{"id":"PCNIhKBZxzHE","colab_type":"code","colab":{"autoexec":{"startup":false,"wait_interval":0}}},"cell_type":"code","source":["bookid = 0\n","usernum = 0\n","bookmap = {}\n","usermap = {}\n","useridslist = []\n","for k in range(0,500000):\n"," userid = df_mat[k,0]\n"," isbn = df_mat[k,1]\n"," if isbn not in bookmap:\n"," if bookid < 10000:\n"," bookmap[isbn] = bookid\n"," if userid not in usermap:\n"," if usernum < 10000:\n"," usermap[userid]=usernum\n"," rating_matrix[usernum, bookid] = df_mat[k,2]\n"," usernum+=1\n"," else:\n"," rating_matrix[usermap[userid], bookid] = df_mat[k,2]\n"," bookid = bookid+1\n"," else:\n"," if userid not in usermap:\n"," if usernum < 10000:\n"," usermap[userid]=usernum\n"," rating_matrix[usernum, bookmap[isbn]] = df_mat[k,2]\n"," usernum+=1\n"," else:\n"," rating_matrix[usermap[userid], bookmap[isbn]] = df_mat[k,2]\n"," "],"execution_count":0,"outputs":[]},{"metadata":{"id":"4xH0LdcrxzHI","colab_type":"code","colab":{"autoexec":{"startup":false,"wait_interval":0}}},"cell_type":"code","source":["usertestmap = {}\n","booktestmap = {}\n","uid = 0 \n","iid = 0"],"execution_count":0,"outputs":[]},{"metadata":{"id":"aZ6XecQexzHL","colab_type":"code","colab":{"autoexec":{"startup":false,"wait_interval":0}}},"cell_type":"code","source":["bookid = 0\n","usernum = 0\n","booktestmap = {}\n","usertestmap = {}\n","for k in range(700000, 1000000):\n"," userid = df_mat[k,0]\n"," isbn = df_mat[k,1]\n"," if isbn not in booktestmap:\n"," if bookid < 10000:\n"," booktestmap[isbn] = bookid\n"," if userid not in usertestmap:\n"," if usernum < 10000:\n"," usertestmap[userid]=usernum\n"," rating_matrix_test[usernum, bookid] = df_mat[k,2]\n"," usernum+=1\n"," else:\n"," rating_matrix_test[usertestmap[userid], bookid] = df_mat[k,2]\n"," bookid = bookid+1\n"," else:\n"," if userid not in usertestmap:\n"," if usernum < 10000:\n"," usertestmap[userid]=usernum\n"," rating_matrix_test[usernum, booktestmap[isbn]] = df_mat[k,2]\n"," usernum+=1\n"," else:\n"," rating_matrix_test[usertestmap[userid], booktestmap[isbn]] = df_mat[k,2]"],"execution_count":0,"outputs":[]},{"metadata":{"id":"_Am_JqZVxzHP","colab_type":"code","colab":{"autoexec":{"startup":false,"wait_interval":0}},"outputId":"40ad82ed-e0d4-413f-efe8-c7649891cc18"},"cell_type":"code","source":["print rating_matrix_test"],"execution_count":0,"outputs":[{"output_type":"stream","text":["[[10 0 0 ..., 0 0 0]\n"," [ 0 0 0 ..., 0 0 0]\n"," [ 0 0 0 ..., 0 0 0]\n"," ..., \n"," [ 0 0 0 ..., 0 0 0]\n"," [ 0 0 0 ..., 0 0 0]\n"," [ 0 0 0 ..., 0 0 0]]\n"],"name":"stdout"}]},{"metadata":{"id":"96dOUDj-xzHW","colab_type":"text"},"cell_type":"markdown","source":[""]},{"metadata":{"id":"z5gS7bTNxzHX","colab_type":"code","colab":{"autoexec":{"startup":false,"wait_interval":0}}},"cell_type":"code","source":["# converting the data into torch tensors\n","rating_matrix = torch.FloatTensor(rating_matrix)\n"],"execution_count":0,"outputs":[]},{"metadata":{"id":"V4G4T_-pxzHa","colab_type":"code","colab":{"autoexec":{"startup":false,"wait_interval":0}}},"cell_type":"code","source":["# converting ratings to binary: rating > 6 is liked = 1, otw not liked\n","# the original 0's in the training set are given a value of -1\n","\n","rating_matrix[rating_matrix == 0] = -1\n","\n","rating_matrix[rating_matrix == 1] = 0\n","rating_matrix[rating_matrix == 2] = 0\n","rating_matrix[rating_matrix == 3] = 0\n","rating_matrix[rating_matrix == 4] = 0\n","rating_matrix[rating_matrix == 5] = 0\n","rating_matrix[rating_matrix == 6] = 0\n","rating_matrix[rating_matrix == 7] = 0\n","\n","# converting all ratings > 7 to 1\n","rating_matrix[rating_matrix >= 8] = 1\n"],"execution_count":0,"outputs":[]},{"metadata":{"id":"c1HgINrWxzHe","colab_type":"code","colab":{"autoexec":{"startup":false,"wait_interval":0}}},"cell_type":"code","source":["rating_matrix_test = torch.FloatTensor(rating_matrix_test)\n","\n","rating_matrix_test[rating_matrix_test == 0] = -1\n","rating_matrix_test[rating_matrix_test == 1] = 0\n","rating_matrix_test[rating_matrix_test == 2] = 0\n","rating_matrix_test[rating_matrix_test == 3] = 0\n","rating_matrix_test[rating_matrix_test == 4] = 0\n","rating_matrix_test[rating_matrix_test == 5] = 0\n","rating_matrix_test[rating_matrix_test == 6] = 0\n","rating_matrix_test[rating_matrix_test == 7] = 0\n","rating_matrix_test[rating_matrix_test >= 8] = 1"],"execution_count":0,"outputs":[]},{"metadata":{"id":"UnO2D3bcxzHi","colab_type":"code","colab":{"autoexec":{"startup":false,"wait_interval":0}}},"cell_type":"code","source":["# creating the RBM neural network\n","class RBM():\n"," def __init__(self, nv, nh):\n"," self.W = torch.randn(nh, nv) #initialising weights in torch\n"," self.a = torch.randn(1, nh) # to initialise the RBM object\n"," self.b = torch.randn(1, nv) # for bias\n"," \n"," # use gibbs sampling to improve log likelihood gradient\n"," # sample_h : sample prob of hidden nodes, given visible nodes\n"," def sample_h(self, x):\n"," wx = torch.mm(x, self.W.t()) # multiply w(tensor weights) and x(visible neurons)\n"," activ = wx + self.a.expand_as(wx) # to add bias to every row of neuron\n"," prob_h_given_v = torch.sigmoid(activ)\n"," return prob_h_given_v, torch.bernoulli(prob_h_given_v) # returns prob and neurons activated by this sampling\n"," \n"," # sample v: prob of visible nodes, given hidden nodes\n"," # estimating prob of visible nodes\n"," def sample_v(self,y):\n"," wy = torch.mm(y, self.W) # multiply w(tensor weights) and x(visible neurons)\n"," activ = wy + self.b.expand_as(wy) # to add bias to every row of neuron\n"," prob_v_given_h = torch.sigmoid(activ)\n"," return prob_v_given_h, torch.bernoulli(prob_v_given_h) # returns prob and neurons activated by this sampling\n"," \n"," def train(self,v0, vk, ph0, phk): # Using k-step contrastive divergence\n"," #v0:input vec having ratings of all movies by 1 user, vk: visible nodes obtained after k iterations, \n"," #ph0: prob of hidden nodes= 1 in first iteration , phk: prob of hidden nodes after k sampling\n"," self.W += torch.mm(v0.t(),ph0) - torch.mm(vk.t(), phk)\n"," self.b += torch.sum((v0-vk),0) \n"," self.a += torch.sum((ph0-phk),0)\n"," \n"," "],"execution_count":0,"outputs":[]},{"metadata":{"id":"RCIu1c8mxzHn","colab_type":"code","colab":{"autoexec":{"startup":false,"wait_interval":0}},"outputId":"e424c1ed-a7bd-4d1b-c038-79a0c13f113a"},"cell_type":"code","source":["nv = len(rating_matrix[0]) # no. of visible nodes\n","print nv\n","nh = 100 # number of features we want to detect\n","\n","# batch size: to update weights after several iterations and not afer each one\n","batch_size = 1000\n","rbm = RBM(nv,nh)\n"],"execution_count":0,"outputs":[{"output_type":"stream","text":["10000\n"],"name":"stdout"}]},{"metadata":{"id":"01rmpelpxzHt","colab_type":"code","colab":{"autoexec":{"startup":false,"wait_interval":0}},"outputId":"36173cc5-6945-4c67-cfd0-1b8ca0f372ee"},"cell_type":"code","source":["n_iter = 5\n","for iter in range(0, n_iter):\n"," train_loss = 0\n"," rms_train_loss = 0\n"," counter = 0.\n"," for user in range(0, 10000 - batch_size, batch_size):\n"," vk = rating_matrix[user:user+batch_size]# op of gibbs sampling afte k iterations of random walk\n"," v0 = rating_matrix[user:user+batch_size]\n"," ph0,_ = rbm.sample_h(v0)\n"," for k in range(10): # for k steps of contrastive div\n"," _,hk = rbm.sample_h(vk)\n"," _,vk = rbm.sample_v(hk)\n"," vk[v0<0]= v0[v0<0] # to eliminate -1 ratings\n"," phk,_ = rbm.sample_h(vk)\n"," rbm.train(v0,vk,ph0,phk)\n"," train_loss += torch.mean(torch.abs(v0[v0>=0] - vk[v0>=0])) #MAE\n"," rms_train_loss += torch.mean((v0[v0>=0] - vk[v0>=0])**2) #RMSE\n"," #train_loss += torch.mean(torch.abs(v0[v0>=0] - vk[v0>=0])) #MAE\n"," counter += 1.\n"," print \"MAE on training for iter #\"+str(iter)+\" is: \"+str(train_loss/counter)\n"," print \"RMSE on training for iter #\"+str(iter)+\" is: \"+str((rms_train_loss/counter)**0.5)\n"," print \"\"\n"," \n"," \n"," \n"," "],"execution_count":0,"outputs":[{"output_type":"stream","text":["MAE on training for iter #0 is: 0.380275072065\n","RMSE on training for iter #0 is: 0.616664472842\n","\n","MAE on training for iter #1 is: 0.377912293285\n","RMSE on training for iter #1 is: 0.614745714328\n","\n","MAE on training for iter #2 is: 0.375525298138\n","RMSE on training for iter #2 is: 0.612801189733\n","\n","MAE on training for iter #3 is: 0.370339020544\n","RMSE on training for iter #3 is: 0.608554862394\n","\n","MAE on training for iter #4 is: 0.371679191732\n","RMSE on training for iter #4 is: 0.609654977616\n","\n"],"name":"stdout"}]},{"metadata":{"id":"k9-SXoYLxzHy","colab_type":"code","colab":{"autoexec":{"startup":false,"wait_interval":0}},"outputId":"8c7c8dd2-4a33-4ebe-cafe-bad0c3f33d4c"},"cell_type":"code","source":["\n","test_loss = 0\n","counter = 0.\n","mae_test_loss = 0\n","rmse_test_loss = 0\n","\n","for user in range(10000):\n"," v = rating_matrix[user:user+1]\n"," vt = rating_matrix_test[user:user+1]\n"," if len(vt[vt>=0]) > 0:\n"," _,h = rbm.sample_h(v)\n"," _,v = rbm.sample_v(h)\n"," if len(vt[vt>=0]) > 0 and len(v[vt>=0]) > 0:\n"," mae_test_loss += torch.mean(torch.abs(vt[vt>=0] - v[vt>=0])) #MAE\n"," rmse_test_loss += torch.mean((vt[vt>=0] - v[vt>=0])**2) #RMSE\n"," counter += 1.\n","print \"MAE on testing is: \"+str(mae_test_loss/counter)\n","print \"RMSE on testing is: \"+str((rmse_test_loss/counter)**0.5)\n"," \n"],"execution_count":0,"outputs":[{"output_type":"stream","text":["MAE on training for iter #4 is: 0.347591827294\n","RMSE on training for iter #4 is: 0.589569187877\n"],"name":"stdout"}]},{"metadata":{"id":"yt5V-q8ExzH2","colab_type":"code","colab":{"autoexec":{"startup":false,"wait_interval":0}}},"cell_type":"code","source":[""],"execution_count":0,"outputs":[]}]}
1,180 changes: 1,180 additions & 0 deletions Code/BookLook_SVD.ipynb

Large diffs are not rendered by default.

1,179 changes: 1,179 additions & 0 deletions Code/BookLook_final.ipynb

Large diffs are not rendered by default.

73 changes: 0 additions & 73 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,74 +1 @@
# Particle Jekyll Theme

![](./particle.jpg)

This is a simple and minimalist template for Jekyll designed for developers that want to show of their portfolio.

The Theme features:

- Gulp
- SASS
- Sweet Scroll
- Particle.js
- BrowserSync
- Font Awesome and Devicon icons
- Google Analytics
- Info Customization

## Basic Setup

1. [Install Jekyll](http://jekyllrb.com)
2. Fork the [Particle Theme](https://github.com/nrandecker/particle/fork)
3. Clone the repo you just forked.
4. Edit `_config.yml` to personalize your site.

## Site and User Settings

You have to fill some informations on `_config.yml` to customize your site.

```
# Site settings
description: A blog about lorem ipsum dolor sit amet
baseurl: "" # the subpath of your site, e.g. /blog/
url: "http://localhost:3000" # the base hostname & protocol for your site
# User settings
username: Lorem Ipsum
user_description: Anon Developer at Lorem Ipsum Dolor
user_title: Anon Developer
email: anon@anon.com
twitter_username: lorem_ipsum
github_username: lorem_ipsum
gplus_username: lorem_ipsum
```

**Don't forget to change your url before you deploy your site!**

## Color and Particle Customization
- Color Customization
- Edit the sass variables
- Particle Customization
- Edit the json data in particle function in app.js
- Refer to [Particle.js](https://github.com/VincentGarreau/particles.js/) for help

## Running the blog in local

In order to compile the assets and run Jekyll on local you need to follow those steps:

- Install [NodeJS](https://nodejs.org/)
- Run `npm install`
- Run `gulp`

## Questions

Having any issues file a [GitHub Issue](https://github.com/nrandecker/particle/issues/new).

## License

This theme is free and open source software, distributed under the The MIT License. So feel free to use this Jekyll theme anyway you want.

## Credits

This theme was partially designed with the inspiration from these fine folks
- [Willian Justen](https://github.com/willianjusten/will-jekyll-template)
- [Vincent Garreau](https://github.com/VincentGarreau/particles.js/)
12 changes: 12 additions & 0 deletions _includes/codelogistics.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<div class="user-details">
<h1>Code Logistics</h1>
</div>
<div class="user">
<div class="tech">
<p align="center">The ipynb files with the code can be found in the below location. There are 3 separate files in the location.
The file BookLook_final.ipynb is the file that has the LHSCM implememntation. The BookLook_SVD.ipynb is the file that has
the SVD model implementation and BookLook_RBM has the Neural network model implementation.</br>
<a href="https://github.com/fnumegha/BookLook/tree/master/Code" target="_blank">https://github.com/fnumegha/BookLook/tree/master/Code</a>
</p>
</div>
</div>
2 changes: 1 addition & 1 deletion _includes/footer.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<footer class="footer">
<p>&copy; {{site.username}}</p>
<p>Build with Jekyll and <span class="love"></span> by <a href="https://github.com/nrandecker">Nathan Randecker</a></p>
<p>A CSCE 670 adventure. Built with <span class="love"></span></p>
</footer>
<script src="//cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js"></script>
<script src="{{ "/assets/js/sweet-scroll.min.js" | prepend: site.baseurl }}"></script>
4 changes: 3 additions & 1 deletion _includes/header.html
Original file line number Diff line number Diff line change
@@ -6,10 +6,12 @@ <h1>
</h1>
<div class="header-links">
<a class="link" href="#about" data-scroll>About</a>
<a class="link" href="#relatedwork" data-scroll>Related Work</a>
<a class="link" href="#projects" data-scroll>Methodology</a>
<a class="link" href="#lhscm" data-scroll>LHSCM Method</a>
<a class="link" href="#evaluation" data-scroll>Evaluation</a>
<a class="link" href="#rbm" data-scroll>RBM</a>
<a class="link" href="#rbm" data-scroll>Code</a>
<a class="link" href="#references" data-scroll>References</a>
</div>
</div>
<a class="down" href="#about" data-scroll><i class="icon fa fa-chevron-down" aria-hidden="true"></i></a>
5 changes: 3 additions & 2 deletions _includes/projects.html
Original file line number Diff line number Diff line change
@@ -3,11 +3,12 @@ <h1> Methodology </h1>
</div>
<div class="user">
<div class="tech">
<p>To take advantage of the dislikes of the user, we plan to use the method of 'Love-Hate Square Counting Method' proposed in
<p align = "center">To take advantage of the dislikes of the user, we plan to use the method of 'Love-Hate Square Counting Method' proposed in
[1] Let's take an example to explain this! Suppose Cav is friends with Trump and Parisa. Now, Cav hates 3 books which Trump
also hates & Cav loves 3 books which Parisa also loves. Now if we know that Trump likes "Twilight" and Parisa likes "Life of
Pie", then , is it more likely for Cav to like "Twilight" or "Life of Pie"?
This is exactly the question we are trying to answer with BookLook! </p>
</div>
</div>

<div class="images">
<img alt="LoveHate" src="{{ "/assets/img/LoveHate.jpg" | prepend: site.baseurl }}" /></div>
2 changes: 1 addition & 1 deletion _includes/results.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="user-details">
<h1>Results</h1>
<h1>Evaluation</h1>

</div>

3 changes: 3 additions & 0 deletions _layouts/default.html
Original file line number Diff line number Diff line change
@@ -27,6 +27,9 @@
<section id="rbm">
{% include NeuralNets.html %}
</section>
<section id="code">
{% include codelogistics.html %}
</section>
<section id="references">
{% include references.html %}
</section>
Binary file added assets/img/LoveHate.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.