Skip to content

Commit 4cba012

Browse files
Merge pull request #11023 from IoannisPanagiotas/kmeans-relax-config-for-props
Kmeans relax config for 1d props
2 parents fd3f9c5 + 203e582 commit 4cba012

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

algo/src/test/java/org/neo4j/gds/kmeans/KmeansStreamConfigTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void shouldFailOnInvalidPropertyValueTypes(ValueType valueType) {
7272
assertThatIllegalArgumentException()
7373
.isThrownBy(() -> streamConfig.graphStoreValidation(graphStoreMock, List.of(), List.of()))
7474
.withMessageContaining("Unsupported node property value type")
75-
.withMessageContaining("Value type required: [DOUBLE_ARRAY] or [FLOAT_ARRAY].");
75+
.withMessageContaining("Value type required: [DOUBLE], [DOUBLE_ARRAY] or [FLOAT_ARRAY].");
7676
}
7777

7878
@ParameterizedTest
@@ -93,13 +93,14 @@ void shouldAcceptValidPropertyValueTypes(ValueType valueType) {
9393
static Stream<Arguments> validNodePropertyValueTypes() {
9494
return Stream.of(
9595
Arguments.of(ValueType.DOUBLE_ARRAY),
96-
Arguments.of(ValueType.FLOAT_ARRAY)
96+
Arguments.of(ValueType.FLOAT_ARRAY),
97+
Arguments.of(ValueType.DOUBLE)
9798
);
9899
}
99100

100101
static Stream<Arguments> invalidNodePropertyValueTypes() {
101102
return Arrays.stream(ValueType.values())
102-
.filter(t -> t != ValueType.DOUBLE_ARRAY && t != ValueType.FLOAT_ARRAY)
103+
.filter(t -> t != ValueType.DOUBLE_ARRAY && t != ValueType.FLOAT_ARRAY && t != ValueType.DOUBLE)
103104
.map(Arguments::of);
104105
}
105106

doc/modules/ROOT/pages/algorithms/kmeans.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ This sampling strategy tries to spread the initial clusters more evenly so as to
5353

5454

5555
It is also possible to explicitly give the list of initial centroids to the algorithm via the `seedCentroids` parameter. In this case, the value of the `initialSampler` parameter is ignored, even if changed in the configuration.
56+
Note that although the algorithm supports clustering single double numbers, when seeded through the `seedCentroids` parameter, the initial centroids must be passed as arrays e.g., [[1.5],[2.5]] for initializing with 1.5 and 2.5 respectively.
5657

5758
[[algorithm-k-means-considerations]]
5859
== Considerations

procedures/facade-api/configs/community-configs/src/main/java/org/neo4j/gds/kmeans/KmeansBaseConfig.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,14 @@ default void nodePropertyTypeValidation(
6969
Collection<RelationshipType> selectedRelationshipTypes
7070
) {
7171
var valueType = graphStore.nodeProperty(nodeProperty()).valueType();
72-
if (valueType == ValueType.DOUBLE_ARRAY || valueType == ValueType.FLOAT_ARRAY) {
72+
if (valueType == ValueType.DOUBLE_ARRAY || valueType == ValueType.FLOAT_ARRAY || valueType == ValueType.DOUBLE) {
7373
return;
7474
}
7575
throw new IllegalArgumentException(
7676
StringFormatting.formatWithLocale(
77-
"Unsupported node property value type [%s]. Value type required: [%s] or [%s].",
77+
"Unsupported node property value type [%s]. Value type required: [%s], [%s] or [%s].",
7878
valueType,
79+
ValueType.DOUBLE,
7980
ValueType.DOUBLE_ARRAY,
8081
ValueType.FLOAT_ARRAY
8182
)

0 commit comments

Comments
 (0)