Kaggle competition: Jane Street Market Prediction
train["Country/State"].loc[train["Country/State"] == "Taiwan*"] = "Taiwan"
test["Country/State"].loc[test["Country/State"] == "Taiwan*"] = "Taiwan"
train = train.drop(columns = ["Date"])
 test = test.drop(columns = ["Date"])
 countriesorstates = train["Country/State"].unique()
print(countriesorstates )<prepare_x_and_y>
warnings.filterwarnings("ignore")
 VERSION = ''
random_picks = random.choices(countriesorstates, k = 9)
 for value in random_picks:
train_temp = train.loc[train["Country/State"] == value]
test_temp = test.loc[test["Country/State"] == value]
train_temp_cc = train_temp["ConfirmedCases"].loc[train["Country/State"] == value]
train_temp_ft = train_temp["Fatalities"].loc[train["Country/State"] == value]
train_temp_X = train_temp.iloc[:, 5]
test_temp_X = test_temp.iloc[:, 3]
x = train_temp_X.to_numpy(dtype = float)
 y_1 = train_temp_cc.to_numpy(dtype = float)
 y_2= train_temp_ft.to_numpy(dtype = float)
 x = x.reshape(-1,)
 plt.plot(x, y_1, color ='red', label = value)
 plt.xlabel("No.of days")
 plt.ylabel('Confirmed cases')
 plt.legend()
plt.title("Place: " + value)
 plt.show()
plt.plot(x, y_2, color ='black', label = value)
 plt.xlabel("No.of days")
 plt.ylabel('Fatalities')
 plt.legend()
plt.title("Place: " + value)
 plt.show()<create_dataframe>
SEED = 420
N_ESTIMATORS = 250
DEVICE = torch.device("cpu" )
poly_reg_cc = PolynomialFeatures(degree = 4)
 poly_reg_ft = PolynomialFeatures(degree = 4)
 reg_cc = LinearRegression()
reg_ft = LinearRegression()
sub = pd.DataFrame({'ForecastId': [], 'ConfirmedCases': [], 'Fatalities': []})
 for value in countriesorstates:
train_temp = train.loc[train["Country/State"] == value]
test_temp = test.loc[test["Country/State"] == value]
train_temp_cc = train_temp["ConfirmedCases"].loc[train["Country/State"] == value].to_frame()
train_temp_ft = train_temp["Fatalities"].loc[train["Country/State"] == value].to_frame()
train_temp_X = train_temp.iloc[:, 4:6]
test_temp_X = test_temp.iloc[:, 2:4]
sc1 = StandardScaler()
train_temp_X = sc1.fit_transform(train_temp_X)
 test_temp_X = sc1.transform(test_temp_X)
 sc_cc = StandardScaler()
sc_ft = StandardScaler()
train_temp_cc = sc_cc.fit_transform(train_temp_cc)
 train_temp_ft = sc_ft.fit_transform(train_temp_ft)
 X_poly = poly_reg_cc.fit_transform(train_temp_X)
 reg_cc.fit(X_poly, train_temp_cc)
 test_cc = sc_cc.inverse_transform(reg_cc.predict(poly_reg_cc.fit_transform(test_temp_X)))
 X_poly = poly_reg_ft.fit_transform(train_temp_X)
 reg_ft.fit(X_poly, train_temp_ft)
 test_ft = sc_ft.inverse_transform(reg_ft.predict(poly_reg_ft.fit_transform(test_temp_X)))
 a = int(train["No.of days"].loc[train["Country/State"] == "India"].max())
 b = int(a - test_temp["No.of days"].min())
 test_cc[0:b+1] = sc_cc.inverse_transform(train_temp_cc)[(a-b-1):(a)]
test_ft[0:b+1] = sc_ft.inverse_transform(train_temp_ft)[(a-b-1):(a)]
test_cc = test_cc.flatten()
test_ft = test_ft.flatten()
sub_temp = pd.DataFrame({'ForecastId': test_temp["ForecastId"].loc[test["Country/State"] == value],
'ConfirmedCases': test_cc, 'Fatalities': test_ft})
 sub = pd.concat([sub, sub_temp], axis = 0 )<save_to_csv>
CV_SCORERS = {
'precision_score': make_scorer(precision_score),
'recall_score': make_scorer(recall_score),
'f1_score': make_scorer(f1_score),
'balanced_accuracy_score': make_scorer(balanced_accuracy_score)
 }
