Kaggle competition: Otto Group Product Classification Challenge
<SOS> metric: MulticlassLoss Kaggle data source: otto-group-product-classification-challenge<install_modules>
train = pd.read_csv('.. /input/otto-group-product-classification-challenge/train.csv')
 test = pd.read_csv('.. /input/otto-group-product-classification-challenge/test.csv')
 sampleSubmission = pd.read_csv('.. /input/otto-group-product-classification-challenge/sampleSubmission.csv')
 train.shape, test.shape
!pip install --no-index --find-links /tmp/pip/cache-transformers/ transformers<set_options>
train["target"] = train["target"].str.replace('Class_', '')
 train["target"] = train["target"].astype(int)- 1
X_train = train.drop(['id','target'] , axis=1)
 y_train = train["target"]
X_test = test.drop('id', axis=1 )
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath("__file__")))+"/input/tsepipeline/TSE-kaggle/input/src")
 pd.set_option("display.max_rows", 1000)
 pd.set_option("display.max_colwidth", 1000 )<define_variables>
y_pred = np.zeros(( len(X_test), 9))
models = []
oof_train = np.zeros(( len(X_train),9))
SENTIMENT_COMB = {
'pos':['positive'],
'neg':['negative'],
'neu':['neutral'],
'png':['positive','negative'],
'pnu':['neutral','positive'],
'nng':['neutral','negative'],
'pnn':['positive','negative','neutral'],
}<import_modules>
NFOLDS = 5
cv = KFold(n_splits=NFOLDS, shuffle=True, random_state=0)
 params = {
'objective': 'multiclass',
'num_class': 9,
}
for fold_id,(train_index, valid_index)in enumerate(cv.split(X_train)) :
X_tr = X_train.loc[train_index, :]
X_val = X_train.loc[valid_index, :]
y_tr = y_train[train_index].astype(int)
 y_val = y_train[valid_index].astype(int)
 lgb_train = lgb.Dataset(X_tr, y_tr)
 lgb_eval = lgb.Dataset(X_val, y_val)
 model = lgb.train(params, lgb_train,
valid_sets=[lgb_train, lgb_eval],
verbose_eval=10,
num_boost_round=1000,
early_stopping_rounds=10)
 oof_train[valid_index] = model.predict(X_val, num_iteration=model.best_iteration)
 y_pred += model.predict(X_test, num_iteration=model.best_iteration)/NFOLDS
<define_variables><EOS> 
submit = pd.concat([sampleSubmission[['id']], pd.DataFrame(y_pred)], axis = 1)
 submit.columns = sampleSubmission.columns
submit.to_csv('submit.csv', index=False )