how to write code for given algorithm
Show older comments
Input:
train_data(d1,d2….dm) //training document vectors
with n features
test_data(d1,d2…dk) // testing document vectors p
features
Output:
sim_matrix // Similarity matrix
Steps:
- [m,n]= size of train_data
- [k,p]= size of test_data
- Take Lamda=1 and sigma(1:n) =2
- Take N*D=0 and NuD=0
- for each document in test data and for each documentin training data
- if test_data[r,j] . train_data[i,j]>0
- then n1=0.5*(1+exp(-((train_data[r,j]-test_data[i,j])/sigma[j])^2))
- if test_data[I,j] and train_data[r,j]=0
- then n1=0
- otherwise n1=-lamda
- end if
- N*D[i,r]=N*D[i,r]+n1[r,j]
- end for
- for each feature in train data
- if train_data[r,j] and test[i,j]=0
- then n2=0
- otherwise n2=1
- end if
- NuD[i,r]=NuD[i,r]+n2[r,j]
- end loop
1 Comment
Image Analyst
on 3 Jan 2017
Answers (1)
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!