sub.ForecastId = sub.ForecastId.astype('int')
 for i in range(len(sub)) :
sub["ConfirmedCases"][i] = int(round(sub["ConfirmedCases"][i]))
sub["Fatalities"][i] = int(round(sub["Fatalities"][i]))
sub.to_csv("submission.csv", index = False )<import_modules>
def pickleSave(obj, file):
if VERSION != '':
file, ext = os.path.splitext(file)
 file += "_v" + str(VERSION)+ ext
dirs = os.path.dirname(file)
 if dirs:
os.makedirs(dirs, exist_ok=True)
 with open(file, 'wb')as f:
pickle.dump(obj, f)
 return
def unpickle(file):
if VERSION != '':
file, ext = os.path.splitext(file)
 file += "_v" + str(VERSION)+ ext
return pickle.load(open(file, 'rb'))
from pandas_profiling import ProfileReport<load_from_csv>
class Best_clf_cv_transformer(BaseEstimator, TransformerMixin):
def __init__(self, myparams={'name':'LSvc', 'C':1}, **other_params):
self.myparams = myparams
self.myinit(**other_params)
 return
def myinit(self, **other_params):
self.cv = 5
if 'cv' in self.myparams:
self.cv= self.myparams['cv']
clf = None
name = self.myparams['name']
if name == 'Logit':
clf = LogisticRegression(random_state=0)
 elif name == 'DT':
clf = DecisionTreeClassifier(random_state=0)
 elif name == 'RidgClf':
clf = RidgeClassifier(random_state=0)
 elif name == 'Prcpt':
clf = Perceptron(random_state=0)
 elif name == 'PssAggClf':
clf = PassiveAggressiveClassifier(random_state=0)
 elif name == 'Knn':
clf = KNeighborsClassifier(random_state=0)
 elif name == 'RF':
clf = RandomForestClassifier(random_state=0)
 elif name == 'NearCent':
clf = NearestCentroid(random_state=0)
 elif name == 'MultNB':
clf = MultinomialNB(random_state=0)
 elif name == 'BernNB':
clf = BernoulliNB(random_state=0)
 elif name == 'Svc':
clf = SVC(probability=True, random_state=0)
 elif name == 'LSvc':
clf = LinearSVC(random_state=0)
 elif name == 'Xgb':
clf = xgb.XGBClassifier(random_state=0)
 elif name == 'Catb' :
clf = CatBoostClassifier(verbose=False, random_state=0)
 elif name == 'FCNN':
