Jul 13, 2018

Textual description of firstImageUrl

Weekend learning: An ad-hoc way to add new arsenal - IOS Application development with iPhone App Bootcamp Udemy

Needless to say sometimes people are so much stressed that they want to come out of this so called "Work-Learn-zone" to "Fun-Learn-zone". Different people have different methodology of transition.
We work and learn but its inevitable to work with same enthusiasm on trite things. Yes, I get bored and believe me I have validated this with my friends - they have same traits.

Why not build something new, learn and have fun !! 

I decided to spent my weekends with something new learning, build and have fun with tech semantics. After browsing udemy I found a small and crisp tutorial for ios application development in swift programming language - The 10 Day iPhone App Bootcamp - NEW iOS 12 and Xcode 10.

https://udemy-certificate.s3.amazonaws.com/pdf/UC-KRHH9TOL.pdf
The very best part of this video tutorial is, it does not have sample code - You come, learn and do yourself. Although it is 10 days bootcamp, after spending 2 Days of exhaustive session with Nick Walter I end-up with learning of Swift programming basic and developed 4 Small IOS applications 
Building application using swift programming language

Swift programming language is simple in terms of syntax and semantics. This IOS application development tutorial explained very well required Swift programming language and fundamentals of Xcode(Integrated development environment (IDE) for macOS) - prerequisite for IOS application development.

JokeBank App:

This application explained fundamental of Swift array and objects. It contains a list view to choose joke type and on click of this we end up with detailed view of joke. Below screenshot shows UI involved.

Learning highlights :
1. Array in Swift programming and how to create array of objets to store Joke title and details
2. Navigation controller and tabular view of UI
3. How to use ViewController(or TableViewController) along the side of UI.
4. Display text in multi-lines in UI using (jokeQ.lineBreakMode = .byWordWrapping and jokeQ.numberOfLines = 0)
5. How to navigate from One UI to another using Segue(Storyboard segue)
JokeBank App Source Code

TODOList App:

This application provides UI to add task with provision to mark task important or non-important, it also allows to mark it completed and delete it from Home page of application.


Learning highlights :
1. Introduction of Core data concept and Save, fetch and delete from core data
(UIApplication.shared.delegate as? AppDelegate)?.saveContext()
2. Navigation controller, tabular view and navigation buttons.
3. Navigation from UI using multiple segues.
segue.destination as? CompleteViewController or CreateToDoViewController
4. Database entities in core data and associated API's for data interaction.
5. Redirecting from one UI to home screen using navigationController?.popViewController(animated: true)
TodoList App Source Code


Collector App:

This app allows to select images from directory & camera and display images in tabular form with title. It also allows to delete images from home screen using swipe.

Learning highlights :
1. Saving Image in binary form in Core data entity - store image locally.
2. Interaction with camera and local directory to capture image.
cameraImageCollect(_ sender: Any) and directoryImageCollect(_ sender: Any)
3. How to use array of binary data of image and saving in core data. Collectable is entity
var allCollected = [Collectable]()
4. Convert a UIImage into a Data using UIImagePNGRepresentation and UIImageJPEGRepresentation.
collectable.image = UIImageJPEGRepresentation(data, 0.8)
5. Delete image and title from tabular UI using swipe.
if editingStyle == .delete context.delete(collectable)
Collector App Source code

Bitcoin Tracker App:

This is bitcoin price app tracker shows latest price in different currency. Its UI page application with refresh button which brings updated value of bitcoin by making HTTP GET call.

Learning highlights:
1. How to execute GET HTTP request and get price updated in three different currency.
URLSession.shared.dataTask(with: url){(data, response, error)
2. How to write currency formatter using NumberFormatter()
Collector App Source code
Ahhh !! after developing these small app I really had fun with Swift & Xcode and finally became a novice IOS developer

May 4, 2018

Textual description of firstImageUrl

Solve Linear regression problem mathematically with least square method : Find slope and intercept of linear classifier

Linear regression is one of basic supervised learning which is used to predict outcome. In linear regression problem, we find best fit line using sample points with one independent variable and one dependent variable. Basic idea is to finds a linear function which predicts the dependent variable values as a function of the independent variables.
In order to best fit line which is represented by find linear function - we can use ordinary least squares method(minimize the residuals) or least absolute deviations (minimizing the sum of absolute values of residuals). Residuals means vertical distances between the points of the data set and the fitted line (wiki).
Linear best fit line(blue) for data points(Red) and green line indicates error/residues (Source:wiki

Least square method :-  Using this approach vertical distances between the data set points and the fitted line is computed such that sum of all distances for each point from best fit line is minimum. 

Dataset:- (x, y) = (2,10) (4,9) (3,6) (6,6) (8,6)  (8,3) (10,2)

Algorithm : For finding best fit line (y= . mX+ c) , we have to find value of m(slope) and c(intercept). Follow below steps to find slope and intercept.

1. Compute mean of x and y values. Here x̅  and ȳ are mean of x and y data points.


2.  Calculate slope of line(linear classifier)

3. Calculate intercept of line .
---------------------------------------------------------

Use python terminal to find mean of x and y data points.
Python 2.7.10 (default, Jul 15 2017, 17:16:57) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> import numpy
>>> a = [2,4,3,6,8,8,10]
>>> numpy.mean(a)
5.8571428571428568
>>> 
>>> 
>>> 
>>> b = [10,9,6,6,6,3,2]
>>> numpy.mean(b)
6.0

x̅ = 5.86
ȳ = 6.0

Find slope(m):  Pre-process sample data in tabular form below and compute slope of line.

iteration# xi yi xi - x̅ yi - ȳ (xi - x̅)(yi -ȳ)= (P) (xi - x̅)2 =(Q)
1 2 10 -3.86 4 -15.44 14.9
2 4 9 -1.86 3 -5.58 3.46
3 3 6 -2.86 0 0 8.18
4 6 6 0.14 0 0 0.02
5 8 6 2.14 0 0 4.58
6 8 3 2.14 -3 -6.42 4.58
7 10 2 4.14 -4 -16.56 17.14
                                                             
Slope of line:
 
Compute y-intercept :

Now equation of line  :


Best fit line separates data points below and this line can be used to predict outcome for other test(new) data points.