rh-aiservices-bu / fraud-detection Goto Github PK
View Code? Open in Web Editor NEWHome Page: https://rh-aiservices-bu.github.io/fraud-detection/
License: Apache License 2.0
Home Page: https://rh-aiservices-bu.github.io/fraud-detection/
License: Apache License 2.0
When following https://access.redhat.com/documentation/en-us/red_hat_openshift_ai_self-managed/2.9/html-single/openshift_ai_tutorial_-_fraud_detection_example/index on OpenShift AI 2.9.1, the 1_experiment_train.ipynb
will print in the last cell for the input
sally_transaction_details = [
[0.3111400080477545,
1.9459399775518593,
1.0,
0.0,
0.0]
]
output
Is Sally's transaction predicted to be fraudulent? (true = YES, false = NO)
False
How likely was Sally's transaction to be fraudulent?
0.00038%
If I add
print(prediction)
there I will see
[array([[0.00038084]], dtype=float32)]
When I then save the model to MinIO with 2_save_model.ipynb
, deploy it using a multi-model serving, and use 3_rest_requests_multi_model.ipynb
, for (what seems like) the same input
data = [0.3111400080477545, 1.9459399775518593, 1.0, 0.0, 0.0]
I get
[0.9950703]
and
fraud
It is quite unexpected that the model gives quite the opposite result when run locally and when served.
I follow the tutorial at https://access.redhat.com/documentation/en-us/red_hat_openshift_ai_self-managed/2.7/html-single/openshift_ai_tutorial_-_fraud_detection_example/index which uses this repo https://github.com/rh-aiservices-bu/fraud-detection.
The section https://access.redhat.com/documentation/en-us/red_hat_openshift_ai_self-managed/2.7/html-single/openshift_ai_tutorial_-_fraud_detection_example/index#running-a-pipeline-generated-from-python-code shows the use of pipeline/7_get_data_train_upload.py
to build pipeline/7_get_data_train_upload.yaml
. (Small issue with that section reported in https://issues.redhat.com/browse/RHOAIENG-4448.)
However, when I import the generated pipeline YAML file, the triggered run keeps on being shown as Running in the OpenShift AI dashboard. Specifically, the get-data task is shown as Pending.
There sadly seems to be no way to debug this from the OpenShift AI dashboard. However, in OpenShift Console in the TaskRuns view, there is a stream of events
0/2 nodes are available: pod has unbound immediate PersistentVolumeClaims. preemption: 0/2 nodes are available: 2 Preemption is not helpful for scheduling..
shown.
Checking the YAML of the imported pipeline back in the OpenShift AI dashboard shows
workspaces:
- name: train-upload-stock-kfp
volumeClaimTemplate:
spec:
storageClassName: gp3
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
Logging in as admin to OpenShift Console, I see that the fraud-detection PVC (as well as the one created for MinIO), are of the class gp3-csi, not gp3.
Should the pipeline/7_get_data_train_upload.py
try not to force the storage class?
Should the tutorial text be updated to document that DEFAULT_STORAGE_CLASS
environment variable that pipeline/7_get_data_train_upload.py
consumes? Checking https://rh-aiservices-bu.github.io/fraud-detection/fraud-detection-workshop/running-a-pipeline-generated-from-python-code.html it does not mention storage classes either.
When creating a workbench in OpenShift AI 2.5, the default and labelled Recommended version of the TensorFlow image is 2023.2.
However, with that image, running the first cell
!pip install onnx==1.12.0 \
onnxruntime==1.16.1 \
seaborn==0.13.0 \
tf2onnx==1.13.0
in 1_experiment_train.ipynb yields
Collecting onnx==1.12.0
Downloading onnx-1.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 13.1/13.1 MB 261.3 MB/s eta 0:00:00a 0:00:01
Collecting onnxruntime==1.16.1
Downloading onnxruntime-1.16.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.2 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.2/6.2 MB 226.6 MB/s eta 0:00:00
Collecting seaborn==0.13.0
Downloading seaborn-0.13.0-py3-none-any.whl (294 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 294.6/294.6 kB 483.0 MB/s eta 0:00:00
Collecting tf2onnx==1.13.0
Downloading tf2onnx-1.13.0-py3-none-any.whl (442 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 442.3/442.3 kB 458.3 MB/s eta 0:00:00
Requirement already satisfied: numpy>=1.16.6 in /opt/app-root/lib/python3.9/site-packages (from onnx==1.12.0) (1.24.3)
Requirement already satisfied: typing-extensions>=3.6.2.1 in /opt/app-root/lib/python3.9/site-packages (from onnx==1.12.0) (4.5.0)
Collecting protobuf<=3.20.1,>=3.12.2
Downloading protobuf-3.20.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.0/1.0 MB 502.8 MB/s eta 0:00:00
Collecting sympy
Downloading sympy-1.12-py3-none-any.whl (5.7 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.7/5.7 MB 196.8 MB/s eta 0:00:00
Collecting coloredlogs
Downloading coloredlogs-15.0.1-py2.py3-none-any.whl (46 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 46.0/46.0 kB 316.2 MB/s eta 0:00:00
Requirement already satisfied: packaging in /opt/app-root/lib/python3.9/site-packages (from onnxruntime==1.16.1) (23.2)
Requirement already satisfied: flatbuffers in /opt/app-root/lib/python3.9/site-packages (from onnxruntime==1.16.1) (23.5.26)
Requirement already satisfied: matplotlib!=3.6.1,>=3.3 in /opt/app-root/lib/python3.9/site-packages (from seaborn==0.13.0) (3.6.3)
Requirement already satisfied: pandas>=1.2 in /opt/app-root/lib/python3.9/site-packages (from seaborn==0.13.0) (1.5.3)
Collecting flatbuffers
Downloading flatbuffers-2.0.7-py2.py3-none-any.whl (26 kB)
Requirement already satisfied: six in /opt/app-root/lib/python3.9/site-packages (from tf2onnx==1.13.0) (1.16.0)
Requirement already satisfied: requests in /opt/app-root/lib/python3.9/site-packages (from tf2onnx==1.13.0) (2.31.0)
Requirement already satisfied: pyparsing>=2.2.1 in /opt/app-root/lib/python3.9/site-packages (from matplotlib!=3.6.1,>=3.3->seaborn==0.13.0) (3.1.1)
Requirement already satisfied: fonttools>=4.22.0 in /opt/app-root/lib/python3.9/site-packages (from matplotlib!=3.6.1,>=3.3->seaborn==0.13.0) (4.44.0)
Requirement already satisfied: cycler>=0.10 in /opt/app-root/lib/python3.9/site-packages (from matplotlib!=3.6.1,>=3.3->seaborn==0.13.0) (0.12.1)
Requirement already satisfied: contourpy>=1.0.1 in /opt/app-root/lib/python3.9/site-packages (from matplotlib!=3.6.1,>=3.3->seaborn==0.13.0) (1.2.0)
Requirement already satisfied: kiwisolver>=1.0.1 in /opt/app-root/lib/python3.9/site-packages (from matplotlib!=3.6.1,>=3.3->seaborn==0.13.0) (1.4.5)
Requirement already satisfied: pillow>=6.2.0 in /opt/app-root/lib/python3.9/site-packages (from matplotlib!=3.6.1,>=3.3->seaborn==0.13.0) (10.1.0)
Requirement already satisfied: python-dateutil>=2.7 in /opt/app-root/lib/python3.9/site-packages (from matplotlib!=3.6.1,>=3.3->seaborn==0.13.0) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in /opt/app-root/lib/python3.9/site-packages (from pandas>=1.2->seaborn==0.13.0) (2023.3.post1)
Collecting humanfriendly>=9.1
Downloading humanfriendly-10.0-py2.py3-none-any.whl (86 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 86.8/86.8 kB 381.0 MB/s eta 0:00:00
Requirement already satisfied: certifi>=2017.4.17 in /opt/app-root/lib/python3.9/site-packages (from requests->tf2onnx==1.13.0) (2023.7.22)
Requirement already satisfied: charset-normalizer<4,>=2 in /opt/app-root/lib/python3.9/site-packages (from requests->tf2onnx==1.13.0) (3.3.2)
Requirement already satisfied: urllib3<3,>=1.21.1 in /opt/app-root/lib/python3.9/site-packages (from requests->tf2onnx==1.13.0) (1.26.18)
Requirement already satisfied: idna<4,>=2.5 in /opt/app-root/lib/python3.9/site-packages (from requests->tf2onnx==1.13.0) (3.4)
Collecting mpmath>=0.19
Downloading mpmath-1.3.0-py3-none-any.whl (536 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 536.2/536.2 kB 396.5 MB/s eta 0:00:00
Installing collected packages: mpmath, flatbuffers, sympy, protobuf, humanfriendly, onnx, coloredlogs, tf2onnx, seaborn, onnxruntime
Attempting uninstall: flatbuffers
Found existing installation: flatbuffers 23.5.26
Uninstalling flatbuffers-23.5.26:
Successfully uninstalled flatbuffers-23.5.26
Attempting uninstall: protobuf
Found existing installation: protobuf 3.20.3
Uninstalling protobuf-3.20.3:
Successfully uninstalled protobuf-3.20.3
Attempting uninstall: onnx
Found existing installation: onnx 1.15.0
Uninstalling onnx-1.15.0:
Successfully uninstalled onnx-1.15.0
Attempting uninstall: tf2onnx
Found existing installation: tf2onnx 1.15.1
Uninstalling tf2onnx-1.15.1:
Successfully uninstalled tf2onnx-1.15.1
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tensorflow 2.13.1 requires flatbuffers>=23.1.21, but you have flatbuffers 2.0.7 which is incompatible.
tensorflow 2.13.1 requires protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.20.3, but you have protobuf 3.20.1 which is incompatible.
googleapis-common-protos 1.61.0 requires protobuf!=3.20.0,!=3.20.1,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0.dev0,>=3.19.5, but you have protobuf 3.20.1 which is incompatible.
google-api-core 2.14.0 requires protobuf!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0.dev0,>=3.19.5, but you have protobuf 3.20.1 which is incompatible.
Successfully installed coloredlogs-15.0.1 flatbuffers-2.0.7 humanfriendly-10.0 mpmath-1.3.0 onnx-1.12.0 onnxruntime-1.16.1 protobuf-3.20.1 seaborn-0.13.0 sympy-1.12 tf2onnx-1.13.0
[notice] A new release of pip available: 22.2.2 -> 23.3.2
[notice] To update, run: pip install --upgrade pip
The step 4 in https://access.redhat.com/documentation/en-us/red_hat_openshift_ai_self-managed/2-latest/html-single/fraud_detection_tutorial/index#creating-a-workbench says "Select the latest Tensorflow image." and shows a selection of 2023.1 (Recommended).
But that is not possible with latest OpenShift AI -- either the user can select 2023.1, or the latest (and Recommended).
In any case, the notebook should work with the latest product version (and latest images) without errors.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.