clf = None
else:
print('ERROR Best_clf_cv_transformer: invalid @param name
')
 clf = None
self.isCV = True
if 'isCV' in self.myparams:
self.isCV = self.myparams['isCV']
self.n_estimators = 1
if 'n_estimators' in self.myparams:
self.n_estimators = self.myparams['n_estimators']
if 'params' in self.myparams:
clf.set_params(**self.myparams['params'])
 if other_params:
clf.set_params(**other_params)
 self.param_grid = None
if 'param_grid' in self.myparams:
self.param_grid = self.myparams['param_grid']
self.clf = clf
self.cv_score = 0
self.name = name
self._estimator_type='classifier'
return
def fit(self, X, Y, **FIT_PARAMS):
train_len = len(Y[pd.isnull(Y)==False])
 X, Y = X[:train_len], Y[:train_len]
print('training', self.name, 'for X.shape =', X.shape)
 n_jobs = -1
if self.name == 'FCNN':
lrScheduler = LRScheduler(
 CyclicLR,
base_lr=0.0001,
max_lr=0.05,
step_every='batch' 
)
 self.clf = NeuralNetClassifier(
 module=MyModule,
module__inputCount=X.shape[1],
module__outputCount=2,
module__hiddenLayerCounts=[15],
max_epochs=1000,
verbose=0,
iterator_train__shuffle=True,
callbacks=[('LRScheduler', lrScheduler),('EarlyStopping', EarlyStopping(patience=20)) ] 
)
 X = X.astype(np.float32)
 Y = Y.astype(np.int64)
 n_jobs = None
if self.isCV:
if self.param_grid:
gridSearchCV = GridSearchCV(
 self.clf, self.param_grid, iid=False, cv=self.cv, scoring=CV_SCORERS,
refit='f1_score', n_jobs=n_jobs 
)
 gridSearchCV.fit(X, Y)
 print(self.name, ": Best_clf_cv_transformer: Best parameter(CV score=%0.3f):" % gridSearchCV.best_score_)
 print(gridSearchCV.best_params_)
 self.clf = gridSearchCV.best_estimator_
self.cv_score = gridSearchCV.best_score_
if self.name == 'LSvc':
self.clf = CalibratedClassifierCV(self.clf)
 else:
if self.name == 'LSvc':
self.clf = CalibratedClassifierCV(self.clf)
 print(self.name, ': Best_clf_cv_transformer: starting CV =', self.cv)
 if self.name not in {'fss'}:
cv_results = cross_validate(self.clf, X, Y, cv=int(self.cv))
else:
voting_clf = VotingClassifier(estimators=[(self.name, self.clf)])
 cv_results = cross_validate(voting_clf, X, Y, cv=self.cv)
 self.cv_score = np.mean(cv_results['test_score'])
 print(self.name, ": cv_score: %0.3f" % self.cv_score)
 else:
if self.name == 'LSvc':
self.clf = CalibratedClassifierCV(self.clf)
 if self.n_estimators > 1:
self.clf = BaggingClassifier(base_estimator=self.clf, n_estimators=self.n_estimators)
 self.clf.fit(X, Y)
 print("Done Fitting", self.name)
 return self
def get_cv_score(self):
return self.cv_score
def transform(self, X, Y=None, **FIT_PARAMS):
if self.name == 'FCNN':
X = X.astype(np.float32)
 if not Y is None:
Y = Y.astype(np.int64)
 return self.clf.transform(X, Y)
 def predict(self, X, **FIT_PARAMS):
if self.name == 'FCNN':
X = X.astype(np.float32)
 return self.clf.predict(X)
 def predict_proba(self, X):
if self.name == 'FCNN':
X = X.astype(np.float32)
 return self.clf.predict_proba(X)
 def predict_log_proba(self, X):
if self.name == 'FCNN':
X = X.astype(np.float32)
 return self.clf.predict_log_proba(X)
 def score(self, X, Y, **FIT_PARAMS):
if self.name == 'FCNN':
X = X.astype(np.float32)
 return self.clf.score(X, Y, **FIT_PARAMS)
 def decision_function(self, X, **FIT_PARAMS):
if self.name == 'FCNN':
X = X.astype(np.float32)
 return self.clf.decision_function(X)
 def set_params(self, **params):
self.myparams = params['myparams']
params.pop('myparams')
 self.myinit(**params)
 return self
def get_params(self, deep=True):
params = {'myparams': self.myparams}
return params
def apply(self, X):
return self.clf.apply(X)
 def decision_path(self, X):
return self.clf.decision_path(X)
 def staged_decision_function(self, X):
return self.clf.staged_decision_function(X)
 def staged_predict(self, X):
return self.clf.staged_predict(X)
 def staged_predict_proba(self, X):
return self.clf.staged_predict_proba(X)
 def staged_score(self, X):
return self.clf.staged_score(X )
xtrain = pd.read_csv('/kaggle/input/covid19-global-forecasting-week-4/train.csv')
 xtest = pd.read_csv('/kaggle/input/covid19-global-forecasting-week-4/test.csv')
 xsubmission = pd.read_csv('/kaggle/input/covid19-global-forecasting-week-4/submission.csv' )<create_dataframe>
def seed_all() :
random.seed(SEED)
 np.random.seed(SEED)
 random.seed(SEED)
 seed_all()
train_profile = ProfileReport(xtrain, title='Pandas Profiling Report', html={'style':{'full_width':True}})
 train_profile<prepare_x_and_y>
def load_preprocess_data(filename='.. /input/jane-street-market-prediction/train.csv', isTrainData=True):
dtype = None
if isTrainData:
dtype = {
'date' : 'int64',
'weight' : 'float64',
'resp' : 'float64',
'ts_id' : 'int64',
'feature_0' : 'float64'
}
else:
dtype = {
'date' : 'int64',
'weight' : 'float64',
'feature_0' : 'float64'
}
for i in range(1, 130):
k = 'feature_' + str(i)
 dtype[k] = 'float32'
X = pd.read_csv(filename, dtype=dtype)
 resp_cols = ['resp_1', 'resp_2', 'resp_3','resp_4', 'resp']
X = X.query('date > 85')
 X = X[X['weight'] != 0].reset_index(drop = True)
 y = np.stack([(X[c] > 0 ).astype('int')for c in resp_cols] ).T
f_columns = [c for c in X.columns if "feature" in c]
Weights = X['weight'].values.reshape(( -1,1))
if isTrainData:
X.drop(columns=['date', 'weight', 'resp', 'resp_1', 'resp_2', 'resp_3', 'resp_4', 'ts_id'], inplace=True)
 else:
X.drop(columns=['date', 'weight'], inplace=True)
 preprocess_pipe = Pipeline([ 
("imputer", SimpleImputer(missing_values=np.nan, strategy='mean')) ,
])
 X = preprocess_pipe.fit_transform(X)
 X = np.hstack(( X, Weights))
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.05)
 del X, y
