Kaggle competition: Flavours of Physics: Finding τ  →  μμμ
path = '/kaggle/input/covid19-global-forecasting-week-2/'
df_train = pd.read_csv(path+'train.csv')
 df_test = pd.read_csv(path+'test.csv' )<data_type_conversions>
from sklearn.metrics import roc_curve, auc
import xgboost as xgb
df_train['Date'] = pd.to_datetime(df_train['Date'], infer_datetime_format=True)
 df_test['Date'] = pd.to_datetime(df_test['Date'], infer_datetime_format=True )<something_strange>
print('Loading the training/test data using pandas...')
 train = pd.read_csv('.. /input/training.csv')
 test = pd.read_csv('.. /input/test.csv')
 check_agreement = pd.read_csv('.. /input/check_agreement.csv')
 check_correlation = pd.read_csv('.. /input/check_correlation.csv' )
EMPTY_VAL = "EMPTY_VAL"
def fillState(state, country):
if state == EMPTY_VAL: return country
return state<data_type_conversions>
def add_features(df):
df['flight_dist_sig'] = df['FlightDistance']/df['FlightDistanceError']
df['flight_dist_sig2'] =(df['FlightDistance']/df['FlightDistanceError'])**2
df['NEW_IP_dira'] = df['IP']*df['dira']
df['p0p2_ip_ratio']=df['IP']/df['IP_p0p2']
df['p1p2_ip_ratio']=df['IP']/df['IP_p1p2']
df['DCA_MAX'] = df.loc[:, ['DOCAone', 'DOCAtwo', 'DOCAthree']].max(axis=1)
 df['iso_bdt_min'] = df.loc[:, ['p0_IsoBDT', 'p1_IsoBDT', 'p2_IsoBDT']].min(axis=1)
 df['iso_min'] = df.loc[:, ['isolationa', 'isolationb', 'isolationc','isolationd', 'isolatione', 'isolationf']].min(axis=1)
 df['NEW_FD_LT']=df['FlightDistance']/df['LifeTime']
return df
df_train['Province_State'].fillna(EMPTY_VAL, inplace=True)
 df_train['Province_State'] = df_train.loc[:, ['Province_State', 'Country_Region']].apply(lambda x : fillState(x['Province_State'], x['Country_Region']), axis=1)
 df_train.loc[:, 'Date'] = df_train.Date.dt.strftime("%m%d")
 df_train["Date"] = df_train["Date"].astype(int)
 print(df_train.shape)
 df_train.head()<data_type_conversions>
train = add_features(train)
 test = add_features(test)
 check_agreement = add_features(check_agreement)
 check_correlation = add_features(check_correlation )
df_test['Province_State'].fillna(EMPTY_VAL, inplace=True)
 df_test['Province_State'] = df_test.loc[:, ['Province_State', 'Country_Region']].apply(lambda x : fillState(x['Province_State'], x['Country_Region']), axis=1)
 df_test.loc[:, 'Date'] = df_test.Date.dt.strftime("%m%d")
 df_test["Date"] = df_test["Date"].astype(int)
 print(df_test.shape)
 df_test.head()<categorify>
filter_out = ['id','min_ANNmuon', 'production', 'mass', 'signal', 'SPDhits', 'isolationb', 'isolationc', 'DOCAone', 'DOCAtwo', 'DOCAthree','CDF1', 'CDF2', 'CDF3']
features = list(f for f in train.columns if f not in filter_out )
le = preprocessing.LabelEncoder()
df_train['Country_Region'] = le.fit_transform(df_train['Country_Region'])
 df_train['Province_State'] = le.fit_transform(df_train['Province_State'])
 df_test['Country_Region'] = le.fit_transform(df_test['Country_Region'])
 df_test['Province_State'] = le.fit_transform(df_test['Province_State'] )<choose_model_class>
print('Training XGBoost model...')
 model_xgb = xgb.XGBClassifier()
params ={'nthread': 4,
'objective': 'binary:logistic',
'max_depth' : 8,
'min_child_weight': 3,
'learning_rate' : 0.1,
'n_estimators' : 300,
'subsample' : 0.9,
'colsample_bytree' : 0.5,
'silent': 1}
model_xgb.fit(train[features],train.signal )
def build_model_1() :
model = RandomForestRegressor(n_estimators = 100, random_state = 0)
 return model
def build_model_2() :
model = XGBRegressor(n_estimators=1000)
 return model
def build_model_3() :
model = DecisionTreeRegressor(random_state=1)
 return model
def build_model_4() :
model = LogisticRegression()
return model
def build_model_5() :
model = LinearRegression()
return model
def build_model_6() :
model = LGBMRegressor(random_state=5)
 return model
def build_model_7() :
model = LGBMRegressor(iterations=2)
 return model 
<create_dataframe>
pred_test = model_xgb.predict_proba(test[features])[:,1]
result = pd.DataFrame({'id': test.id})
 result['prediction'] = pred_test
<prepare_x_and_y><EOS> 
result.to_csv('submission_nacho.csv', index=False, sep=',' )