Kaggle competition: Forest Cover Type Prediction
data_folder = Path(".. /input")
<load_from_csv>
train_dataset=pd.read_csv('/kaggle/input/forest-cover-type-prediction/train.csv')
 test_dataset=pd.read_csv('/kaggle/input/forest-cover-type-prediction/test.csv' )
train_df = pd.read_csv(".. /input/train.csv")
 test_df = pd.read_csv(".. /input/sample_submission.csv" )<choose_model_class>
train_dataset.isnull().sum()
callbacks = [partial(EarlyStoppingCallback, monitor='accuracy', min_delta=0.01, patience=3)]<choose_model_class>
test_dataset.isnull().sum()
learn = cnn_learner(train_img, models.densenet161, metrics=[error_rate, accuracy], callback_fns=callbacks ).mixup().to_fp16()<train_model>
X=train_dataset.drop(labels=['Id','Cover_Type'],axis=1)
 y=train_dataset['Cover_Type']
lr = 1e-02
learn.fit_one_cycle(3, slice(lr), callbacks=[SaveModelCallback(learn, every='improvement', monitor='quadratic_kappa', name='bestmodel')] )<train_model>
from sklearn.model_selection import train_test_split
learn.fit_one_cycle(16, slice(1e-05, 1e-03), callbacks=[SaveModelCallback(learn, every='improvement', monitor='quadratic_kappa', name='bestmodel')] )<categorify>
from sklearn.model_selection import train_test_split
learn.to_fp32()<feature_engineering>
X_train,X_test,y_train,y_test=train_test_split(X,y,random_state=40 )
preds,_ = learn.TTA(ds_type=DatasetType.Test )<filter>
classifier = RandomForestClassifier(n_estimators = 100, criterion = 'entropy', random_state = 0)
 classifier.fit(X_train, y_train)
 y_pred = classifier.predict(X_test)
 acc=accuracy_score(y_test, y_pred)
 print(acc)
test_df.has_cactus = preds.numpy() [:, 0]<save_to_csv>
predict=classifier.predict(test_dataset.drop(labels=['Id'],axis=1))
Submission=pd.DataFrame(data=predict,columns=['Cover_Type'])
 Submission.head()
test_df.to_csv('submission.csv', index=False )<create_dataframe>
Submission['Id']=test_dataset['Id']
Submission.set_index('Id',inplace=True )
<feature_engineering><EOS> 
Submission.to_csv('Submission.csv' )