gc.collect()
W_train = X_train[:, -1]
X_train = X_train[:, :-1]
W_test = X_test[:, -1]
X_test = X_test[:, :-1]
return X_train, X_test, y_train, y_test, W_train, W_test, preprocess_pipe
xtrain.rename(columns={'Country_Region':'Country'}, inplace=True)
 xtest.rename(columns={'Country_Region':'Country'}, inplace=True)
 xtrain.rename(columns={'Province_State':'State'}, inplace=True)
 xtest.rename(columns={'Province_State':'State'}, inplace=True)
 xtrain['Date'] = pd.to_datetime(xtrain['Date'], infer_datetime_format=True)
 xtest['Date'] = pd.to_datetime(xtest['Date'], infer_datetime_format=True)
 xtrain.info()
xtest.info()
y1_xTrain = xtrain.iloc[:, -2]
y1_xTrain.head()
y2_xTrain = xtrain.iloc[:, -1]
y2_xTrain.head()
EMPTY_VAL = "EMPTY_VAL"
def fillState(state, country):
if state == EMPTY_VAL: return country
return state<data_type_conversions>
X_TRAIN, X_TEST, Y_TRAIN, Y_TEST, W_train, W_test, preprocess_pipe = load_preprocess_data()
gc.collect()
X_TRAIN.shape, Y_TRAIN.shape
X_xTrain = xtrain.copy()
X_xTrain['State'].fillna(EMPTY_VAL, inplace=True)
 X_xTrain['State'] = X_xTrain.loc[:, ['State', 'Country']].apply(lambda x : fillState(x['State'], x['Country']), axis=1)
 X_xTrain.loc[:, 'Date'] = X_xTrain.Date.dt.strftime("%m%d")
 X_xTrain["Date"] = X_xTrain["Date"].astype(int)
 X_xTrain.head()
X_xTest = xtest.copy()
X_xTest['State'].fillna(EMPTY_VAL, inplace=True)
 X_xTest['State'] = X_xTest.loc[:, ['State', 'Country']].apply(lambda x : fillState(x['State'], x['Country']), axis=1)
 X_xTest.loc[:, 'Date'] = X_xTest.Date.dt.strftime("%m%d")
 X_xTest["Date"] = X_xTest["Date"].astype(int)
 X_xTest.head()<categorify>
def learning_rate_010_decay_power_09(current_iter):
base_learning_rate = 0.1
lr = base_learning_rate * np.power (.995, current_iter)
 return lr if lr > 1e-2 else 1e-2
le = preprocessing.LabelEncoder()
X_xTrain.Country = le.fit_transform(X_xTrain.Country)
 X_xTrain['State'] = le.fit_transform(X_xTrain['State'])
 X_xTrain.head()
X_xTest.Country = le.fit_transform(X_xTest.Country)
 X_xTest['State'] = le.fit_transform(X_xTest['State'])
 X_xTest.head()
xtrain.head()
xtrain.loc[xtrain.Country == 'Afghanistan', :]
xtest.tail()<categorify>
FIT_PARAMS= {
"early_stopping_rounds":30,
"eval_metric" : 'auc',
"eval_set" : [(X_TEST, Y_TEST[:,-1])],
'eval_names': ['valid'],
'callbacks': [lgb.reset_parameter(learning_rate=learning_rate_010_decay_power_09)],
'verbose': 50,
'categorical_feature': 'auto'
}
filterwarnings('ignore')
 le = preprocessing.LabelEncoder()
countries = X_xTrain.Country.unique() 
<prepare_x_and_y>
xout = pd.DataFrame({'ForecastId': [], 'ConfirmedCases': [], 'Fatalities': []})
 for country in countries:
