Tuesday, February 6, 2018

CoreML Simple Linear Regressor


I started learning basic Machine Learning from last 6 months from Udemy Course.

Machine Learning A-Z™: Hands-On Python & R In Data Science

I am a friend of mine, started to do MLTokyo study session every Saturday. I remember we were so obsessed with it that once we were working for 3 continuous days in Silver Week holidays from morning 10AM to almost 7PM.

I could grasp the fundamentals of Machine Learning algorithms but I still wanted to connect it to my job.
It was just that last year Apple announced the CoreML Framework in WWDC2017 talks.
So it was the perfect timing to apply the studied machine learning.

CoreML is a great Framework.
For those who are new, here's a quick explanation, the image which I have in mind about CoreML.

  • Traditionally, we train ML models on the server side. We need to have good specification server, keeping in mind the time, processing power, and data size required to train the model.
  • Once we are finished with the training, we want to use it from the mobile app. To achieve this, we generally build a wrapper API around the model.
  • The app captures the data and sends it to the API for processing. The model processes the data and returns the results via API back to the app.

So generally a Machine Learning App is built around this architecture.

The problem with above process is that the app constantly needs to be connected to the Internet to be able to process the data.
Also, there's huge network overhead involved with it.

CoreML to the rescue:

CoreML improves this process to a quite extent.

  • The same already trained model can now be exported to a file format (.mlmodel) which can be easily imported into Xcode Project. This integrates the model into your app directly removing the need for overhead API and also making your ML App offline workable.
  • According to the documentation of CoreML, it does supports following Caffe, Keras, scikit-learn, XGBoost, LIBSVM. 
So I thought why not to convert the models trained in the Udemy Course one by one.

My first CoreML integration.

Udemy Course:
- Part 2 - Regression
 - Section 4 - Simple Linear Regression
   Github source code

Xcode Model

APP Preview in Simulator

Since it was a simple Linear regressor, it was quite simple to integrate.
But as I proceeded to integrate Polynomial Regression, I started facing problems of data preprocessing.
I am still stuck on translating PolynomialFeatures into swift code.
It seems like all the data preprocessing has to be re-written in the app code to be able to provide inputs to the trained model.

Although it looks all promising and interesting to integrate CoreML, there are some things which should be taken care of.

  1. App Size will increase depending on the size of the trained model. CNN model trained with 4000 images each for 2 classes yields a 15MB .mlmodel file. This model gets packed with almost same size as .mlmodelc file inside the IPA.
  2. As far as my understanding of the topic is that it is not possible to train the model on the device. So the only prediction can be done from the model. I think there is a provision to update the model from in background of the app, but have not yet explored it.

If you like this post and have any comments please let me know.

Happy Machine Learning,
Happy iOS

Sunday, August 6, 2017



Today I went to the Maker Faire Tokyo 2017.
It was an awesome event. Many robots and innovative ideas.
One day is just not enough to see all the exhibits.

This event was held on Saturday/Sunday 5th and 6th August 2017 respectively.

It attracted quite a lot of people.
The exhibits varied from school robotics projects to professional big industry products.
The event audience also varied correspondingly. Small kids could play with robots and maneuver them in the grid. People could also try VR and experience the mind blowing simulations and games.

Here is a quick conclusion of my day

Things I learned
- The trend to have a personal robot assistant with you all the time is increasing. People need small cute robots to talk with them, interface with them.
- Daily activity robots are gaining popularity like the cleaning robot.
- DeepLearning/AI combined with robotics is gaining an edge over traditional robotics methodology. Robotic arm with build in camera on its tip is simple to estimate the world.
- Image processing has proven to be an efficient substitute for hardware devices like distance measurement, angle measurement, position coordinates.
- Smart IoT homes are becoming popular with IoT devices connected to the internet, there is so much potential for data collection. Cheaper data collection methods are available now as compared to surveys or access logs.

- With the digital age, the analog devices become obsolete, but there was a team which showed how analog devices can be still used in making interesting games or small devices. These guys used the tape recorder magnets to generate sound, the CRT TV as the drums collecting the noise and producing sound.
- One team even showed the application of high voltage sparks in creating music or beautiful arts.

By checking these things, I am quite motivated to join the next year's faire and have an exhibit.

I have shared some pics on my Instagram  or MyPage : roboganism
Please check if you are interested.


Wednesday, May 31, 2017

Snow Wall of Nagano

Day 1 of 7 

Time Log:
- D1
21st Sunday
05:14 Minatocho -> 05:17 Keikyu Kawasaki 
05:34 JR Kawasaki -> Tokyo (05:52)
06:16 Tokyo -> Nagano (07:38) Kagayaki 1501
20:35 Toyama -> Kanazawa 20:55

1) Kawasaki -> Nagano

