IBM / icp4d-customer-churn-classifier

Infuse AI into your application. Create and deploy a customer churn prediction model with IBM Cloud Private for Data, Db2 Warehouse, Spark MLlib, and Jupyter notebooks.
https://developer.ibm.com/patterns/infuse-ai-into-your-application/
Apache License 2.0
17 stars 22 forks source link

Cannot visualize the customer demographics and trading activity data with Db2 datasource #33

Open farnaudies opened 3 years ago

farnaudies commented 3 years ago

#############

Db2 Connection and Dataset data_df_1 then df_churn_pd = data_df_1

##############

use "Insert to code" and "pandas DataFrame"

to import the input data into the notebook.

Add asset from file system# @hidden_cell

from project_lib import Project project = Project.access()

Db2Wh_5nodes_metadata = project.get_connection(name="Db2Wh-5nodes")

import os, jaydebeapi, pandas as pd

Db2Wh_5nodes_url = 'jdbc:db2://{}:{}/{}'.format( Db2Wh_5nodes_metadata['host'], Db2Wh_5nodes_metadata.get('port', 50000), Db2Wh_5nodes_metadata['database'] )

Db2Wh_5nodes_connection = jaydebeapi.connect( 'com.ibm.db2.jcc.DB2Driver', Db2Wh_5nodes_url, [Db2Wh_5nodes_metadata['xxxxx'],Db2Wh_5nodes_metadata['yyyyy']] )

query = 'SELECT * FROM "CHURN"."MERGED_CUSTOMERS"' data_df_1 = pd.read_sql_query(query, con=Db2Wh_5nodes_connection) data_df_1.head()

########################## Error Step 3


TypeError Traceback (most recent call last)

in ----> 1 get_ipython().run_line_magic('brunel', "data('df_churn_pd') stack polar bar x(CHURNRISK) y(#count) color(CHURNRISK) bar tooltip(#all) :: width=300, height=300") /opt/conda/envs/Python-3.7-main/lib/python3.7/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth) 2315 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals 2316 with self.builtin_trap: -> 2317 result = fn(*args, **kwargs) 2318 return result 2319 in brunel(self, line, cell) /opt/conda/envs/Python-3.7-main/lib/python3.7/site-packages/IPython/core/magic.py in (f, *a, **k) 185 # but it's overkill for just that one bit of state. 186 def magic_deco(arg): --> 187 call = lambda f, *a, **k: f(*a, **k) 188 189 if callable(arg): ~/.local/lib/python3.7/site-packages/brunel/magics.py in brunel(self, line, cell) 43 parts = line.split('::') 44 action = parts[0].strip() ---> 45 datasets_in_brunel = brunel.get_dataset_names(action) 46 self.cache_data(datasets_in_brunel,datas) 47 if len(parts) > 2: ~/.local/lib/python3.7/site-packages/brunel/brunel.py in get_dataset_names(brunel_src) 92 93 def get_dataset_names(brunel_src): ---> 94 return brunel_util_java.D3Integration.getDatasetNames(brunel_src) 95 96 def cacheData(data_key, data): ~/.local/lib/python3.7/site-packages/jpype/_jpackage.py in __call__(self, *arg, **kwarg) 54 55 def __call__(self, *arg, **kwarg): ---> 56 raise TypeError("Package {0} is not Callable".format(self.__name)) TypeError: Package org.brunel.util.D3Integration.getDatasetNames is not Callable
Thrameos commented 3 years ago

What version of JPype is being used? This error looks like what happens when a dependency is missing (so it can't find the jar) with version 0.7.x or earlier and a JPackage automatically assumed that getDatasetNames is a package as a result.

For the user, make sure that you have all the required jars.

For the developer, consider upgrading to JPype 1.2.x series and using the import system rather than JPackage. It would have detected the missing dependency and then reported a more specific error.

farnaudies commented 3 years ago

I made this updates :

NOTE: if you do have to perform one or more of these installs, you MUST

restart the kernel

!pip install --user pyspark==2.3.2

!pip install --user py4j==0.10.7

!pip install --user ibm-watson-machine-learning==1.0.44

!pip install --user brunel==2.6.2

!pip install --user JPype1==1.2.1

!pip install --user PyPI==2.1

I restarted the kernel and now I have no error but output is empty, why?

Le lun. 25 janv. 2021 à 19:10, Karl Nelson notifications@github.com a écrit :

What version of JPype is being used? This error looks like what happens when a dependency is missing (so it can't find the jar) with version 0.7.x or earlier and a JPackage automatically assumed that getDatasetNames is a package as a result.

For the user, make sure that you have all the required jars.

For the developer, consider upgrading to JPype 1.2.x series and using the import system rather than JPackage. It would have detected the missing dependency and then reported a more specific error.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/IBM/icp4d-customer-churn-classifier/issues/33#issuecomment-767009770, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFPWKAGHXR6HQLLHFRGVLC3S3WX2RANCNFSM4WSCZM2Q .

Thrameos commented 3 years ago

Sorry cant help beyond fixing the source if the error message.