Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sample app forecasting with keras reload problem #121

Open
Marka10 opened this issue Jan 27, 2021 · 0 comments
Open

Sample app forecasting with keras reload problem #121

Marka10 opened this issue Jan 27, 2021 · 0 comments
Labels
usage exception Exception during a SSE function call from Qlik

Comments

@Marka10
Copy link

Marka10 commented Jan 27, 2021

Function
PyTools.sklearn_Calculate_Metrics_Sequence

Describe the bug
Connector reply error: grpc::StatusCode::UNKNOWN: 'Exception iterating responses: 'str' object has no attribute 'decode''

Full error message from Python
2021-01-27 08:36:26,273 - INFO - ExecuteFunction (functionId: 42, _sklearn)
2021-01-27 08:36:26,337 - ERROR - Exception iterating responses: 'str' object has no attribute 'decode'
Traceback (most recent call last):
File "C:\Qlik\qlik-py-tools-8.0\qlik-py-env\lib\site-packages\grpc_server.py", line 453, in _take_response_from_response_iterator
return next(response_iterator), True
File "main.py", line 550, in _sklearn
response = model.calculate_metrics(ordered_data=True)
File "C:\Qlik\qlik-py-tools-8.0\qlik-py-env\core_sklearn.py", line 895, in calculate_metrics
self.X_test, self.y_test = self._get_model_and_data(target=True, ordered_data=ordered_data)
File "C:\Qlik\qlik-py-tools-8.0\qlik-py-env\core_sklearn.py", line 1927, in _get_model_and_data
self._get_model()
File "C:\Qlik\qlik-py-tools-8.0\qlik-py-env\core_sklearn.py", line 2459, in _get_model
self.model = self.model.load(self.model.name, self.path)
File "C:\Qlik\qlik-py-tools-8.0\qlik-py-env\core_machine_learning.py", line 132, in load
keras_model = keras.models.load_model(path + name + '.h5')
File "C:\Qlik\qlik-py-tools-8.0\qlik-py-env\lib\site-packages\keras\engine\saving.py", line 458, in load_wrapper
return load_function(*args, **kwargs)
File "C:\Qlik\qlik-py-tools-8.0\qlik-py-env\lib\site-packages\keras\engine\saving.py", line 550, in load_model
model = _deserialize_model(h5dict, custom_objects, compile)
File "C:\Qlik\qlik-py-tools-8.0\qlik-py-env\lib\site-packages\keras\engine\saving.py", line 242, in _deserialize_model
model_config = json.loads(model_config.decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'

Error message in Qlik
image

Expression or load script used in Qlik
Its the unaltered app "Sample-app-forecasting-with-keras"
...
For Each vModel in FieldValueList('Model Name')

If '$(vModel)' <> 'Bikes-CausalConv-7d-v1' Then

    // Other than the multi-step model we get evaluation metrics and predictions one month at a time.
    // Since past values are inputs to these models, predicting over long periods will add up the errors from previous predictions.
    // In practice, we can continue to provide actual values to the model
    // So we are going to get predictions one month at a time, supplying actual values for previous periods
    For Each vMonth in 7, 8, 9, 10, 11, 12

        // Prepare samples table with the current model name and unique keys
        [TEMP_SAMPLES_WITH_KEYS]:
        LOAD
           '$(vModel)' as Model_Name,
           Key,
           N_Features // Including Target for historical data. Target may be Null or zero for the periods to be predicted
        RESIDENT [TEMP_TEST]
        WHERE [Key] >= (MonthStart(MakeDate(2012, $(vMonth), 1))-31) and [Key] <= MonthEnd(MakeDate(2012, $(vMonth), 1)); 

        // Use the LOAD...EXTENSION syntax to call the Get_Metrics function
        [Result-Metrics]:
        LOAD *,
            MonthName(MakeDate(2012, $(vMonth), 1)) as MonthName
        EXTENSION PyTools.sklearn_Calculate_Metrics_Sequence(TEMP_SAMPLES_WITH_KEYS{Model_Name, Key, N_Features});

Environment:

  • Windows Server
  • Qlik Sense Enterprise november 2020
  • SSE Version PY-tools 8.0

Additional context
In searching the web in general for solutions it seems that h5py needs to be <2.5 and some have had success using a different solver than lbfgs.

@Marka10 Marka10 added the usage exception Exception during a SSE function call from Qlik label Jan 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
usage exception Exception during a SSE function call from Qlik
Projects
None yet
Development

No branches or pull requests

1 participant