Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/Code of Winning Methods/A5/raw_data
/Code of Winning Methods/A5/proc_data
/Code of Winning Methods/A5/output_data
/Code of Winning Methods/A1/2. data
/Code of Winning Methods/A1/5. models
/Code of Winning Methods/A1/4. logs
2 changes: 1 addition & 1 deletion Code of Winning Methods/A1/2. data/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ This folder should contain the following files:
- sample_submission.csv
- sell_prices.csv

These can be found in the M5 competition repo.
These can be found in the M5 competition repo.
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
#!/usr/bin/env python
# coding: utf-8

# ## Please input your directory for the top level folder
# folder name : SUBMISSION MODEL

# In[ ]:


dir_ = '/home/artemis/M5/A1-Yeon/' # input only here

dir_ = '../../' # input only here
# dir_ = '/A1/' # input only here

# In[ ]:
# ../../2.\ data/

# C:\Users\neuromancer\M5-methods\Code of Winning Methods\A1\1. document

raw_data_dir = dir_+'2. data/'
processed_data_dir = dir_+'2. data/processed/'
Expand Down Expand Up @@ -371,7 +367,11 @@ def merge_by_concat(df1, df2, merge_on):

# Make some features from date
grid_df['tm_d'] = grid_df['date'].dt.day.astype(np.int8)
grid_df['tm_w'] = grid_df['date'].dt.week.astype(np.int8)

## replacing newversion of week version
grid_df['tm_w'] = grid_df['date'].dt.isocalendar().week.astype(np.int8)

# grid_df['tm_w'] = grid_df['date'].dt.week.astype(np.int8)
grid_df['tm_m'] = grid_df['date'].dt.month.astype(np.int8)
grid_df['tm_y'] = grid_df['date'].dt.year
grid_df['tm_y'] = (grid_df['tm_y'] - grid_df['tm_y'].min()).astype(np.int8)
Expand Down Expand Up @@ -523,7 +523,7 @@ def merge_by_concat(df1, df2, merge_on):


# In[ ]:

### cat asdasdsad

#################################################################################
print('Save Mean/Std encoding')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# In[ ]:


dir_ = '/home/artemis/M5/A1-Yeon/' # input only here
dir_ = '../../' # input only here


# #### setting other directory
Expand Down Expand Up @@ -234,10 +234,11 @@ def make_lag_roll(LAG_DAY):
grid_df = grid_df[keep_cols]

d_sales = grid_df[['d','sales']]
substitute = d_sales['sales'].values
# refactored
substitute = d_sales['sales'].to_numpy(copy=True)
substitute[(d_sales['d'] > END_TRAIN)] = np.nan
grid_df['sales'] = substitute

grid_df.to_pickle(processed_data_dir+'test_'+store_id+'.pkl')
del grid_df, d_sales, substitute

Expand All @@ -246,7 +247,8 @@ def make_lag_roll(LAG_DAY):
estimator = lgb.train(lgb_params,
train_data,
valid_sets = [valid_data],
verbose_eval = 100,
# this is deprecated
# verbose_eval = 100,
)

# display(pd.DataFrame({'name':estimator.feature_name(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# In[ ]:


dir_ = '/home/artemis/M5/A1-Yeon/' # input only here
dir_ = '../../' # input only here


# #### setting other directory
Expand Down Expand Up @@ -242,7 +242,7 @@ def make_lag_roll(LAG_DAY):
grid_df = grid_df[keep_cols]

d_sales = grid_df[['d','sales']]
substitute = d_sales['sales'].values
substitute = d_sales['sales'].to_numpy(copy=True)
substitute[(d_sales['d'] > END_TRAIN)] = np.nan
grid_df['sales'] = substitute

Expand All @@ -253,7 +253,7 @@ def make_lag_roll(LAG_DAY):
estimator = lgb.train(lgb_params,
train_data,
valid_sets = [valid_data],
verbose_eval = 100
# verbose_eval = 100

)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# In[ ]:


dir_ = '/home/artemis/M5/A1-Yeon/' # input only here
dir_ = '../../' # input only here


# #### setting other directory
Expand Down Expand Up @@ -241,7 +241,7 @@ def make_lag_roll(LAG_DAY):
grid_df = grid_df[keep_cols]

d_sales = grid_df[['d','sales']]
substitute = d_sales['sales'].values
substitute = d_sales['sales'].to_numpy(copy=True)
substitute[(d_sales['d'] > END_TRAIN)] = np.nan
grid_df['sales'] = substitute

Expand All @@ -252,7 +252,7 @@ def make_lag_roll(LAG_DAY):
estimator = lgb.train(lgb_params,
train_data,
valid_sets = [valid_data],
verbose_eval = 100
# verbose_eval = 100

)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# In[ ]:


dir_ = '/home/artemis/M5/A1-Yeon/' # input only here
dir_ = '../../' # input only here


# #### setting other directory
Expand Down Expand Up @@ -248,7 +248,7 @@ def prepare_data(store):
valid_data = lgb.Dataset(grid_df[vl_mask][model_var],
label=grid_df[vl_mask]['sales'])

m_lgb = lgb.train(lgb_params, train_data, valid_sets = [valid_data, train_data], verbose_eval=100)
m_lgb = lgb.train(lgb_params, train_data, valid_sets = [valid_data, train_data])
# display(pd.DataFrame({'name':m_lgb.feature_name(),
# 'imp':m_lgb.feature_importance()}).sort_values('imp',ascending=False).head(25))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# In[ ]:


dir_ = '/home/artemis/M5/A1-Yeon/' # input only here
dir_ = '../../' # input only here


# #### setting other directory
Expand Down Expand Up @@ -254,7 +254,7 @@ def prepare_data(store, state):
valid_data = lgb.Dataset(grid_df[vl_mask][model_var],
label=grid_df[vl_mask]['sales'])

m_lgb = lgb.train(lgb_params, train_data, valid_sets = [valid_data, train_data], verbose_eval=100)
m_lgb = lgb.train(lgb_params, train_data, valid_sets = [valid_data, train_data])
model_name = model_dir+'non_recur_model_'+store+'_'+state+'.bin'
pickle.dump(m_lgb, open(model_name, 'wb'))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# In[ ]:


dir_ = '/home/artemis/M5/A1-Yeon/' # input only here
dir_ = '../../' # input only here


# #### setting other directory
Expand Down Expand Up @@ -253,7 +253,7 @@ def prepare_data(store, state):
valid_data = lgb.Dataset(grid_df[vl_mask][model_var],
label=grid_df[vl_mask]['sales'])

m_lgb = lgb.train(lgb_params, train_data, valid_sets = [valid_data, train_data], verbose_eval=100)
m_lgb = lgb.train(lgb_params, train_data, valid_sets = [valid_data, train_data])
model_name = model_dir+'non_recur_model_'+store+'_'+state+'.bin'
pickle.dump(m_lgb, open(model_name, 'wb'))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# In[ ]:


dir_ = '/home/artemis/M5/A1-Yeon/' # input only here
dir_ = '../../' # input only here


# #### setting other directory
Expand All @@ -21,7 +21,6 @@
model_dir = dir_+'5. models/'
submission_dir = dir_+'6. submissions/'


# In[ ]:


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# In[ ]:


dir_ = '/home/artemis/M5/A1-Yeon/' # input only here
dir_ = '../../' # input only here


# #### setting other directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# In[ ]:


dir_ = '/home/artemis/M5/A1-Yeon/' # input only here
dir_ = '../../' # input only here


# #### setting other directory
Expand Down
Loading