ivy-llc / demos

Demos and Tutorials with Ivy
https://ivy.dev/docs/demos/
19 stars 61 forks source link

Addition of Jupyter Notebook for Credit Card Fraud Detection Using Ivy Framework #89

Closed muzakkirhussain011 closed 8 months ago

muzakkirhussain011 commented 8 months ago

Pull Request - Addition of Jupyter Notebook for Credit Card Fraud Detection Using Ivy Framework

Changes Proposed in this Pull Request:

Impact of Change:

How to Test:

Additional Notes:

Closes #90

muzakkirhussain011 commented 8 months ago

Hi @NripeshN ,

I have just pushed a commit that adds a Jupyter notebook for sarcasm detection using an LSTM model. This notebook also includes a demonstration of transpiling the TensorFlow model to PyTorch using Ivy, which significantly reduces training time while maintaining model performance.

I would greatly appreciate your review and feedback on this PR. Your insights will be invaluable to ensure the quality and effectiveness of the implementation.

Thank you for your time and consideration.

Best regards

muzakkirhussain011 commented 8 months ago

Hey @vedpatwardhan , Absolutely, I’ll revise the notebook to utilize Ivy for the model implementation. I appreciate the heads-up and the positive feedback on the PR. I’ll get the updated version to you soon.

muzakkirhussain011 commented 8 months ago

Hi @vedpatwardhan , Thank you for your review. I’ve attempted to implement the model using Ivy, but due to its current developmental stage, it lacks several methods and functions necessary for our model. This has led me to transpile the model from TensorFlow to PyTorch, which has shown better performance for our needs. I’m committed to updating the implementation as Ivy advances and includes the required features. For now, I believe the transpiled PyTorch model is the most viable solution. I appreciate your understanding and look forward to your feedback.

vedpatwardhan commented 8 months ago

Hi @vedpatwardhan , Thank you for your review. I’ve attempted to implement the model using Ivy, but due to its current developmental stage, it lacks several methods and functions necessary for our model. This has led me to transpile the model from TensorFlow to PyTorch, which has shown better performance for our needs. I’m committed to updating the implementation as Ivy advances and includes the required features. For now, I believe the transpiled PyTorch model is the most viable solution. I appreciate your understanding and look forward to your feedback.

Hey @muzakkirhussain011, actually we do have an LSTM layer in ivy and we also have the ivy.lstm function. Could you please try using those if they serve the purpose? If not, we can make necessary changes to them accordingly, but the goal here is to add the demo using ivy as a framework, so we shouldn't ideally be transpiling here 😅

muzakkirhussain011 commented 8 months ago

Hi @vedpatwardhan ,

I appreciate the suggestion to use the existing LSTM layer and ivy.lstm function. However, there are several features and functionalities currently not available in Ivy that are crucial for building a robust sarcasm detection model. For instance, we lack TensorDataset, DataLoader, and a zero_grad function for optimizers. Moreover, the optimizer doesn't accept model.parameters() as an argument, and the loss function class doesn't have a backward method for the backward pass.

Most importantly, for a task like sarcasm detection, we need a comprehensive architecture that includes not just an LSTM but also embedding layers with full parameter support, bidirectional LSTM, and dense layers (linear layers). Without these, it's challenging to create an effective model.

It would be beneficial for the framework to consider incorporating these key features. Their addition promises to advance Ivy's deep learning capabilities and support more complex model development.

vedpatwardhan commented 8 months ago

Hi @vedpatwardhan ,

I appreciate the suggestion to use the existing LSTM layer and ivy.lstm function. However, there are several features and functionalities currently not available in Ivy that are crucial for building a robust sarcasm detection model. For instance, we lack TensorDataset, DataLoader, and a zero_grad function for optimizers. Moreover, the optimizer doesn't accept model.parameters() as an argument, and the loss function class doesn't have a backward method for the backward pass.

Most importantly, for a task like sarcasm detection, we need a comprehensive architecture that includes not just an LSTM but also embedding layers with full parameter support, bidirectional LSTM, and dense layers (linear layers). Without these, it's challenging to create an effective model.

It would be beneficial for the framework to consider incorporating these key features. Their addition promises to advance Ivy's deep learning capabilities and support more complex model development.

Hey @muzakkirhussain011, actually the Dataset, DataLoader classes, etc. aren't present in the ivy repo (they are present on the builder repo), but that could actually be implemented functionally using ivy. As for the optimizer, given that ivy's design has been made closer to jax, the optimizer doesn't really operate in the stateful manner and you can just pass model.v to the optimizer when calling optimizer.step. For both the dataset and optimizer issues, you can refer the example under the "I'm using Ivy" dropdown of this section. Ofc feel free to make necessary changes to how you'd generate batches, etc. Happy to answer any further questions, thanks 😄

