Clustering sequences of data with different lengths using ngrams.

2 vues (au cours des 30 derniers jours)
SOPAE YI
SOPAE YI le 16 Mar 2020
Modifié(e) : SOPAE YI le 21 Mar 2020
I am trying to cluster sequences of data that have different lengths.
I am treating the element of my sequence as a word. In other words, a list is a sentence.
To be able to achive this I am thinking of extracting ngrams like my code below.
However, I keep getting following error message:
“Arguments to IMPORT must either end with ".*" or else specify a fully qualified class name: "nltk" fails this test.”
1. How can I solve this error?
2. Am I going toward right direction?
I am a novice Matlab user and I hope I am not asking too basic questions.
Following is my Matlab code:
-------------------------------------------------------
A = [1.2,1.5; 2.4,0.5; 3.2,1.5];
B = [1.0,1.0; 2.0,0; 3.0,1.0; 4.0,0.5];
C = [1.1,1.2; 2.2,1.3; 3.3,1.5];
D = [1.3,1.3; 2.1,1.4; 3.2,1.7; 4.3, 2.0];
E = [1.3,1.8; 2.3,0.4; 3.1,1.6; 4.3,0.8];
figure()
plot(A(:,1), A(:,2)) % first column is the time-values
hold on;
plot(B(:,1), B(:,2))
hold on;
plot(E(:,1), E(:,2))
figure()
plot(C(:,1), C(:,2)) % first column is the time-values
hold on;
plot(D(:,1), D(:,2))
import nltk
from nltk import ngrams
aa = A(:)'
bb = B(:)'
cc = C(:)'
dd = D(:)'
ee = E(:)'
bb = list()
bb append(str(','.join(str(e) for e in ['x' + str(e) for e in aa])))
bb append(str(','.join(str(e) for e in ['x' + str(e) for e in bb])))
bb append(str(','.join(str(e) for e in ['x' + str(e) for e in cc])))
bb append(str(','.join(str(e) for e in ['x' + str(e) for e in dd])))
bb append(str(','.join(str(e) for e in ['x' + str(e) for e in ee])))
from sklearn.feature_extraction.text import CountVectorizer
vectorizer = CountVectorizer()
X = vectorizer.fit_transform(bb)
X.toarray()

Réponses (1)

Prabhanjan Mentla
Prabhanjan Mentla le 20 Mar 2020
NLTK is not supported in MATLAB however one can run python functions in MATLAB by following this. There is also text analytics toolbox in MATLAB which deals text data.
  1 commentaire
SOPAE YI
SOPAE YI le 20 Mar 2020
Modifié(e) : SOPAE YI le 21 Mar 2020
Thank you so much for crrecting me, sir.
My data is not text.
I am working on spoken sentence (or an utterance) especialy, pitch of a sentence.
Can I use NLTK to cluster sequences of (pitch) data that have different lengths?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Statistics and Machine Learning Toolbox dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by