Kaggle competition: What's Cooking? (Kernels Only)
<SOS> metric: CategorizationAccuracy Kaggle data source: whats-cooking?-(kernels-only)<define_variables>
import numpy as np
import pandas as pd
data_folder = Path(".. /input" )<load_from_csv>
df1 = pd.read_json('.. /input/train.json')
 df2 = pd.read_json('.. /input/test.json' )
train_df = pd.read_csv(".. /input/train.csv")
 test_df = pd.read_csv(".. /input/sample_submission.csv" )<define_variables>
df1['ingredients1'] = df1['ingredients'].apply(','.join)
 df2['ingredients2'] = df2['ingredients'].apply(','.join )
train_image_list_bunch.show_batch(rows=4, figsize=(7,6))<choose_model_class>
vector = TfidfVectorizer(binary=True ).fit(df1['ingredients1'].values)
 X_train = vector.transform(df1['ingredients1'].values)
 X_train = X_train.astype('float')
 X_test = vector.transform(df2['ingredients2'].values)
 X_test = X_test.astype('float' )
learn = cnn_learner(train_image_list_bunch, models.densenet161, metrics=[error_rate, accuracy] )<find_best_params>
lb = LabelEncoder()
y_train = lb.fit_transform(df1.cuisine )
learn.lr_find()
learn.recorder.plot()<train_model>
dtc = DecisionTreeClassifier()
lr = 1e-01
learn.fit_one_cycle(5, slice(lr))<predict_on_test>
xx = X_train.todense()
preds,_ = learn.get_preds(ds_type=DatasetType.Test )<filter>
dtc.fit(X_train, y_train )
test_df.has_cactus = preds.numpy() [:, 0]<save_to_csv>
test_df.to_csv('submission.csv', index=False )<install_modules>
!pip install pytorchcv<import_modules>
xx_test = X_test.todense()
import numpy as np
import pandas as pd
from pytorchcv.model_provider import get_model as ptcv_get_model
from pathlib import Path
from fastai import *
from fastai.vision import *
import torch<load_from_csv>
y_pred = dtc.predict(X_test )
<choose_model_class><EOS> 
y_pred_ = lb.inverse_transform(y_pred)
 submission = pd.DataFrame({"id": df2["id"], "cuisine": y_pred_})
 submission.to_csv('submission.csv', index = False )