2017-07-20 3 views
0

私はelki 0.7を使ってツイート(テキスト、日付、著者など)をクラスタリングしています。elkiの文字列のカストム距離関数を定義する方法は?

最初のステップでは、つぶやきのテキストをクラスタ化したいと思います。

私は単純な距離関数を書いており、将来私はそれをカスタマイズしたいと思います。

public class Distance extends AbstractPrimitiveDistanceFunction<String> { 
@Override 
    public double distance(String str1, String str2) { 
     int row1 = rowNumber.get(str1), 
       row2 = rowNumber.get(str2); 
     return 1 - similarity[row1][row2]; 
} 
@Override 
    public SimpleTypeInformation<? super String> getInputTypeRestriction() { 
     return VectorFieldTypeInformation.typeRequest(String.class, 2, 2); 
    } 

} 

類似度は、ツイートの正規化類似度(tf-idfを使用)を計算した配列です。 クラスタリングを実行したいが、SimpleTypeInformation関数にエラーがある。

The type of <V>typeRequest(Class<? super V>,int,int) is erroneous 
    where V is a type-variable: 
    V extends FeatureVector<?> declared in method <V>typeRequest(Class<? super V>,int,int) 

incompatible types: inferred type does not conform to upper bound(s) 
inferred: String 
    upper bound(s): String,FeatureVector<?> 

アイデアはありますか?

+1

ベクトルフィールド*はありませんが、単一の文字列ですか? –

+1

https://github.com/elki-project/elki/blob/master/elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/distancefunction/strings/LevenshteinDistanceFunctionを参照してください。文字列距離関数のjava。 –

答えて

2

https://elki-project.github.io/dev/typeinformation

タイプ情報は、自動型のマッチングのために必要です。

VectorFieldTypeInformationのみのためのベクトル場を使用しています。今、Stringは2次元のベクトルフィールドであり、コンパイルエラーが発生していると主張しています。

データは文字列であり、文字列のベクトルフィールドではありません。単純なオブジェクトのTypeInformationの適切なサブクラスを選択する必要があります。SimpleTypeInformation<String>はあなたが望むものです。

コードでは、事前計算された距離行列が使用されます。 ELKIには、このユースケースに対して最適化されたクラスがあります。

+0

事前計算距離行列のELKIにはどのクラスがありますか? – NASRIN

+1

初心者のためのハウツーを参照してください:https://elki-project.github.io/howto/precomputed_distances –

+0

ええ、私はそれを読んでいますが、私はそれをJavaやElkiMiniGUIで使うことはできません。どんな例がありますか? – NASRIN

関連する問題