states = X_xTrain.loc[X_xTrain.Country == country, :].State.unique()
for state in states:
X_xTrain_CS = X_xTrain.loc[(X_xTrain.Country == country)&(X_xTrain.State == state), ['State', 'Country', 'Date', 'ConfirmedCases', 'Fatalities']]
y1_xTrain_CS = X_xTrain_CS.loc[:, 'ConfirmedCases']
y2_xTrain_CS = X_xTrain_CS.loc[:, 'Fatalities']
X_xTrain_CS = X_xTrain_CS.loc[:, ['State', 'Country', 'Date']]
X_xTrain_CS.Country = le.fit_transform(X_xTrain_CS.Country)
 X_xTrain_CS['State'] = le.fit_transform(X_xTrain_CS['State'])
 X_xTest_CS = X_xTest.loc[(X_xTest.Country == country)&(X_xTest.State == state), ['State', 'Country', 'Date', 'ForecastId']]
X_xTest_CS_Id = X_xTest_CS.loc[:, 'ForecastId']
X_xTest_CS = X_xTest_CS.loc[:, ['State', 'Country', 'Date']]
X_xTest_CS.Country = le.fit_transform(X_xTest_CS.Country)
 X_xTest_CS['State'] = le.fit_transform(X_xTest_CS['State'])
 xmodel1 = XGBRegressor(n_estimators=1000)
 xmodel1.fit(X_xTrain_CS, y1_xTrain_CS)
 y1_xpred = xmodel1.predict(X_xTest_CS)
 xmodel2 = XGBRegressor(n_estimators=1000)
 xmodel2.fit(X_xTrain_CS, y2_xTrain_CS)
 y2_xpred = xmodel2.predict(X_xTest_CS)
 xdata = pd.DataFrame({'ForecastId': X_xTest_CS_Id, 'ConfirmedCases': y1_xpred, 'Fatalities': y2_xpred})
 xout = pd.concat([xout, xdata], axis=0)
<save_to_csv>
OPT_PARAMS_1 = {'n_estimators': N_ESTIMATORS, 'colsample_bytree': 0.668, 'min_child_samples': 150, 'min_child_weight': 1, 'num_leaves': 80, 'reg_alpha': 0, 'reg_lambda': 0.002, 'subsample': 0.87}
OPT_PARAMS_2 = {'n_estimators': N_ESTIMATORS, 'colsample_bytree': 0.668, 'min_child_samples': 190, 'min_child_weight': 1, 'num_leaves': 90, 'reg_alpha': 0, 'reg_lambda': 0.002, 'subsample': 0.87}
xout.ForecastId = xout.ForecastId.astype('int')
 xout.tail()
xout.to_csv('submission.csv', index=False )<load_from_csv>
def create_train_lgbm(X_train, y_train, component):
if component == 1:
opt_params = deepcopy(OPT_PARAMS_1)
 else:
opt_params = deepcopy(OPT_PARAMS_2)
 lgb_clf_1 = lgb.LGBMClassifier(**opt_params)
 lgb_clf_1.fit(X_train, y_train, **FIT_PARAMS)
 if lgb_clf_1.best_iteration_ != N_ESTIMATORS:
opt_params['n_estimators'] = lgb_clf_1.best_iteration_
lgb_clf_1 = lgb.LGBMClassifier(**opt_params)
 lgb_clf_1.fit(X_train, y_train, **FIT_PARAMS)
 X_temp = X_train[10].reshape(( 1, -1))
np.round(lgb_clf_1.predict(X_temp)).astype(int)
 return lgb_clf_1
df=pd.read_csv("/kaggle/input/covid19-global-forecasting-week-4/train.csv")
 test=pd.read_csv("/kaggle/input/covid19-global-forecasting-week-4/test.csv" )<feature_engineering>
def getLgbs() :
LGBS = []
for model_id in range(5):
y_train = Y_TRAIN[:, model_id]
lgbm_1 = create_train_lgbm(X_TRAIN, y_train, 1)
 lgbm_2 = create_train_lgbm(X_TRAIN, y_train, 2)
 LGBS.append(( lgbm_1, lgbm_2))
pickleSave(LGBS, 'lgbs.bin')
 return LGBS
df["Province_State"].fillna("state", inplace = True)
 df["Country_Region"] = [country_name.replace("'","")for country_name in df["Country_Region"]]
