Wouldn’t it be pretty cool if you could make your own review rating algorithm, in simple HTML & JS without worrying about the tedious ML backend infrastructure? That’s exactly what we’re gonna do in this tutorial — build an ML algo which gives ratings to reviews (1–5) in a jiffy.
Dataset
We’ll be using the Etsy review dataset openly available at Kaggle: https://www.kaggle.com/andrewmvd/trip-advisor-hotel-reviews. Credits to Kaggle: Abdulelah for distributing the dataset
This contains the text of a review and it’s score — what rating the buyer gave the seller. We’ll try and predict the score given the review.
Step 1: Upload the dataset to your Hazlo account
Log in to your Hazlo account, go to the datasets page and deploy the .csv file from the link.
Step 2: Create your project
Once you’ve uploaded your dataset, go to your projects page and launch a project with “ratings” as your chosen column.
After pressing deploy, your model should be ready in a couple of minutes. You can see your models training in real-time and Hazlo takes care of the tedious stuff like synthetic samplings and vectorizations — so we can focus on building our site.
Step 3: Connect your API
You’ll see the sample cURL request for your model in your “APIs & NLP” page; you can convert the request to your language of choice (JS in this case) with https://curl.trillworks.com/ — it’s a nifty tool that quickly converts a cURL request to valid requests different languages.
Step 4: Build out a front-end
This step’s pretty straightforward, we’ll build out a quick front-end using CSS ( I’ll be using Bootstrap to add that bit of pizazz) & HTML. It’ll need to have a text area input which users can write the review in and a predict button which executes the fetch query.
Step 5: Deploy & share with the world
That’s it you’ve built out your review classifier — you can now deploy it and share it with the world.
Here’s my pen, you can put in your project details (project code & API Key) and start using it.
An aside: since this is just a demo, we’re using API Keys on the client side; however, it’s highly recommended that you only use your API key on the server-side of things during production.
“Talk is cheap. Show me the code.”
― Linus Torvalds