我正在使用H2O 3.20.0.10开发Spring Boot应用程序,并且需要框架中所有列的摘要/元数据。调用H2oApi的frameSummary()时,出现MalformedJsonException:
Caused by: com.google.gson.stream.MalformedJsonException: JSON forbids NaN and infinities: NaN at line 1 column 23937 path $.frames[0].columns[6].mean
at com.google.gson.stream.JsonReader.nextDouble(JsonReader.java:912)
at com.google.gson.Gson$1.read(Gson.java:319)
at com.google.gson.Gson$1.read(Gson.java:313)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:37)
at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:25)
at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:116)
at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:211)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:174)
at water.bindings.H2oApi.frameSummary(H2oApi.java:3718)
位置23937的列是枚举类型,因此没有平均值。
更新MWE:
new H2oApi("http://localhost:54321").frameSummary(key);
H2O的响应类似于:
__meta
schema_version 3
schema_name "FramesV3"
schema_type "Frames"
_exclude_fields ""
row_offset 0
row_count -1
column_offset 0
full_column_count -1
column_count -1
job null
frames
0
__meta
schema_version 3
schema_name "FrameV3"
schema_type "Frame"
_exclude_fields ""
frame_id
__meta
schema_version 3
schema_name "FrameKeyV3"
schema_type "Key<Frame>"
name "TrainR"
type "Key<Frame>"
URL "/3/Frames/TrainR"
byte_size 48018
is_text false
row_offset 0
row_count 100
column_offset 0
column_count 10
full_column_count 10
total_column_count 10
checksum 5296931134826174000
rows 1233
num_columns 10
default_percentiles […]
columns
0 {…}
1 {…}
2 {…}
3 {…}
4 {…}
5 {…}
6
__meta
schema_version 3
schema_name "ColV3"
schema_type "Vec"
label "weekday"
missing_count 0
zero_count 176
positive_infinity_count 0
negative_infinity_count 0
mins […]
maxs […]
mean "NaN"
sigma "NaN"
type "enum"
domain […]
domain_cardinality 7
data […]
string_data null
precision -1
histogram_bins […]
histogram_base 0
histogram_stride 1
percentiles […]
7 {…}
8 {…}
9 {…}
compatible_models null
有没有解决方法?
答案 0 :(得分:0)
我能够解决此问题。 Gson通常不喜欢原始值(或对象也是如此)的无穷“ NaN”
解决方法是在配置Gson时放宽。
我还创建了一个拉取请求:https://github.com/h2oai/h2o-3/pull/2962