ageron / ageron/handson-ml2

Chapter 13 : TypeError in cell #102

Abierto
#348 5 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Jupyter Notebook
Estrellas
30k
Forks
13.1k
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

Hi,

Executing the cell 102 of the chapter 13 handbook raises TypeError Exception (see traceback below). The workaround i used is to change `value=[x]` to `value=[*x]` (and the same for `y`) as the values returned are arrays (`[15.]`) and not simple values.
We could also be using directly the `filepath_dataset` created earlier and parse it "the good way", reshaping `X_train`, or else.. ?

> ```
> ---------------------------------------------------------------------------
> TypeError Traceback (most recent call last)
> in
> 2 for x, y in zip(X_train[:, 1:2], y_train):
> 3 example = Example(features=Features(feature={
> ----> 4 "housing_median_age": Feature(float_list=FloatList(value=[x])),
> 5 "median_house_value": Feature(float_list=FloatList(value=[y]))
> 6 }))
>
> ~\anaconda3\lib\site-packages\google\protobuf\internal\python_message.py in init(self, **kwargs)
> 551 field_value = [_GetIntegerEnumValue(field.enum_type, val)
> 552 for val in field_value]
> --> 553 copy.extend(field_value)
> 554 self._fields[field] = copy
> 555 elif field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
>
> ~\anaconda3\lib\site-packages\google\protobuf\internal\containers.py in extend(self, elem_seq)
> 280 raise
> 281
> --> 282 new_values = [self._type_checker.CheckValue(elem) for elem in elem_seq_iter]
> 283 if new_values:
> 284 self._values.extend(new_values)
>
> ~\anaconda3\lib\site-packages\google\protobuf\internal\containers.py in (.0)
> 280 raise
> 281
> --> 282 new_values = [self._type_checker.CheckValue(elem) for elem in elem_seq_iter]
> 283 if new_values:
> 284 self._values.extend(new_values)
>
> ~\anaconda3\lib\site-packages\google\protobuf\internal\type_checkers.py in CheckValue(self, proposed_value)
> 283 message = ('%.1024r has type %s, but expected one of: numbers.Real' %
> 284 (proposed_value, type(proposed_value)))
> --> 285 raise TypeError(message)
> 286 converted_value = float(proposed_value)
> 287 # This inf rounding matches the C++ proto SafeDoubleToFloat logic.
>
> TypeError: array([15.]) has type , but expected one of: numbers.Real
>
> ```

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.