muzakkirhussain011 commented 8 months ago

Hi @vedpatwardhan ,

I would like to request your expertise in reviewing a recent commit that includes a Jupyter notebook for our credit card fraud detection project. This notebook is integral to our initiative, as it employs the Ivy framework throughout all stages—training, prediction, and evaluation. Your insights would be greatly appreciated to ensure the thoroughness and accuracy of our methodologies.

Thank you for your assistance. Best regards

muzakkirhussain011 commented 8 months ago

Hi @NripeshN ,

I have just pushed a commit that adds a Jupyter notebook for our credit card fraud detection project. This notebook is integral to our initiative, as it employs the Ivy framework throughout all stages—training, prediction, and evaluation. Your insights would be greatly appreciated to ensure the thoroughness and accuracy of our methodologies.

Thank you for your time and consideration.

Best regards

NripeshN commented 8 months ago

Hi @NripeshN ,

I have just pushed a commit that adds a Jupyter Notebook for our credit card fraud detection project. This notebook is integral to our initiative, as it employs the Ivy framework throughout all stages—training, prediction, and evaluation. Your insights would be greatly appreciated to ensure the thoroughness and accuracy of our methodologies.

Thank you for your time and consideration.

Best regards

Hey @muzakkirhussain011 Could you please create 2 different PRs for the 2 problem statement? Note: The Credit Card Fraud Detection would not be considered if someone else creates a PR soon as in the form you had selected Sarcasm Detection and credit card fraud detection is only available for our Rising Contributors.

muzakkirhussain011 commented 8 months ago

Hi @NripeshN ,

Thank you for your guidance. I understand the need for separate PRs for different problem statements. I have removed the sarcasm detection notebook due to persistent errors and plan to address it in a future PR. For now, I am focusing solely on the credit card fraud detection notebook. All stages of training, predicting, and evaluation are implemented within the Ivy framework. This PR will be exclusively for the credit card fraud detection notebook.

I appreciate the heads-up regarding the availability of the credit card fraud detection for Rising Contributors. I’ll ensure to submit my PR promptly to avoid any overlap with other contributors.

Best regards

muzakkirhussain011 commented 8 months ago

Hi @vedpatwardhan ,

I wanted to highlight that the current PR is dedicated exclusively to credit card fraud detection. The notebook on sarcasm detection has been removed due to persistent errors.

Looking forward to your review.

Best Regards

vedpatwardhan commented 8 months ago

@NripeshN could you please review the PR? Thanks @muzakkirhussain011 😄

NripeshN commented 8 months ago

Could you please tidy the notebook a little bit with Markdowns explaining what you are doing etc. You can use this notebook for reference. Thanks!

muzakkirhussain011 commented 8 months ago

Hi @NripeshN ,

Thank you for your feedback. I've updated the Jupyter notebook to enhance its clarity and tidiness. Now, it includes detailed markdown annotations explaining each step of the analysis and the corresponding code blocks. I've made sure to follow the structure and documentation style of the reference notebook you provided.

Please have a look and let me know if there are any further improvements you'd like to see.

Best regards

muzakkirhussain011 commented 8 months ago

Hi @NripeshN ,

I’m just checking in on the updates made to the Jupyter notebook. I’ve incorporated detailed markdown annotations and restructured the code blocks for enhanced clarity, as per your suggestions.

Could you please review the changes at your earliest convenience? If all is in order, I would appreciate if we could move forward with merging the PR.

Looking forward to your feedback.

Best regards

NripeshN commented 8 months ago

Hi @NripeshN ,

I’m just checking in on the updates made to the Jupyter notebook. I’ve incorporated detailed markdown annotations and restructured the code blocks for enhanced clarity, as per your suggestions.

Could you please review the changes at your earliest convenience? If all is in order, I would appreciate if we could move forward with merging the PR.

Looking forward to your feedback.

Best regards

I have asked for a few changes. Once done the PR looks good to be merged

muzakkirhussain011 commented 8 months ago

Hi @NripeshN ,

Thank you for your feedback on the PR. Could you please specify the changes you're referring to? This will help me address them accurately and ensure the PR is ready for merging.

Best regards

NripeshN commented 8 months ago

Hi @NripeshN ,

Thank you for your feedback on the PR. Could you please specify the changes you're referring to? This will help me address them accurately and ensure the PR is ready for merging.

Best regards

I left a review above. Just tagged you in it again.

muzakkirhussain011 commented 8 months ago

Hi @NripeshN ,

I couldn't find the review you mentioned. Could you please point me to it or resend? Also, a quicker response would help me act on it sooner.

