A low-code guide to build PyTorch Neural Networks with Pycaret

Almost in every machine learning project, we train and evaluate multiple machine learning models. This often involves writing multiple lines of imports, many function calls, print statements to train individual models and compare the results across the models. The code becomes a mess when comparing different models with cross-validation loops or ensembling the models. Over time, it gets even messier when we move from classification models to regression models or vice-versa. We end up copying snippets of code from one place to another, creating chaos! We can easily avoid this chaos by just importing PyCaret!

PyCaret is a low-code machine library that allows you to create, train, and test ML models via a unified API given a regression or classification problem. PyCaret also offers various steps in a machine learning project, from data preparation to model deployment with a minimal amount of code. It can work with any model/library that follows a Scikit-Learn API such as Scikit-Learn Models, Xgboost, LightGBM, CatBoost, etc. All in all, the library is an easy-to-use productivity booster that enables fast experiments and helps you focus more on the business problem at hand.

Now, what if you want to add Neural Networks to your models-to-try list?, you need to write snippets for training and testing loops with frameworks like PyTorch, convert NumPy arrays to tensors, and the other way around to get existing things working or write a whole new set of evaluation functions. One small Type error and you end up changing a part of the code you have written over time, which might create more issues you never anticipated. You end up more time updating the code than experimenting on different models and solve the problem.

What if you can use the same PyCaret with Neural Networks with very minimal changes?

Yes, you heard it right! SKORCH makes it possible! SKORCH is a Scikit-Learn wrapper for PyTorch that makes it possible to train Neural Networks with sklearn-like API, which is what PyCaret expects!

Many resources are explaining how to use Pycaret to build ML models with a single line of code! And also tutorials and examples for using SKORCH to build neural networks. It is recommended to go through these tutorials before jumping into the next parts of this blog. This notebook containing the code can be referred to in parallel.

In this blog, we will see

  • how to use build a neural…

Continue reading: https://towardsdatascience.com/pycaret-skorch-build-pytorch-neural-networks-using-minimal-code-57079e197f33?source=rss—-7f60cf5620c9—4

Source: towardsdatascience.com