Explore Machine Learning Models Without Writing Code or Installing Packages

Leveraging scikit-learn’s models and exposing their behaviour through API

Raman Sah
Towards Data Science

--

“forced perspective photography of bus on road” by Muneeb Syed on Unsplash

Machine Learning | Artificial Intelligence | Deep Learning — they ARE the next big thing, I know it, we all know it. Then why wait? What keeps us from grabbing the opportunity when its right in front of us? Maybe because taking a step off from daily chores and doing something new requires a bit of effort.

Back in the days when I started to explore machine learning and its applications, a significant portion of my time got wasted in guess what? — figuring out and researching 1. the language to use, 2. framework to choose, 3. installing (installing it the right way) and setting up a development environment. After all the drama, I get to start actual development.

Then comes the idea of building a cloud based application where anyone can start harnessing the power of machine learning and it will take care of the rest. Of course there are plenty of service available — one is BigML, but for my own practice and satisfaction, I started to develop the idea.

It became my dream project overnight; An independent web application where one can learn and test Machine Learning models through APIs. No more coding expertise, installation headaches, compatibility issues, need for a powerful rig. Even Postman could run it.

Sample Usage

Fetch the JWT for current user

POST /api/login/
Content-Type: application/json
{
"username": "username",
"password": "password"
}

Response
{
"token": "abcd12345"
}

Consider the following problem statement

You are a Physics student who appeared for the final exams and impatient to know your final score. But the teacher who grades you is insanely strict. He has a formula to calculate total score but no one knows it (which is 0.5 * Paper_1 + 2 * Paper_2 + Paper_3). You have a list of your friends’ exam scores along with final score and want to calculate yours.

Fire up a linear regressor with the given input

POST /api/model/
Content-Type: application/json
Accept: application/json
Authorization: JWT abcd12345

{
"model_path": "sklearn.linear_model.LinearRegression",
"action": "new_model",
"name": "Compute Final Score",
"input_x": [[95, 87, 69], [99, 48, 54], [85, 57, 98], [90, 95, 91]],
"input_y": [291, 200, 254, 326]
}

Response
{
"status": "Trained",
"model_id": "randommodelid"
}

Use this trained model to predict your score

POST /api/model/
Content-Type: application/json
Accept: application/json
Authorization: JWT abcd12345

{
"action": "predict",
"model_id": "randommodelid",
"input_x": [[90, 95, 91]]
}

Response
{
"status": "OK",
"prediction": [
326
]
}

This is an active project under development. Currently serving Linear Regression, SVM and KNN. More complex models coming soon …

Update (Sep 30, 2018) : Refactored code to dynamically fetch model classes mentioned by the user in API. Theoretically, all models in scikit learn can be tested now.

The model_path argument decides which model to invoke. You can try various others including, but not limited to:

  • sklearn.svm.SVR
  • sklearn.svm.SVC
  • sklearn.linear_model.BayesianRidge

and many many more …

I am looking forward for like minded folks, just like me who are willing to help or contribute to the project. The project is hosted on Github and I would be glad to accept some pull requests. 😃

--

--