human
I am working on the file "Antoine_ISNARDY_el_nino.ipynb".
The first task is:
It seems that there is a bias towards first columns of the array, meaning lowest lat and lon. Surprising.
In order to remove the bias, I tried to shuffle columns in the training array (uncomment lines of code in the above FeatureExtractor). Results are not that better. Worse, they are very depending on the permutation.
Leads to think that xgboost is sensitive to feature ordering (surprising)



As observed in descriptive data, temperature in the EN zone looks pretty correlated to what's happening in the east side of the zone !
More surprisingly, what's happening in the west part of the Indian ocean seems to affect EL temperature.
In any case, EN zone is mostly affected by what's happening around the equator.
This supports papers I have read about how horizontal wind affects climate, especially near equator.
Besides, the wind force was one of the feature in "ClimateLearn: A machine-learning approach for climate prediction using network measures"



Next step was to leverage most important features
A simple trick was to take into account only these most important features.
They were retrieved based on the fitting of the whole training set.
The way it is implemented is pretty ugly as it is set in a hard fashion, but it is convenient for the submission process.
Can you write Python code for it?
assistant
#Here's happening in the east side of the zone !
.

mask = np.where(reg.clf.feature_importances_ > 0.002)

import numpy as np
import pandas as pd
import xarray as xr

mask = np.array([   0,    1,    2,    3,    5,   72,  251,  345,  378,  385,  823,
         921, 1010, 1011, 1017, 1054, 1058, 1059, 1088, 1100, 1102, 1121,
        1122, 1130, 1138, 1147, 1157, 1209, 1216, 1222, 1223, 1233, 1234,
        1237, 1246, 1252, 1257, 1270, 1271, 1274, 1278, 1288, 1307, 1308,
        1309, 1319, 1330, 1332, 1338, 1340, 1341, 1342, 1343, 1344, 1345,
        1346, 1347, 1348, 1349, 1350, 1360, 1379, 1397, 1402, 1423, 1429,
        1433, 1455, 1476, 1477, 1483, 1487, 1498, 1508, 1516, 1531, 1537,
        1551, 1553, 1554, 1600, 1602, 1629, 1671, 1673, 1685, 1855, 1866,
        1880, 1914, 2052, 2099, 2201, 2205, 2267, 2664])

# El nino zone
en=[-5, 5, 190, 240]

# Around zones
bottom=[-15,-5,190,240]
up=[5, 15, 190, 240]
left=[-15,15,165,190]
right=[-15,15,240,250]

rectangle=[bottom[0], up[1], left[2], right[3]] # Including all zones

pac_lat_bottom = -60
pac_lat_top = 60
pac_lon_left = 360 - 220
pac_lon_right = 360 - 80

en_lat_bottom = -5
en_lat_top = 5
en_lon_left = 360 - 170
en_lon_right = 360 - 120

def get_area(tas, coords):
    return tas.loc[:,coords[0]:coords[1], coords[2]:coords[3]]
    
def get_area_mean(tas, lat_bottom, lat_top, lon_left, lon_right):
    """The array of mean temperatures in a region at all time points."""
    return tas.loc[:, lat_bottom:lat_top, lon_left:lon_right].mean(dim=('lat','lon'))

def get_enso_mean(tas):
    """The array of mean temperatures in the El Nino 3.4 region at all time points."""
    return get_area_mean(tas, en_lat_bottom, en_lat_top, en_lon_left, en_lon_right)

class FeatureExtractor(object):

    def __init__(self):
        pass
        
    def transform(self, X_ds):
        valid_range = np.arange(X_ds.n_burn_in, len(X_ds['time']))
        
        worldwide = X_ds['tas'].values
        worldwide_vectorized = worldwide.reshape(len(worldwide), -1)
        X_array = worldwide_vectorized
        X_array =...