Kaggle competition: M5 Forecasting - Accuracy
CLASS = ['Black-grass', 'Charlock', 'Cleavers', 'Common Chickweed', 'Common wheat', 'Fat Hen', 'Loose Silky-bent',
'Maize', 'Scentless Mayweed', 'Shepherds Purse', 'Small-flowered Cranesbill', 'Sugar beet']<define_variables>
poisson = pd.read_csv('/kaggle/input/m5-first-public-notebook-under-0-50/submission.csv')
 tweedie = pd.read_csv('/kaggle/input/m5-accuracy-tweedie-is-back/submission.csv')
 best_score = pd.read_csv('/kaggle/input/m5-accuracy-poisson-tweedie/submission(14 ).csv')
 Rv2 = pd.read_csv('/kaggle/input/m5-forecaster-v2/sub_dt_lgb.csv')
 lig = pd.read_csv('/kaggle/input/m5-forecasting-lightgbm/submission(11 ).csv' )
train_dir = '.. /input/train'
test_dir = '.. /input/test'
train_Blackgrass = ['.. /input/train/Black-grass/{}'.format(i)for i in os.listdir(os.path.join(train_dir, 'Black-grass')) ]
train_Charlock = ['.. /input/train/Charlock/{}'.format(i)for i in os.listdir(os.path.join(train_dir, 'Charlock')) ]
train_Cleavers = ['.. /input/train/Cleavers/{}'.format(i)for i in os.listdir(os.path.join(train_dir, 'Cleavers')) ]
train_CommonChickweed = ['.. /input/train/Common Chickweed/{}'.format(i)for i in os.listdir(os.path.join(train_dir, 'Common Chickweed')) ]
train_Commonwheat = ['.. /input/train/Common wheat/{}'.format(i)for i in os.listdir(os.path.join(train_dir, 'Common wheat')) ]
train_FatHen = ['.. /input/train/Fat Hen/{}'.format(i)for i in os.listdir(os.path.join(train_dir, 'Fat Hen')) ]
train_LooseSilkybent = ['.. /input/train/Loose Silky-bent/{}'.format(i)for i in os.listdir(os.path.join(train_dir, 'Loose Silky-bent')) ]
train_Maize = ['.. /input/train/Maize/{}'.format(i)for i in os.listdir(os.path.join(train_dir, 'Maize')) ]
train_ScentlessMayweed = ['.. /input/train/Scentless Mayweed/{}'.format(i)for i in os.listdir(os.path.join(train_dir, 'Scentless Mayweed')) ]
train_ShepherdsPurse = ['.. /input/train/Shepherds Purse/{}'.format(i)for i in os.listdir(os.path.join(train_dir, 'Shepherds Purse')) ]
train_SmallfloweredCranesbill = ['.. /input/train/Small-flowered Cranesbill/{}'.format(i)for i in os.listdir(os.path.join(train_dir, 'Small-flowered Cranesbill')) ]
train_Sugarbeet = ['.. /input/train/Sugar beet/{}'.format(i)for i in os.listdir(os.path.join(train_dir, 'Sugar beet')) ]
test_imgs = ['.. /input/test/{}'.format(i)for i in os.listdir(test_dir)]
train_imgs = train_Blackgrass + train_Charlock + train_Cleavers + train_CommonChickweed + train_Commonwheat + train_FatHen + train_LooseSilkybent + \
train_Maize + train_ScentlessMayweed + train_ShepherdsPurse + train_SmallfloweredCranesbill+ train_Sugarbeet
random.shuffle(train_imgs)
 test_imgs<prepare_x_and_y>
poisson = poisson.sort_values(by = 'id' ).reset_index(drop = True)
 tweedie = tweedie.sort_values(by = 'id' ).reset_index(drop = True)
 Rv2 = Rv2.sort_values(by = 'id' ).reset_index(drop = True)
 best_score = best_score.sort_values(by = 'id' ).reset_index(drop = True)
 lig = lig.sort_values(by = 'id' ).reset_index(drop = True)
 sub = poisson.copy()
for i in sub.columns :
if i != 'id' :
sub[i] = 0.5 * best_score[i] + 0.3 * tweedie[i] + 0.2 * poisson[i]
sub.to_csv('submission.csv', index = False)
 sub.head()
nrows = 150
ncolumns = 150
channels = 3
def read_and_process_image(list_of_images):

 X = []
y = []
for image in list_of_images:
X.append(cv2.resize(cv2.imread(image, cv2.IMREAD_COLOR),(nrows,ncolumns), interpolation=cv2.INTER_CUBIC))
if image.split('/')[3] == 'Black-grass':
y.append(0)
 elif image.split('/')[3] == 'Charlock':
y.append(1)
 elif image.split('/')[3] == 'Cleavers':
y.append(2)
 elif image.split('/')[3] == 'Common Chickweed':
y.append(3)
 elif image.split('/')[3] == 'Common wheat':
y.append(4)
 elif image.split('/')[3] == 'Fat Hen':
y.append(5)
 elif image.split('/')[3] == 'Loose Silky-bent':
y.append(6)
 elif image.split('/')[3] == 'Maize':
y.append(7)
 elif image.split('/')[3] == 'Scentless Mayweed':
y.append(8)
 elif image.split('/')[3] == 'Shepherds Purse':
y.append(9)
 elif image.split('/')[3] == 'Small-flowered Cranesbill':
y.append(10)
 elif image.split('/')[3] == 'Sugar beet':
y.append(11)
 return X, y<prepare_x_and_y>
poisson = pd.read_csv('/kaggle/input/m5-first-public-notebook-under-0-50/submission.csv')
 tweedie = pd.read_csv('/kaggle/input/m5-accuracy-tweedie-is-back/submission.csv')
 best_score = pd.read_csv('/kaggle/input/m5-accuracy-poisson-tweedie/submission(14 ).csv')
 Rv2 = pd.read_csv('/kaggle/input/m5-forecaster-v2/sub_dt_lgb.csv')
 lig = pd.read_csv('/kaggle/input/m5-forecasting-lightgbm/submission(11 ).csv' )
<train_model><EOS> 
poisson = poisson.sort_values(by = 'id' ).reset_index(drop = True)
 tweedie = tweedie.sort_values(by = 'id' ).reset_index(drop = True)
 Rv2 = Rv2.sort_values(by = 'id' ).reset_index(drop = True)
 best_score = best_score.sort_values(by = 'id' ).reset_index(drop = True)
 lig = lig.sort_values(by = 'id' ).reset_index(drop = True)
 sub = poisson.copy()
for i in sub.columns :
if i != 'id' :
sub[i] = 0.5 * best_score[i] + 0.3 * tweedie[i] + 0.2 * poisson[i]
sub.to_csv('submission.csv', index = False)
 sub.head()