print(df.shape,"
",df.head() )<split>
def getSclfs() :
SCLFS = []
for model_id in range(5):
sclf = StackingClassifier(classifiers=LGBS[model_id], fit_base_estimators=False,
use_probas=True, average_probas=False,
meta_classifier=Best_clf_cv_transformer({ 'name': 'LSvc', 'params': {'penalty': 'l2', 'class_weight': 'balanced'}, 'param_grid': {'C' : [0.01, 0.05, 0.1, 1]} }))
sclf.name = 'sclf_' + str(model_id)
 y_train = Y_TRAIN[:, model_id]
sclf.fit(X_TRAIN, y_train)
 SCLFS.append(sclf)
 pickleSave(SCLFS, 'sclfs.bin')
 X_temp = X_TRAIN[10].reshape(( 1, -1))
np.round(SCLFS[0].predict(X_temp)).astype(int)
 return SCLFS
X_y=shuffle(new_data)
 y_cases=X_y['target_infection']
y_fatal=X_y['target_fatal']
X=X_y.drop(['target_infection','target_fatal'],axis=1)
 X_train_cases, X_test_cases, y_train_cases, y_test_cases = train_test_split(X, y_cases, test_size=0.33)
 X_train_fatal, X_test_fatal, y_train_fatal, y_test_fatal = train_test_split(X, y_fatal, test_size=0.33)
 print("Shape of infection train dataset:",(X_train_cases.shape,y_train_cases.shape))
print("Shape of infection test dataset:",(X_test_cases.shape,y_test_cases.shape))
print("Shape of fatal train dataset:",(X_train_fatal.shape,y_train_fatal.shape))
print("Shape of fatal test dataset:",(X_test_fatal.shape,y_test_fatal.shape))<train_on_grid>
LGBS = unpickle('.. /input/jane-lgbm-stackedlsvc/lgbs.bin')
 SCLFS = unpickle('.. /input/jane-lgbm-stackedlsvc/sclfs.bin' )
reg_case=ElasticNet(random_state=42,l1_ratio=0.1,max_iter=2200)
 params = [{'alpha': [10**-4,10**-3, 10**-2,10**-1, 10**0,10**1, 10**2,10**3,10**4]}]
clf = RandomizedSearchCV(reg_case, params, cv=4, scoring='neg_root_mean_squared_error',return_train_score=True)
 search=clf.fit(X_train_cases, y_train_cases)
 results = pd.DataFrame.from_dict(clf.cv_results_)
<train_model>
def predict(test_df, isRetProb=False):
test_df.drop(columns=['weight', 'date'], inplace=True)
 test_df.reset_index(drop=True, inplace=True)
 X_test = preprocess_pipe.transform(test_df ).reshape(( -1, 130))
y_probs = []
for sclf in SCLFS:
y_p = sclf.predict_proba(X_test ).reshape(( -1, 2)) [:, 1].reshape(( -1, 1))
y_probs.append(y_p)
 y_probs = np.hstack(y_probs)
 pred_pr = np.median(y_probs, axis=1)
 y_pred =(pred_pr >= 0.5 ).astype(int)
 if isRetProb:
return y_pred, pred_pr
else:
return y_pred
best_alpha=1000
best_itr=2400
final_reg_case=ElasticNet(random_state=42,alpha=best_alpha,l1_ratio=0.1,max_iter=best_itr)
 final_reg_case.fit(X_train_cases,y_train_cases )<predict_on_test>
env = janestreet.make_env()
env_iter = env.iter_test()
pred=final_reg_case.predict(X_test_cases)
 print("The RMSE value",(mean_squared_error(y_test_cases,pred)) **0.5 )<train_on_grid>
for test_df, pred_df in env_iter:
if test_df["weight"].item() > 0:
predictions = predict(test_df)
 pred_df.action = predictions
else:
pred_df.action = 0
env.predict(pred_df )
reg_fatal=ElasticNet(random_state=42,l1_ratio=0.1,max_iter=3500)
 params = [{'alpha': [10**-4,10**-3, 10**-2,10**-1, 10**0,10**1, 10**2,10**3,10**4]}]
clf = RandomizedSearchCV(reg_fatal, params, cv=4, scoring='neg_root_mean_squared_error',return_train_score=True)
 search=clf.fit(X_train_fatal, y_train_fatal)
 results = pd.DataFrame.from_dict(clf.cv_results_)
<train_model>
print('Done !' )