2016年4月19日 星期二

4.19 Pick up a new language?

This is quoted from UW Machine Learning Discussion Forum:

hey kai,
Need your advice, as you have more experience in data science.
Which is more used in real world application R or Python ?
I know python and I want to learn data science using python.
Would I have to learn R ?
thanks,
Savan

My response:

Hi Savan,
Regarding your question, there is no right/wrong answer in deciding whether it is necessary to pick up a new language. There are many arguments out there (http://insidebigdata.com/2013/12/09/data-science-wars-python-vs-r/). Since I started R first (before R I got some experience in MATLAB), I am primarily an R user and it's my current tool for data processing and analysis. My overall experience with R is that it is very flexible, meaning there are many available packages (and getting more and more) that are developed and can be applied in many fields; but I heard people arguing there are so many tricks in R (i.e. shortcut functions) that could make the codes kind of messy. One strength of python, though I don't have an intuition yet, is it's highly scalable (able to handle small or huge data set), and I guess this is part of the reasons python is very popular in machine learning.
So, it's useful to know another language for data science, but it is also necessary to be realistic and figure out the time and the study load that one might take, since it's also a learning process. My suggestion would be stick to python first, but feel free to explore. After all, the core of data science is to "get hands dirty" (http://www.kdnuggets.com/2015/05/data-science-inconvenient-truth.html), so there will be many opportunities to practice; as the hands get more dirty, one may need to come up with new solutions to the problems, and at that point R might come in and play.
I hope this help.
Best,
Kai

2016年4月18日 星期一

4.18 Study Note for UW Machine Learning – Regression

Introduction
Learning x à y relationship
Case study: predicting house prices
Module 1: Simple Regression
Gradient descent algorithm
Module 2: Multiple Regression
Incorporate more inputs
Module 3: Assessing Performance
Overfit
Measures of error (training, test, true)
Bias-variance tradeoff
Module 4: Ridge Regression
In addition to measure fit, ask how to choose balance (i.e. model complexity)
Cross validation
Module 5: Feature Selection & Lasso Regression
Efficiency of predictions and interpretability
Lasso total cost = measure of fit + (different) measure of model complexity
Coordinate descent algorithm (very cool, maybe useful in tuning coil)
Module 6: Nearest Neighbor & Kernel Regression
Models, Algorithms, Concepts, very important course

Assumed background: Basic calculus (concept of derivatives), basic linear algebra (vectors, matrices, matrix multiply, important to learn before IBSC program started); programming experience: python; Reliance on GraphLab Create, SFrames, Assignments: use pre-implemented algorithms first, then implement all algorithms from scratch, via Numpy library
Net result: learn how to code methods from scratch

Provided machine in Cloud

2016年4月14日 星期四

4.14 Random Forest

Want to remind myself that I used to learn the concept of random forest in JHU's Data Sciences Specialization on Coursera.

Review and refresh my mind on the concepts and how to implement this method in R may be helpful at some point.

2016年4月7日 星期四

4.7 Posting this Machine Learning cheat-sheet

As I am learning the UW Machine Learning on Coursera these days, posting this cheat-sheet (should be obtained from Mi some day) is relevant.


2016年4月1日 星期五

4.1 Thoughts in Data Analysis

Constructing a clean table requires patience and many hard works. The rewards are huge when performing downstream analyses.

Double-checking upon each query is very important, which can avoid data flying around.

What's wrong with my ML's answer of "predicting the majority class"?
(ref: Carlos in the ML class)
The "Major Classifier" was explained in the video "What's a good accuracy?" (Under week 3, Section 2: "Evaluating classification models") But I also have a hard time understanding it. I also would like some instructor to help me understand this better. This is what I understand so far:

A "class" is one group a where a classifier can place an event. For example flip a coin, there are 2 classes: heads or tails. This is a Binary Classification and I have a 50% possibility to guess a coin flip correctly. After many coin tosses, chances are I will be 0.5 accurate on my guesses. If a classification has more classes (k), the accuracy of the classificator will be =1/k

For example, rolling a die would have 6 k (classes) so accuracy of random guessing would be 1/6 = 0.1666...

Now, for the example in the video, Carlos explains that we should always compare our model accuracy with a simple baseline. A simple baseline could be a Random Guess (50% accurate for a Binary Classification) or a Majority Class (Guess everything to the most common class then the accuracy of your guess equals to that class' occurrence)

Carlos explains that 90% mail is spam, so spam is the "Majority Class"

That means that if I had a dataset with tons of emails and I just looked at the file without even opening any mail, and then I declared: "Fu** it, All of this mail is spam. Let's go have one beer", I would be 90% accurate. THEN, if I make a classifier model , it must be better than 90% accurate, else the "Fu** it" strategy is a better investment of my time.

So, let's say that I arrive to the bar to have my beer for a job well done, and I declare: "This bar is full of good beer!". The barman, (who also happens to be a statistician during the day), then corrects me: "The truth is, we sell 65 beer brands here. If you choose one at random there's 1/65 chance that you will like one. If I recommend you one, there's a 50% chance you will like it. I would recommend you our most sold beer, which is a total 2% of our business, or I could share to you this dataset with beer lovers reviews ..."

Being that the case, I could better invest my time to create a predictor model to guess which beers I might like from the Bar's variety. If I make a predictor with, say, a 80% accuracy, i'm truly in for some good beer without being wasted drinking lots of untasty beer.

Then, this is the approach I will take for question 7. "Which of the following ranges contains the accuracy of the majority class classifier, which simply predicts the majority class on the test_data?":

I will look for the accuracy of the majority class. To find the major class classifier from the test data, based in the column 'sentiment'. Just sum the entire column (to find the number of items classified as 1) and divide by the lenght of the SFrame.