We started off with the first train from Minatocho Line (place where I live).
Getting around Nagano-station was not that difficult. My family (3 members) had a JR rail pass of 7 days. Before using the rail pass, we just need to get it checked from the station master. Every time you pass the JR station, you need to show the pass to the station master and then checkin / checkout. 
I didn't had the 90days short visa, so I had to buy tickets.

We reached Nagano around 07:38 AM.
I had thought I will buy the Option ticket (http://www.jrtateyama.com/e/) from Nagano station, but the Midori Madonokuchi (ticket office of JR) opens at 10:00 and I arrived at Nagano before that.
I should have bought the ticket beforehand from Tokyo.

2) Nagano -> Ogizawa
Instead of wasting time waiting for the Midori Madonokuchi to open up, I proceeded with my plan of traveling the one way route by paying for individual tickets, but to my surprise there were other companies which were also providing tickets for some sections of the Alpine Route.

So we took Alpico Bus from Nagano -> Ogizawa. it cost around 2,600 yen.  From Ogizawa-station, the one way ticket from other company was available, so we took that one. It cost around 9,500 yen. 

3) Ogizawa -> Kurobe Dam
You take a Kanden trolley bus to go to Kurobe Dam. This is a nice trolley bus which goes through the tunnel in straight manner. It is electric bus and gets power from the two connecting rods to the overhead power cables (similar to train). I was amazed that they maintained this old technology still  till date and are using it for tourism.
I suppose this trolley was used to transport all the construction material to Kurobe dam.

After reaching Kurobe Dam, there are two places to visit.
  1. Go to top walking 222 stairs to get good view of the dam. (there is a spot from which you can see the rainbow when the water is opened out of dam)
  2. Go to bottom directly on the edge of the dam. (one side you can see the deep dam side and other side the flat lake Kurobeko )
At regular intervals you will find fresh stream water to quench your thirst


On the end of the dam, you will find the Kurobeko station located like inside the Tunnel.

4) Kurobeko -> Kurobedaira -> Daikanbo
From Kurobedaira you need to take an almost vertical cable car. It is quite tilted (I think the angle must be around 29 degrees). It takes you to the intermediate top of Mt Tateyama.
From here you have to ride the ropeway to reach to the top Daikanbo station. 
While riding the ropeway, you can see over the the snow blanket of the mountain. I could see some skaters coming from the top. It was a spectacular view.


5) Daikanbo -> Murodo 
The trolley bus takes you from one side of the Mt Tateyama to other side (Murodo).
This is the main place were you can see the Yuki No Otani (Snow Wall) 
The wall is around 3 floors high and it is better to check weather before going there.
We thought it would be quite cold up there, so we tool big jackets, but they were of no use. it was not freezing cold. even a normal jacket / sweater would have been fine.

6) Murodo -> Bijodaira -> Tateyama
We directly caught the bus to Bijodaira since we all were tired. There are not much things to see while coming down. There were some parks but we were least interested in them.
Then you take a cable car from Bijodaira to Tateyama

7) Tateyama -> Toyama 
There is a beautiful old train from Tateyama to Toyama which goes slowly and you can take good pics from this train.


We had booked Airbnb at Kanazawa. Entire room for 4 people.

It was a great experience.
Just had to go into hot bath for relaxing.

Kanazawa is very quite and beautiful place. Maybe next time I would like to visit just Kanazawa. This time it was just the stay.

Monday, November 28, 2016



Saturday, January 30, 2016

Sushiro in japan (スシロー)

Sushiro is a famous sushi restaurant chain in japan.
Today I went to nearby sushiro restaurant. When we entered the restaurant, there was a long queue. I quickly too the booking number and we waited in the queue.

They have this cool booking system connected to the net. They have their separate iphone and android app.
iPhone : https://itunes.apple.com/jp/app/sushiro/id551682016?mt=8
Android : https://play.google.com/store/apps/details?id=jp.co.akindo_sushiro.sushiroapp&hl=en

We can download this app pre-hand and quickly search the nearest store and get the booking number before we reach the place. This is quite convenient feature. Also don't worry if you didn't booked it from smartphone. You can take the booking number from the place itself and register that number in your phone's sushiro app. That would be helpful if you plan to do some nearby shopping until your number arrives. The app will give you notification when your number is about to be called. It will also calculate approx how much time will it take to have the seat.

Once your number gets called, then you are in, to eat plates and plates of sushis.
There's roller belt through which all the sushi orders are served in form of plates.
From the menu ordering system, you can check and order variety of dishes. There's limit of 5 dishes per order, so I will recommend to order 1st snacks quickly and then decide later the main dishes.

The sushi rolling belt brings your orders. Once the dish on the rolling belt reaches your place, the system gives notification that you order has arrived and you need to take off the dish from the rolling belt. If this is your first time to go to sushi restaurant, then you might end up taking other person's dish :P (which i did today !! really embarrassing)

There's a trend that the more you eat sushis the more you can stack plates one on top of the other. You can always check the number of stacks on other table so that you don't fall out of competition !!!
People come with families to this place. On an average one person can eat 10 dishes.
We ate 15 different dishes. I hope so different fishes don't start fighting inside my stomach. hahah

