Random Forest Classifier not JSON serializable in CP3.1.8 FilterObjects

Hi,

Have been running into an error recently. I have been using the filter objects module to automate the RandomForest classification which has been trained in CPA. It was fine until I included a second channel in the analysis. Now I receive the following error after the ExportToDatabase module:

Worker 0: Cancelling worker
Worker 0: Error in handling of pipeline exception
Worker 0: Traceback (most recent call last):
Worker 0: File “c:\temp\cellprofiler\cellprofiler\worker.py”, line 443, in do_job
Worker 0: image_set_number=image_set_number) == ED_STOP:
Worker 0: File “c:\temp\cellprofiler\cellprofiler\worker.py”, line 653, in handle_exception
Worker 0: reply = self.send(req, report_socket)
Worker 0: File “c:\temp\cellprofiler\cellprofiler\worker.py”, line 559, in send
Worker 0: “response from %s” % str(req))
Worker 0: File “c:\temp\cellprofiler\cellprofiler\worker.py”, line 586, in raise_cancel
Worker 0: raise CancelledException(msg)
Worker 0: CancelledException: Received stop notification while waiting for response from (Worker) TypeError: RandomForestClassifier(bootstrap=True, class_weight=None, criterion=‘gini’,
Worker 0: max_depth=None, max_features=‘auto’, max_leaf_nodes=None,
Worker 0: min_impurity_decrease=0.0, min_impurity_split=None,
Worker 0: min_samples_leaf=1, min_samples_split=2,
Worker 0: min_weight_fraction_leaf=0.0, n_estimators=100, n_jobs=None,
Worker 0: oob_score=False, random_state=None, verbose=0,
Worker 0: warm_start=False) of type <class ‘sklearn.ensemble.forest.RandomForestClassifier’> is not JSON serializable

I’m using CP and CPA built from source on Windows 10 64-bit with the correct version of Java Installed. Here’s a pip freeze:

altgraph==0.16.1
backports.functools-lru-cache==1.5
boto3==1.9.130
botocore==1.12.130
-e git+https://github.com/CellProfiler/CellProfiler.git@f3d77528cd39a4543f6c1dc99dd0fa77d81ad769#egg=CellProfiler
-e git+https://github.com/CellProfiler/CellProfiler-Analyst.git@7e194e72e8ce8440ce7c16196cb91c50052c2df1#egg=CellProfiler_Analyst
centrosome==1.1.6
certifi==2019.3.9
chardet==3.0.4
cloudpickle==0.8.1
contextlib2==0.5.5
cycler==0.10.0
dask==1.1.5
decorator==4.4.0
deprecation==2.0.6
dis3==0.1.3
docutils==0.14
future==0.17.1
futures==3.2.0
h5py==2.9.0
idna==2.8
inflect==2.1.0
javabridge==1.0.18
jmespath==0.9.4
joblib==0.13.2
kiwisolver==1.0.1
macholib==1.11
mahotas==1.4.5
matplotlib==2.2.4
my==1.3.0
MySQL-python==1.2.5
mysqlclient==1.4.2
networkx==2.2
numpy==1.15.4+mkl
packaging==19.0
pandas==0.24.2
pefile==2018.8.8
Pillow==6.0.0
prokaryote==2.4.1
PyInstaller==3.4
pyparsing==2.4.0
pypiwin32==223
python-bioformats==1.5.2
python-dateutil==2.8.0
pytz==2019.1
PyWavelets==1.0.3
pywin32==224
pywin32-ctypes==0.2.0
pyzmq==15.3.0
raven==6.10.0
requests==2.21.0
s3transfer==0.2.0
scikit-image==0.14.2
scikit-learn==0.20.3
scipy==1.2.1
seaborn==0.9.0
six==1.12.0
toolz==0.9.0
urllib3==1.24.1
verlib==0.1
wxPython==3.0.2.0
wxPython-common==3.0.2.0

My pipeline is here:
GeneralPipeline_PDXMSCv3.4_CyQAV_Filter_KS_1_RF2_AVPos_RF1.cpproj (674.9 KB)
Classifier model trained with CPA here (renamed to .txt file, just rename to .model and open):
1059_1060_ReExAllNuc_RF1_TS1 - Copy.txt (303.1 KB)

Anyone any ideas? Clearly it’s having trouble converting the classifer into JSON, yet it still gives output to the database which appears accurate. However it errors and stops the pipeline running. So if it can’t be fixed, could we atleast change the error to a warning, as it does actually seem to give me the results I need?

Cheers,

Ed