my drupal site hosted by altervista
martedì 3 agosto 2010
venerdì 26 marzo 2010
Similarity Matrix in Text Mining
What is a similarity matrix ( in text mining ) and why is important?
CORPUS
We have to start from a corpus composed by k documents:
SIMILARITY MATRIX
A way to find semantic structures in the corpus is to study the occurrence and the
co-occurrence for every pair of words in the corpus.
A good tool to find something interesting is a similarity matrix.
DEFINITION
To define a similarity matrix we must define the similarity between two objects ( words )
the objects of index i and j for the generic position {i,j}
a good similarity matrix can follow from this definition: $$ s(w_i,w_j) = \dfrac {c(w_i,w_j) } { f(w_i) \cdot f(w_j) }$$ where: $$ c(w_i,w_j) $$ is the co-occurrence between two words ( the number of documents containing both
words )
MATRIX REPRESENTATIONS
- GRAPH
The created matrix is symmetric and could be visualized using a undirected weighted graph.
The nodes represents the words and the similarity between the two words is given by the
weight between two nodes.
this visualization is nearly useless (easily more than 10000 nodes!!!) .
- METRIC SPACE
A way to handle this info is to position k points in an n-dimensional space so that the mutual
distance between a couple of elements previously defined could reflect the weight between
the related pair of words.$$w_i \mapsto p_i | s(w_i,w_j) = \dfrac{1}{||p_i - p_j||} \forall i,j \leq k$$
( higher weight - closer distance )
a problem related with this approach is that is not always operable (matrix could not be
compatible with metrics constraints ) and the requested dimension of the target space
is a $$O(k^2).$$
so we need to use a technique to reduce the dimension preserving the significant information
( reducing the dimension brings a certain loss of information).
SEMANTIC STRUCTURES
Using the representation in an n-dimensional space is important to analyze clusters of points.
A cluster could be defined as a subset of points whose mutual distances are much smaller
than the average distance of the complete set.
A cluster is a reflection of some kind of statistical structure of the corpus.
Structures able to create a cluster can either be:
- language related rules ( eg: syntactic structures ) or
- semantic meanings ( eg: topics )
Pubblicato da
koteth
0
commenti
Etichette: data mining, math, text mining
martedì 29 dicembre 2009
Verlet integration in Haskell
Pubblicato da
koteth
2
commenti
giovedì 24 dicembre 2009
my delicious
Pubblicato da
koteth
1 commenti
martedì 8 dicembre 2009
Cairo-Chaos Haskell