When you are finished with stuffing as much as you can, then you just call the person to record the number of dishes so that he can bill it. Pay the bill at the counter and go home happily with the great satisfaction.

Tuesday, February 10, 2015

Anything as a Service

I remember that in old days, we had to rely on lot of things. But as technology progressed, things started appearing as services. What I mean to say is the things which were quite difficult to get can now be just obtained as a service. IAAS, PAAS, SAAS are all quite good examples.

One more variant to this is offering the available resources as service. Resources which are not used all the time, can be put to other use.

1) Find a House
airbnb is a site on which you can put your extra room resource as a service. In this way, the extra room gets used 100%, I will say its a very efficient way of using existing resources.

2) Find a Guide/Translator
Based on the same concept as airbnb, we can invest out free time on weekends as a guide to help tourists visit local places. The locals of that city register themselves as guides depending on their schedule. Tourists just need to book a guide on website for particular day/s.

3) Find a Delivery Boy to get food.
Foodie people will find this concept quite interesting.
Say your brother wants to eat Pizza, your sister wants to eat Sushi, and your mom likes Paneer Palak.
You need to call 3 different restaurants. Instead of this you will just call some service and tell them to get these 3 dishes from corresponding restaurants. That service will arrange someone and deliver the dishes right to your home.

4) Find a Salesman
In some countries, salesman go door by door to advertise and sell their products. I think it is just a waste of the time resource. Instead we can have a salesman service, in which you just inform them that you are planning to buy say Vacuum cleaner. That particular service will send you the corresponding salesman. In this way you can do home shopping.

5) Find Local Cuisine
This is another good service for foodies (especially tourists). People want to try local cuisine whenever they visit any place. So local people can arrange food events for which people can freely register and taste the local cuisine.

6) Find a Taxi/Pickup
Services like OlaCabs, Uber taxi, etc. have created additional service layer between the end customers and taxi providers. There are also services in which you can offer the extra empty seats in your car while going to office or returning back to home.

Any resource which you find free can be put to use by offering it as a service !!!

Monday, December 22, 2014

MLM and Social Networks

Good Morning, all readers !!!
And a nice Hello to everyone

Having plenty of free time, so just thought of blogging something.
Here's one of the storiesnexperience post about MLM and Social Networks.

I was in Japan when I got introduced to this HealthCare company.
People said that they got reach in no time after joining this company.

I attended one of their brain washing sessions. The concept was simple,
   “Introduce someone and you get benefits. 
      And on every purchase made by him get more benefits in terms of percentage of the purchase”
Mathematically, it’s unstable model, so you need to control the limits of earnings, or the maximum  number of purchasers connected under you in the graph.
They rely on mouth to mouth advertising for expansion of this graph. The more it expands, the more profit will the people on the top of the graph get. The graph is filled with lot of hopes of big digit dreams. Many people back out after some struggling. There are ways to go to the top, some of which are fishy. There are plans which say “Spend More Get More”

A lot of negative opinions are present when this kind of MLM model is implemented physically with mouth to mouth advertising.
Only if we can trap the potential of this model with the social networks, 
carefully enough that the users at least get something rather than negative profits.

Simple implementations are Invitation Code systems.
In this one, you introduce your friend by using Introduction Code, and then when he registers using your code, you get the benefits. This is MLM of first order. 
In general, this could be used for any action with an action_code and action_benefits.

When we expand it to multiple levels, we need to build a strong graph.
One of the reasons why many of us quit while taking sessions from the the MLM companies, is due to the amount of effort required build a strong graph. You need to talk with many people and convince them to enrol in this scheme. You got to have free time to do this. 
What if we can use the social networks to do our job. 
It could be anyone, twitter’s followers/following network, facebook’s friend of friend network, and so on. On this network, you can clearly calculate which node gets the benefits from other nodes.
Integrating with social networks has lot of potential to generate profits.

This system can also be used for audience gathering for events.
You can have a facebook party event. People invite their friends to this party and get discounted fee. In no time, your event will be overbooked.

In case of buying/selling markets, this system will be similar to using people as salesman. You put any item for sale on some e-commerce site, and you generate a Selling Code for each registered user on that site. Then if someone buys that item with your Selling Code, then you get the benefits.
The seller does not have to put extra effort in pushing the product, while the idle users (just the free-surfing users) can get benefit for acting like salesman.

Mentioning the positives, there are negatives of this integration too !!! 
Sending too many mails, or posting multiple times wont just do good until it is good quality content.
So that requires some good brain storming to build better relationships.

So let’s explore and share this new domain.
Please let me know your opinions on this topic!!! 

CoreML Simple Linear Regressor

Introduction I started learning basic Machine Learning from last 6 months from Udemy Course. Machine Learning A-Z™: Hands-On Python...