Japanese Trade Statistics Analysis 2

In Japanese Trade Statistics 1, we find that China is the driving force behind the increase of the Japanese trade with Asian countries from 1988 to 2015.

Following this, we want to know what kinds of products contribute most to this change of trading pattern.

To answer this question, we first have a look at the structure of commodities in the Japanese Trade.

ratio of com

Continue reading “Japanese Trade Statistics Analysis 2”

Derive hinge loss from SVM

What is hinge loss

The hinge loss is a loss function used to train the machine learning classifier, which is

L(\hat{y}) = max(0, 1 - y\hat{y})      (1)

where y =  -1 or 1  indicating two classes and  \hat{y} represents the output from our classifier.

However, the SVM I know is like

 min\frac{1}{2}\parallel W \parallel^{2}_{} + C\sum^{N}_{i = 1}\xi^{}_{i}      (2)

s.t.    \xi^{}_{i} \geqslant 0, y^{}_{i}(x^{T}_{i}W + b) \geqslant 1-\xi^{}_{i} \forall i

So what is the relation between the two? Are they just two perspectives to look at the same model?

Continue reading “Derive hinge loss from SVM”

Logistic regression with softmax function

The logistic regression model is a simple but popular generalized linear model. It is used to make classification on binary or multiple classes. Here, we will try to implement this model with python, test the results on simulated data and compare its performance with the logistic regression module of scikit-learn.

Continue reading “Logistic regression with softmax function”