Kaggle competition: Cassava Leaf Disease Classification
<SOS> metric: CategorizationAccuracy Kaggle data source: cassava-leaf-disease-classification<prepare_x_and_y>
path = Path('.. /input/cassava-leaf-disease-classification' )
y=np.log(train["count"])
 y.head()<drop_column>
train_df = pd.read_csv(path/'train.csv')
 train_df = train_df[~train_df['image_id'].isin(['1562043567.jpg', '3551135685.jpg', '2252529694.jpg'])]
train_df.head()
train=train.drop(["datetime","casual","registered","count"],1)
 train.head()<drop_column>
item_tfms = RandomResizedCrop(460, min_scale=0.75, ratio=(1.,1.))
 batch_tfms = [*aug_transforms(size=384, max_warp=0), Normalize.from_stats(*imagenet_stats)]
bs=16
test=test.drop(["datetime"],1)
 test.head()<train_model>
def get_x(r):
return path/'train_images'/r['image_id']
def get_y(r):
return r['label']
lgb=LGBMRegressor()
lgb.fit(train,y )<load_from_csv>
pets = DataBlock(blocks=(ImageBlock, CategoryBlock),
get_x=get_x,
get_y=get_y,
splitter=RandomSplitter(0.2, seed=42),
item_tfms=item_tfms,
batch_tfms=batch_tfms)
 dataloader = pets.dataloaders(train_df, bs=bs )
sub=pd.read_csv("/kaggle/input/bike-sharing-demand/sampleSubmission.csv")
 sub.head()<predict_on_test>
dataloader.show_batch()
sub["count"]=np.exp(lgb.predict(test))
sub.head()<save_to_csv>
learn = cnn_learner(dataloader, resnet50,
loss_func = LabelSmoothingCrossEntropy() ,
cbs=[MixUp() ],
metrics=[error_rate,accuracy])
 learn.fine_tune(8,freeze_epochs = 2,base_lr=1e-2 )
sub.to_csv("20190921.csv",index=False )<set_options>
learn = learn.to_native_fp32()
%matplotlib inline
mpl.rcParams['axes.unicode_minus']=False
warnings.filterwarnings('ignore' )<load_from_csv>
sample_df = pd.read_csv(path/'sample_submission.csv')
 sample_df.head()
train=pd.read_csv(".. /input/bike-sharing-demand/train.csv", parse_dates=["datetime"])
 train.shape 
<load_from_csv>
test_data_path = sample_df['image_id'].apply(lambda x: path/'test_images'/x)
 tst_dl = learn.dls.test_dl(test_data_path)
 predictions = learn.tta(dl = tst_dl, n=10)
test=pd.read_csv(".. /input/bike-sharing-demand/test.csv", parse_dates=["datetime"])
 test.shape<feature_engineering>
sample_df['label'] = np.argmax(predictions[0],axis=1)
 sample_df
<feature_engineering><EOS> 
sample_df.to_csv('submission.csv',index=False )