Kaggle competition: What's Cooking? (Kernels Only)
seed = 2357
random.seed(seed )<load_from_csv>
train = pd.read_json(".. /input/train.json")
 test = pd.read_json(".. /input/test.json")
 print(train.head())
 ytrain = train.cuisine
print(ytrain.head(5))
Id = test.id
print(Id.head(5))
train_df = pd.read_csv('.. /input/santander-customer-transaction-prediction/train.csv')
 test_df = pd.read_csv('.. /input/santander-customer-transaction-prediction/test.csv' )<load_pretrained>
from sklearn.feature_extraction.text import TfidfVectorizer
index_f_data = np.load('.. /input/split-test-dataset/index_of_fake_data.npy')
 index_r_data = np.load('.. /input/split-test-dataset/index_of_real_data.npy' )<load_from_csv>
tfidf = TfidfVectorizer(binary=True )
fold_information = pd.read_csv(".. /input/fold-information/10_fold_information.csv" )<data_type_conversions>
train_tfidf_features = tfidf.fit_transform(arraytotext(train.ingredients))
test_tfidf_features= tfidf.transform(arraytotext(test.ingredients))
splits=[]
for i in fold_information.columns:
a = np.array(list(set(train_df.index)-set(list(fold_information[i].dropna()))))
a.sort()
splits.append(( np.array(fold_information[i].dropna().astype(int)) ,a))<set_options>
from sklearn.multiclass import OneVsRestClassifier
from sklearn.svm import SVC
from sklearn.model_selection import cross_val_score
del fold_information
del a
gc.collect()<drop_column>
classifier = SVC(C=200, 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 )
train_features = train_df.drop(['target','ID_code'], axis = 1)
 test_features = test_df.drop(['ID_code'],axis = 1)
 train_target = train_df['target']<prepare_x_and_y>
model = OneVsRestClassifier(classifier )
fake_data = test_features.iloc[index_f_data]
real_data = test_features.iloc[index_r_data]<concatenate>
scores = cross_val_score(classifier,train_tfidf_features, ytrain, cv=5)
 print("Accuracy: %0.2f(+/- %0.2f)" %(scores.mean() , scores.std() * 2))
train_all_real = pd.concat([train_features,real_data], axis = 0 )<count_duplicates>
model.fit(train_tfidf_features, ytrain )
for f in train_all_real.columns[0:200]:
train_all_real[f+'duplicate'] = train_all_real.duplicated(f,False ).astype(int )<categorify>
predictions = model.predict(test_tfidf_features)
 print(predictions )
<feature_engineering><EOS> 
submission = pd.DataFrame()
submission['id'] = Id
submission['cuisine'] = predictions
submission.to_csv('submissionSVM.csv', index=False )