Kaggle competition: Titanic - Machine Learning from Disaster
<SOS> metric: categorizationaccuracy Kaggle data source: titanic-machine-learning-from-disaster<count_values>
warnings.filterwarnings("ignore" )
train_women = train_df.split_category_0.value_counts() ['Women']<filter>
traindata = pd.read_csv('/kaggle/input/titanic/train.csv')
 testdata = pd.read_csv('/kaggle/input/titanic/test.csv' )
submit_index = category_index[train_women:]<split>
le = LabelEncoder()
traindata['Sex'] = le.fit_transform(traindata['Sex'])
 testdata['Sex'] = le.fit_transform(testdata['Sex'])
 traindata['Embarked'] = le.fit_transform(traindata['Embarked'].astype(str))
testdata['Embarked'] = le.fit_transform(testdata['Embarked'].astype(str))
X_train = X_data[:train_women]
X_submit = X_data[train_women:]<choose_model_class>
X = traindata[['Pclass','Sex','Age','Fare','Parch','SibSp','Embarked']].values
y = traindata.iloc[:,1].values
X_real_test = testdata[['Pclass','Sex','Age','Fare','Parch','SibSp','Embarked']].values
ridge = Ridge(alpha=3.1 )<train_model>
print(traindata.isnull().sum() )
ridge.fit(X_train, y_train )<predict_on_test>
imputer = SimpleImputer()
X_transformed = imputer.fit_transform(X)
 X_real_test = imputer.fit_transform(X_real_test )
price = np.expm1(ridge.predict(X_submit))<prepare_output>
X_train, X_test, y_train, y_test = train_test_split(X_transformed,y,test_size=0.25,random_state=1313 )
submit_df = pd.DataFrame(submit_index)
 submit_df = pd.concat([submit_df, pd.DataFrame(price)], axis=1)
 submit_df.columns = ['test_id', 'price']
submit_df.head()<string_transform>
sc = StandardScaler()
X_train = sc.fit_transform(X_train)
 X_test = sc.fit_transform(X_test)
 X_real_test = sc.fit_transform(X_real_test )
category_df = train_test_df[train_test_df.split_category_0 == 'Beauty']<prepare_output>
classifier = SVC(kernel='rbf',random_state=0)
 classifier.fit(X_train,y_train)
 y_pred = classifier.predict(X_test)
 cm = confusion_matrix(y_test,y_pred)
 print(cm )
<feature_engineering><EOS> 
y_pred_test = classifier.predict(X_real_test)
 pid = testdata[['PassengerId']].values
res = np.expand_dims(y_pred_test,axis=1)
 f = np.hstack(( pid,res))
df = pd.DataFrame(f, columns = ['PassengerId', 'Survived'])
 df.to_csv('gender_submission.csv', index=False )