Thanks

muzakkirhussain011 commented 8 months ago

Hey @muzakkirhussain011, actually the task requires using ivy as a framework to implement the model rather than transpiling a model in a different framework, could you please update the notebook accordingly? Thanks for creating the PR 😄

Hi @vedpatwardhan

I've updated the notebook to use Ivy exclusively for all stages—training, predicting, and testing—without any transpiling. Could you please review and approve the requested changes?

Thanks!

NripeshN commented 8 months ago

Hi @NripeshN ,

I couldn't find the review you mentioned. Could you please point me to it or resend? Also, a quicker response would help me act on it sooner.

Thanks

There are a few pending reviews above. Please address them. image

muzakkirhussain011 commented 8 months ago

Hi @NripeshN Thank you for the reminder. I have addressed the pending reviews for the deletion of contributor_demos/Sarcasm Detection/requirements.txt as suggested. If there are any further changes needed, please let me know.

NripeshN commented 8 months ago

Hi @NripeshN Thank you for the reminder. I have addressed the pending reviews for the deletion of contributor_demos/Sarcasm Detection/requirements.txt as suggested. If there are any further changes needed, please let me know.

Hey @muzakkirhussain011 There are 2 more pending changes I requested image image

muzakkirhussain011 commented 8 months ago

Hi @NripeshN ,

I've made the requested changes. Could you please review them at your earliest convenience? If there's anything else that needs attention, just let me know.

Thank you!

NripeshN commented 8 months ago

Hi @NripeshN ,

I've made the requested changes. Could you please review them at your earliest convenience? If there's anything else that needs attention, just let me know.

Thank you!

Hey @muzakkirhussain011, Looks like not all the packages are installed to run the notebook using requirements.txt. Can you please add all the requirements?

muzakkirhussain011 commented 8 months ago

Hi @NripeshN

The requirements.txt file includes all the necessary libraries that aren’t available by default in Colab. I’ve executed the code successfully in Colab without any issues.

Best regards,

muzakkirhussain011 commented 8 months ago

Hi @NripeshN ,

I appreciate your review and the heads-up regarding the requirements.txt. I have gone through the file once more and added all the missing libraries that are essential for running the notebook. The updated requirements.txt is now part of the pull request. Please let me know if everything works fine or if there’s anything else needed.

Thank you for your patience and assistance.

Best

NripeshN commented 8 months ago

Hi @NripeshN ,

I appreciate your review and the heads-up regarding the requirements.txt. I have gone through the file once more and added all the missing libraries that are essential for running the notebook. The updated requirements.txt is now part of the pull request. Please let me know if everything works fine or if there’s anything else needed.

Thank you for your patience and assistance.

Best

Hi @muzakkirhussain011 Could you please add all the dependencies that are needed to run the notebook in requirement.txt. Seems like some packages are missing in requirement.txt

muzakkirhussain011 commented 8 months ago

Hi @muzakkirhussain011 Could you please add all the dependencies that are needed to run the notebook in requirement.txt. Seems like some packages are missing in requirement.txt

Hi @NripeshN ,

I've updated the requirements.txt file with all the necessary dependencies for the notebook. Please check and confirm if everything is running smoothly on your end. Your prompt response would be appreciated!

Thank you.

NripeshN commented 8 months ago

Hi @muzakkirhussain011 Could you please add all the dependencies that are needed to run the notebook in requirement.txt. Seems like some packages are missing in requirement.txt

Hi @NripeshN ,

I've updated the requirements.txt file with all the necessary dependencies for the notebook. Please check and confirm if everything is running smoothly on your end. Your prompt response would be appreciated!

Thank you.

Hey @muzakkirhussain011

I see you have used pip freeze to add all the requirements, but this approach adds a lot of requirements that come along the main packages anyway. Could you just add the main packages you used in the notebook? Thanks!

muzakkirhussain011 commented 8 months ago

Hi @NripeshN

I’ve updated the requirements file to include only the main packages used in the notebook.

Thanks

NripeshN commented 8 months ago

Hi @NripeshN

I’ve updated the requirements file to include only the main packages used in the notebook.

Thanks

Hey @muzakkirhussain011, Is there a reason we are mentioning the pip package's version? Why are we just not downloading the latest version?

muzakkirhussain011 commented 8 months ago

Hi @NripeshN ,

Updated the pip packages to install the latest versions automatically. Please let me know if you have any concerns or further questions.

muzakkirhussain011 commented 8 months ago

Hi @NripeshN ,

I've made the necessary updates, and if everything checks out on your end, Could you please review and merge it? Looking forward to your prompt response.

Thank you!