Haskell chaos and lib-cairo.
Is only a fixed-point iteration over this function:
lgs x r = r * x * exp(- x )
Pubblicato da
koteth
0
commenti
Dollar $ operator in Haskell
Do you know what is $ operator in Haskell?
$ means simply , 'apply the left function at the right value'.
f $ x := f x
it seems really trivial, isn't it ?
But, for example in this kind of situation, is really usefull:
zipWith ( $ ) ( cycle [ \x -> div (x + 1) 2 , \x -> div x 2 ] ) [1..]
here you have a infinite list of function:
a = cycle [ \x -> div (x + 1) 2 , \x -> div x 2 ]
( ie: [\x -> div (x + 1) 2 , \x -> div x 2 , \x -> div (x + 1) 2 , \x -> div x 2, ... ] )
and you want to apply every element of the list at the element
at the same index in the second list:
b = [1..]
zipWith, for every index i takes the element a(i) of the left list
and b(i) of the right list and execute what is requested inside the parentheses.
In this situation is specified $ so:
a(i) $ b(i ) := a(i) ( b(i) )
the result must be the following:
[ 1 ,1 , 2, 2 , 3 ,3 ... and so on.
Pubblicato da
koteth
0
commenti
Prime Numbers in haskell
well, do you want to know how to find 'prime numbers' in a quick and dirty
way using Haskell ?
try this!
import Data.List
nubBy ( \x y -> mod y x == 0 ) [2..]
Haskell is so easy and charming...
( ps: if you want to speed up a little bit:
nubBy ( \x y -> ( x*x-1 <= y ) && ( mod y x == 0 ) ) [2..]
)
Pubblicato da
koteth
1 commenti
giovedì 20 agosto 2009
re: Mandelbrot Set in Haskell

Pubblicato da
koteth
0
commenti
Mandelbrot set in Haskell
gr = map(\y-> [( x:+y )|x<-[-3,-2.95..1]])[-2,-1.9..2]
main = mapM_ putStrLn ( (map(\el->show el) )image )

A first interpretation ( a little bit unsatisfactory ) of the Mandelbrot set in Haskell
Pubblicato da
koteth
0
commenti
martedì 18 agosto 2009
Numbers in Haskell
The core of numbers post in Haskell:
numList p x = map ( idens p x ) ( map ( x * ) [ 1..( p-1 ) ] )
matIde p = map ( numList p ) [ 1..(p-1) ]
Pubblicato da
koteth
0
commenti
domenica 16 agosto 2009
The Path of St. Augustine
Pubblicato da
koteth
0
commenti
Etichette: Il Cammino di Sant'Agostino, Italy, lombardia, The Path of St. Augustine
Dungeon ( Quinta da Regaleira - Portugal )
Quinta da Regaleira
( Mystic Cristina )
Pubblicato da
koteth
0
commenti
Etichette: image
domenica 19 luglio 2009
Mandelbrot in Rebol

And this is my interpretation of Mandelbrot fractal using Rebol:
Pubblicato da
koteth
0
commenti
domenica 12 luglio 2009
Latent Semantic Indexing ( LSI )
Pubblicato da
koteth
0
commenti
Etichette: data mining, text mining
sabato 11 luglio 2009
Peano in Js
Pubblicato da
koteth
0
commenti
Etichette: image, javascript, jquery
lunedì 6 luglio 2009
context-free art
A little piece of context-free art:
circles.cfdg
startshape trails background {b -1} rule trail { trail{ sat 0.001 a -0.001 r 0.4 y 0.5 s 0.999y 0.5 } SQUARE{s 1} } rule trail 0.001 { trail{flip 90} ring{x 5} } rule trails { 140*{r 120}trail{b 1 sat 0 h 100} } rule ring { 120*{r 5}SQUARE{s 4 0.5 y 6 h 100} }
Pubblicato da
koteth
0
commenti
Etichette: context-free, image
Rebol Search File
Another little Rebol program:
REBOL [Title: "Ricerca"]
mainWin: layout [
banner green "Ricerca Parola" box brick 580x2
text "Parola da cercare"
infi1: field infi2: field ""
text "nome file"
selFile: text-list data read %. [
infi2/data: value
infi2/text: value
show infi2
]
button "Ricerca" [
fil1: to-file infi2/data
text: read fil1
outOne: copy ""
while [ text: find text infi1/data ] [
formattedStuff: reduce [ " ( " index? text " ) " copy/part text 10 ]
append outOne "^/ ( indice ) riga: "
append outOne form formattedStuff
text: next text
]
tuno/text: form outOne show tuno
]
at 260x70
tuno: area 340x300 across
text "Risultato"
]
windowHelp: layout [
backcolor linen
h2 "Help Window"
text 300 { Inserisci la parola da ricercare e il nome del file...
}
button "Chiudimi" [ unview/only windowHelp ]
]
windowHelp/offset: mainWin/offset + (mainWin/size * 1x0) + 10x0
view/new mainWin
view/new windowHelp
do-events
Pubblicato da
koteth
2
commenti
'Text Categorization with SVM
A really nice pdf about 'Text Categorization with Support Vector Machines' ( from University of Dortmund ) :
http://www.cs.cornell.edu/People/tj/publications/joachims_97b.pdf
I'll try to post soon some code in Python about this problem...
Pubblicato da
koteth
0
commenti
Etichette: data mining, pdf, text mining
My first time in Rebol and numbers

Rebol is a fantastic language!
You can try this code in the Rebol/view Console:
numbers.r
REBOL [Title: "Numbers Test"]
ena: 121
positions: []
dimPal: 3
unitar: func [ ele enne ][ either (( (ele // enne) == 1 ) or (( ele // enne) == (enne - 1)))[ 1 ] ["-"] ]
evaluateUni: func [ en ] [
for j 1 en 1[ st: copy ""
for i 1 en 1[
append st unitar i * j en
sr: square-root en
if ( unitar i * j en ) == 1 [ append positions ( as-pair i j ) * 350 / en + 23x23 ]
]
]
positions
]
evaluateUni ena
refre: does[
positions: copy []
evaluateUni ena
pis: copy []
posi: copy positions
foreach p posi[ insert tail pis reduce[ 'fill-pen 160.209.215.100 'circle p dimPal ] ]
out: form ( length? positions ) / 2 == ( ena - 1 )
insert tail pis reduce [ 'text 230x5 join "numero primo: " out ]
scrn/effect/draw: copy []
append scrn/effect/draw pis
show scrn
]
refreNoEval: does[
pis: copy []
posi: copy positions
foreach p posi[ insert tail pis reduce[ 'fill-pen 160.209.215.100 'circle p dimPal ] ]
out: form ( length? positions ) / 2 == ( ena - 1 )
insert tail pis reduce [ 'text 230x5 join "numero primo: " out ]
scrn/effect/draw: copy []
append scrn/effect/draw pis
show scrn
]
lay: layout [
scrn: box 400x400 black effect [
draw [ text "unit" ]
rotate 50
gradmul 180.180.210 180.60.255
]
slider 200x16 ena / 300 [
ena: to-integer value * 300
inpNum/data: form ena
inpNum/text: form ena
show inpNum
refre
]
inpNum: field form ena [
print to-integer inpNum/text
ena: to-integer inpNum/text
]
at 330x460
btn "Change" [
refre
]
slider 100x15 dimPal / 10 [
dimPal: to-integer value * 10
refreNoEval
]
]
view lay
Pubblicato da
koteth
2
commenti

startshape trails
background {b -1}
rule trail {
trail{
sat 0.001
a -0.001
r 0.4
y 0.5
s 0.999y 0.5
}
SQUARE{s 1}
}
rule trail 0.001 {
trail{flip 90} ring{x 5}
}
rule trails {
140*{r 120}trail{b 1 sat 0 h 100}
}
rule ring {
120*{r 5}SQUARE{s 4 0.5 y 6 h 100}
}
