Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Importing R cosine similarity to UNIX? Post 302767747 by A-V on Thursday 7th of February 2013 11:28:10 AM
Old 02-07-2013
I have two files each of 6 lines each representing the frequency of specific words
now I wanted to calculate the cosine similarity between these files

for R I simply combine both files and extracted the bits from overall matrix that I needed
Code:
test <- as.matrix(read.csv(file="file.csv", sep=",", header=FALSE)) 
result<- cosine(t(test))
result-files <- (result[7:12,1:6])

I know that is not the best solution but it was easier as I am new to both languages

I have tried to get R running in cygwin but didnt manage... so now I am wondering whether it is possible to do cosine similarity calculations in unix... is there any shortcuts on doing so?

I a working on windows Vista

Cheers
 

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

importing database from unix to winnt

i am a unix-super-beginner (swaddled and weaned on windows) and am trying to import a database from a unix directory into winnt. can someone help me or am i a hopeless case? (4 Replies)
Discussion started by: sadiecutie
4 Replies

2. UNIX for Dummies Questions & Answers

Importing a unix file dump into a PC capable database

My development team has been trying to figure out how to import a unix data dump into SQL Server or convert it into an intermediate file format for several days. The data dump in question looks like this: $RecordID: 1<eof> $Version: 1<eof> Category: 1<eof> Poster: John Doe<eof>... (7 Replies)
Discussion started by: DaltonF
7 Replies

3. UNIX for Advanced & Expert Users

building flat files in unix and importing them from windows

what is a flat file in unix? i have to import a unix flat files from windows based programme. my question is not to export from unix but only to import from windows only. how to build that flat files? how to create export to windows how to import from windows (3 Replies)
Discussion started by: tunirayavarapu
3 Replies

4. Shell Programming and Scripting

awk? create similarity matrix by calculating overlaps between sets comprising of individual parts

Hi everyone I am very new at awk and to me the task I need to get done is very very challenging... Nevertheless, after admiring how fast and elegant issues are being solved here I am sure this is my best chance. I have a 2D data file (input file is a plain tab-delimited text file). The first... (1 Reply)
Discussion started by: stonemonkey
1 Replies

5. Shell Programming and Scripting

Help with merge data based on similarity

Input_file data1 USA 100 ASE data3 UK 20 GWQR data4 Brazil 40 QWE data2 Scotland 60 THWE data5 USA 40 QWERR Reference_file USA 12312 34532 1324 Brazil 23321 231 3421 Scotland 342 34235 UK 231 141 England... (1 Reply)
Discussion started by: patrick87
1 Replies

6. Shell Programming and Scripting

Help with sort list of file based on similarity

Input file (long list of input file): s_1_1_AABCD.txt s_1_1_ABADA.txt s_1_1_DSCBA.txt s_1_1_DSCCA.txt s_1_1_EATTG.txt s_1_1_FADSD.txt s_1_1_TGACC.txt s_1_1_TTAGG.txt s_1_2_AABCD.txt s_1_2_ABADA.txt s_1_2_DSCBA.txt s_1_2_DSCCA.txt s_1_2_EATTG.txt s_1_2_FADSD.txt ... (1 Reply)
Discussion started by: perl_beginner
1 Replies

7. UNIX for Advanced & Expert Users

Vector base Cosine Similarity for two Matrices -- R in UNIX

Dear All, I am facing a problem and I would be Thankful if you can help Hope this is the right place to ask this question I have two matrices of (row=10, col=3) and I want to get the cosine similarity between two lines (vectors) of each file --> the result should be (10,1) of cosine measures I... (10 Replies)
Discussion started by: A-V
10 Replies
Similarity(3)						User Contributed Perl Documentation					     Similarity(3)

NAME
String::Similarity - calculate the similarity of two strings SYNOPSIS
use String::Similarity; $similarity = similarity $string1, $string2; $similarity = similarity $string1, $string2, $limit; DESCRIPTION
$factor = similarity $string1, $string2, [$limit] The "similarity"-function calculates the similarity index of its two arguments. A value of 0 means that the strings are entirely different. A value of 1 means that the strings are identical. Everything else lies between 0 and 1 and describes the amount of similarity between the strings. It roughly works by looking at the smallest number of edits to change one string into the other. You can add an optional argument $limit (default 0) that gives the minimum similarity the two strings must satisfy. "similarity" stops analyzing the string as soon as the result drops below the given limit, in which case the result will be invalid but lower than the given $limit. You can use this to speed up the common case of searching for the most similar string from a set by specifing the maximum similarity found so far. SEE ALSO
The basic algorithm is described in: "An O(ND) Difference Algorithm and its Variations", Eugene Myers, Algorithmica Vol. 1 No. 2, 1986, pp. 251-266; see especially section 4.2, which describes the variation used below. The basic algorithm was independently discovered as described in: "Algorithms for Approximate String Matching", E. Ukkonen, Information and Control Vol. 64, 1985, pp. 100-118. AUTHOR
Marc Lehmann <schmorp@schmorp.de> http://home.schmorp.de/ (the underlying fstrcmp function was taken from gnu diffutils and modified by Peter Miller <pmiller@agso.gov.au> and Marc Lehmann <schmorp@schmorp.de>). perl v5.16.3 2008-11-04 Similarity(3)
All times are GMT -4. The time now is 01:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy