Kaggle competition: What's Cooking? (Kernels Only)
<SOS> metric: CategorizationAccuracy Kaggle data source: whats-cooking?-(kernels-only)<compute_test_metric>
init_notebook_mode(connected=True)
 %matplotlib inline
color = sns.color_palette()
make_submission(f'final_frunkopt_{path_score(path):.4f}', path )<feature_engineering>
train = pd.read_json('.. /input/train.json')
 test = pd.read_json('.. /input/test.json')
 sub = pd.read_csv('.. /input/sample_submission.csv' )
def factorial(n):
return int(scipy.special.gamma(n+1))<define_variables>
total = train.isnull().sum().sort_values(ascending = False)
 percent =(train.isnull().sum() /train.isnull().count() *100 ).sort_values(ascending = False)
 missing_train_data = pd.concat([total, percent], axis=1, keys=['Total missing', 'Percent missing'])
 missing_train_data.head(20 )
for k in range(8, 21): print(k, factorial(k))<set_options>
total = test.isnull().sum().sort_values(ascending = False)
 percent =(test.isnull().sum() /test.isnull().count() *100 ).sort_values(ascending = False)
 missing_test_data = pd.concat([total, percent], axis=1, keys=['Total missing', 'Percent missing'])
 missing_test_data.head(20 )
!g++ --std=c++17 -Wall -g -Ofast -mtune=native -march=native -fopenmp -DNDEBUG -o dp dp.cc<load_from_csv>
def read_dataset(path):
	return json.load(open(path))
train = read_dataset('.. /input/train.json')
 test = read_dataset('.. /input/test.json')
 def generate_text(data):
	text_data = [" ".join(doc['ingredients'] ).lower() for doc in data]
	return text_data
train_text = generate_text(train)
 test_text = generate_text(test)
 target = [doc['cuisine'] for doc in train]
%%bash
time./dp 18 <.. /input/pseudo-k-opt/1515581.355713272.csv >submission.csv<import_modules>
tfidf = TfidfVectorizer(binary=True)
 def tfidf_features(txt, flag):
if flag == "train":
	x = tfidf.fit_transform(txt)
 else:
	 x = tfidf.transform(txt)
 x = x.astype('float16')
 return x
X = tfidf_features(train_text, flag="train")
 X_test = tfidf_features(test_text, flag="test" )
import time
import pandas as pd
import numpy as np
import sympy as sp
import matplotlib.pyplot as plt
import matplotlib.collections as mcoll
from itertools import chain
from itertools import combinations
from itertools import permutations
from itertools import product
from sklearn.neighbors import NearestNeighbors<load_from_csv>
lb = LabelEncoder()
y = lb.fit_transform(target)
 classifier = SVC(C=100,
	 			 kernel='rbf',
	 			 degree=3,
	 			 gamma=1,
	 			 coef0=1,
	 			 shrinking=True,
	 			 tol=0.001,
	 		 probability=False,
	 		 cache_size=200,
	 		 class_weight=None,
	 		 verbose=False,
	 		 max_iter=-1,
		 decision_function_shape=None,
		 random_state=None)
 model = OneVsRestClassifier(classifier, n_jobs=4)
 model.fit(X, y)
 y_test = model.predict(X_test)
 y_pred = lb.inverse_transform(y_test)
 test_id = [doc['id'] for doc in test]
sub = pd.DataFrame({'id': test_id, 'cuisine': y_pred}, columns=['id', 'cuisine'])
 sub.to_csv('sub1.csv', index=False )