1
$\begingroup$

I am currently working on a dataset having 10 features and one continuous target variable. One of the features is 'Country' , in which there are seven unique values [Argentina ,Denmark , France...etc].

Now , the continuous target variable is sales of a given product in that particular country for a given month in a given year.

It has been given in the problem statement , that the Sales have been taken in the local currency of that country , so now I have values on different scales and I am not sure how to deal with them.

When I grouped the data as per the different countries , (using pandas's groupby function) , I got at least 1000 observations for each country. So maybe I could train a model separately for each country ? All kind of approaches will be appreciated.

$\endgroup$
0
$\begingroup$

TL:DR The most common and straight-forward approach would be to scale all the numerical data to be within a given range. This makes the currency differences irrelevant, as all fluctation remains constant, relative to the original scale.

Rescaling

Here is an example function to scale the numerical columns of your dataset:

def rescale(data, new_min=-1, new_max=1):
    """Rescale the columns of Dataframe to be in the range [new_min, new_max].

    Parameters
    ----------
    data    : a Pandas DataFrame
    new_min : the target minimum for each of the columns, optional
    new_max : the target maximum for each of the columns, optional

    Returns
    -------
    out : the rescaled input data, with each column now in the range [new_min, new_max]

    """
    return (data - data.min()) / (data.max() - data.min()) * (new_max - new_min) + new_min

You can then do the following to see nice descriptions of each column in your dataframe, ensuring the min/max values are as desired:

your_dataframe.describe()

One thing to perhaps try out, would be whether or not to scale **all* data to be within a fixed range, say [0, 1], or whether to scale each individual currency to the range [0, 1]. That equates to applying the above function on either single columns of your dataframe, or the entire dataframe.

Considerations

Things to keep in mind/check for would be:

  1. if some currencies are nominal huge compared to others (e.g. 1 euro = 17,000 Indonesian Rupiah), the smaller currencies will have time-series values all very close to zero - this makes computation/optimisation more difficult - especially if you use methods such as gradient descent.

  2. Scaling the currencies individually to a range would lose the relativity of their nominal values. To see this, plot the currencies before and after scaling.


Unify the Currencies

If you have (or could get) exchange rate the data, another alternative would be to convert all of the currencies to the one one your choice.

As the exchange rate changes over time, this would also inherently introduce new information into the dataset, namely the relative economic health of each of the countries. Depending on your use case, this could be something that really helps, or you might really want to avoid. If you have to time, to do it, it could definitely make for some interestinf research!

You can get currency data from Quandl - they have a Python API too, which is simple enough to use.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.