Kaggle competition: What's Cooking? (Kernels Only)
dataset_sctp_train.target.value_counts()<data_type_conversions>
train_df = pd.read_json(".. /input/train.json")
 test_df = pd.read_json(".. /input/test.json" )
y = dataset_sctp_train['target']
X = dataset_sctp_train.drop(['ID_code', 'target'], axis=1)
 X.astype('float32')
 dataset_sctp_test_ID_code = dataset_sctp_test['ID_code']
Z = dataset_sctp_test.drop(['ID_code'], axis=1)
 Z.astype('float32')
(X.shape, y.shape, Z.shape )<drop_column>
Y_train = train_df["cuisine"].apply(lambda x: x.lower())
 X_train = train_df["ingredients"].apply(lambda x: ' '.join(lemmatizer.lemmatize(unidecode.unidecode(i)) for i in x ).strip().lower())
 test_data = test_df["ingredients"].apply(lambda x: ' '.join(lemmatizer.lemmatize(unidecode.unidecode(i)) for i in x ).strip().lower())
 k = Y_train.nunique()
columnsWithZeroStdToRemove = getZeroStdColumns(X)
 print(f'Columns with Zero STD to drop from Train and Test dataset(s)are {columnsWithZeroStdToRemove}.')
 X.drop(columnsWithZeroStdToRemove, axis=1, inplace=True)
 Z.drop(columnsWithZeroStdToRemove, axis=1, inplace=True)
(X.shape, Z.shape )<count_values>
encoder = LabelEncoder()
y_target = encoder.fit_transform(Y_train )
n_cpus_avaliable = multiprocessing.cpu_count()
print(f'We've got {n_cpus_avaliable} cpus to work with.' )<count_duplicates>
vectorizer = TfidfVectorizer(binary = True)
 x = vectorizer.fit_transform(X_train.values)
 x_test = vectorizer.transform(test_data.values )
def augment(x, y, t=2): 
(xs, xn)=([], [])
 for i in range(t):
mask = y > 0
x1 = x[mask].copy()
ids = np.arange(x1.shape[0])
 for c in range(x1.shape[1]):
np.random.shuffle(ids)
 x1[:, c] = x1[ids][:, c]
xs.append(x1)
 for i in range(t // 2):
mask = y == 0
x1 = x[mask].copy()
ids = np.arange(x1.shape[0])
 for c in range(x1.shape[1]):
np.random.shuffle(ids)
 x1[:, c] = x1[ids][:, c]
xn.append(x1)
 xs = np.vstack(xs)
 xn = np.vstack(xn)
 ys = np.ones(xs.shape[0])
 yn = np.zeros(xn.shape[0])
 x = np.vstack([x, xs, xn])
 y = np.concatenate([y, ys, yn])
 return(x, y )<init_hyperparams>
model = SVC(C=270, kernel='rbf', degree=3, gamma=1.3, coef0=1.0, shrinking=True, tol=0.001, probability=True, cache_size=500, max_iter=-1)
 ovr = OneVsRestClassifier(model, n_jobs=1)
 ovr.fit(x, y_target)
 ovr_pred = ovr.predict(x_test)
 y_test = encoder.inverse_transform(ovr_pred)
 test_id = test_df["id"]
submit_cook = pd.DataFrame({'id': test_id, 'cuisine': y_test}, columns=['id', 'cuisine'])
 submit_cook.to_csv('svc_tf.csv', index=False )
<predict_on_test><EOS> 
model = xgboost.XGBClassifier(max_depth = 9, eta = 0.003, subsample = 0.7, gamma = 7)
 ovr = OneVsRestClassifier(model, n_jobs = -1)
 ovr.fit(x, y_target)
 ovr_pred = ovr.predict(x_test)
 y_test = encoder.inverse_transform(ovr_pred)
 test_id = test_df["id"]
submit_xg = pd.DataFrame({'id': test_id, 'cuisine': y_test}, columns=['id', 'cuisine'])
 submit_xg.to_csv('xgboost_tf.csv', index=False )