id
int64
0
7.95k
code_block
stringlengths
1
52.9k
too_long
stringclasses
2 values
marks
int64
1
5
graph_vertex_id
float64
1
88
graph_vertex_class
stringclasses
12 values
graph_vertex_subclass
stringclasses
70 values
kernel_id
float64
25.8k
14.7M
⌀
sqale_rating
float64
1
4
maintainability_rating
stringclasses
4 values
code_smells
int64
0
36
complexity
float64
0
15
⌀
cognitive_complexity
int64
0
33
bugs
int64
0
7
sqale_index
int64
0
125
ncloc
float64
0
101
⌀
mlscent_analysis_status
stringclasses
3 values
mlscent_smell_count
int64
0
31
mlscent_unique_smell_count
int64
0
12
mlscent_findings_json
stringlengths
2
7.76k
mlscent_ml_rating
stringclasses
5 values
mlscent_ml_rating_basis
stringclasses
52 values
mlscent_ml_findings_json
stringclasses
50 values
mlscent_ignored_findings_json
stringclasses
199 values
context_line_count
int64
0
33
combined_rating
stringclasses
5 values
101
df_out['ConfirmedCases'] = (1/2)*(df_out['ConfirmedCases'] + df_out2['ConfirmedCases']) df_out['Fatalities'] = (1/2)*(df_out['Fatalities'] + df_out2['Fatalities'])
No
5
8
Data_Transform
feature_engineering
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
102
df_out['ConfirmedCases'] = df_out['ConfirmedCases'].round().astype(int) df_out['Fatalities'] = df_out['Fatalities'].round().astype(int)
No
5
16
Data_Transform
data_type_conversions
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
103
df_out.tail()
No
5
41
Debug
show_table
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
104
# This Python 3 environment comes with many helpful analytics libraries installed # It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python # For example, here's several helpful packages to load in import numpy as np # linear algebra import pandas as pd # data processing, CSV file I/O...
No
5
88
Debug
list_files
null
1
A
0
2
3
0
0
9
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: /kaggle/input. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 12"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
0
A
105
train_df = pd.read_csv("../input/covid19-global-forecasting-week-2/train.csv") test_df = pd.read_csv("../input/covid19-global-forecasting-week-2/test.csv")
No
5
45
Data_Extraction
load_from_csv
8,660,923
1
A
0
0
0
0
0
2
ok
3
2
[{"detector": "general_ml", "framework": "General ML", "name": "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "fix": "Not specified", "benefits": "Not specified", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name": "Har...
A
no applicable ML-specific findings
[]
["Hardcoded file path", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness."]
11
A
106
train_df.head(50)
No
5
41
Debug
show_table
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
107
''' from pandas_profiling import ProfileReport train_profile = ProfileReport(train_df, title='Pandas Profiling Report', html={'style':{'full_width':True}}) train_profile '''
No
3
22
Environment
import_modules
null
1
A
1
0
0
0
5
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
108
train_df.info()
No
5
40
Debug
show_table_attributes
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
109
common_value = "UNKNOWN" # Replacing all the Province_State that are null by the Country_Region values train_df.Province_State.fillna(train_df.Country_Region, inplace=True) test_df.Province_State.fillna(test_df.Country_Region, inplace=True) # Handling the Date column # 1. Converting the object type column into dateti...
No
4
8
Data_Transform
feature_engineering
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
110
#Dropping the date column train_df.drop("Date", inplace = True, axis = 1) test_df.drop("Date", inplace = True, axis = 1)
No
5
10
Data_Transform
drop_column
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
111
train_df.Province_State.value_counts()
No
5
72
EDA
count_values
8,660,923
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}]
B
Cross Validation Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}]
[]
11
B
112
from sklearn.preprocessing import LabelEncoder le = LabelEncoder() train_df.Country_Region = le.fit_transform(train_df.Country_Region) train_df['Province_State'] = le.fit_transform(train_df['Province_State']) test_df.Country_Region = le.fit_transform(test_df.Country_Region) test_df['Province_State'] = le.fit_transfo...
No
5
20
Data_Transform
categorify
null
1
A
0
0
0
0
0
6
ok
14
8
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Pipeline Checker", "fix": "Use Pipelines for all scikit-learn estimators.", "benefits": "Prevents data leakage and ensures correct model evaluation.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross V...
D
Cross Validation Checker=low, Data Leakage Checker=high, No random seed setting detected=low, Pipeline Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Pipeline Checker", "severity": "low"}]
["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"]
0
D
114
\
No
3
20
Data_Transform
categorify
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
115
''' # Removing duplicate entries train_df = train_df.loc[:,~train_df.columns.duplicated()] test_df = test_df.loc[:,~test_df.columns.duplicated()] print (test_df.shape) '''
No
4
19
Data_Transform
remove_duplicates
null
1
A
1
0
0
0
5
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
116
''' # Dropping the object type columns train_df.drop(objList, axis=1, inplace=True) test_df.drop(objList, axis=1, inplace=True) print (train_df.shape) '''
No
4
10
Data_Transform
drop_column
null
1
A
1
0
0
0
5
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
117
\
No
5
71
Debug
show_columns
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
118
test_df.info()
No
5
40
Debug
show_table_attributes
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
119
X_train = train_df.drop(["Id", "ConfirmedCases", "Fatalities"], axis = 1) Y_train_CC = train_df["ConfirmedCases"] Y_train_Fat = train_df["Fatalities"] #X_test = test_df.drop(["ForecastId"], axis = 1) X_test = test_df.drop(["ForecastId"], axis = 1)
No
5
21
Data_Transform
prepare_x_and_y
8,660,923
1
A
1
0
0
0
5
4
ok
2
2
[{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida...
B
Cross Validation Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}]
["Column Selection Checker"]
11
B
121
\
No
5
28
Model_Train
compute_train_metric
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
122
from sklearn.model_selection import ShuffleSplit, cross_val_score skfold = ShuffleSplit(random_state=7)
No
5
84
Other
not_enough_vertices
null
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
0
A
123
#1.Ridge Regression #Model import from sklearn.linear_model import Ridge #train classifier reg_CC = Ridge(alpha=1.0) reg_Fat = Ridge(alpha=1.0) #Cross Validation to calculate the score score_CC = cross_val_score(reg_CC, X_train, Y_train_CC, cv = skfold) score_Fat = cross_val_score(reg_Fat, X_train, Y_train_Fat, c...
No
5
84
Other
not_enough_vertices
8,660,923
1
A
1
0
0
0
5
6
ok
3
2
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing Checker", "fix": "Write unit tests for data processing and model components.", "benefits": "Ensures code reliability and prevents bugs.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Excepti...
A
no applicable ML-specific findings
[]
["Exception Handling Checker", "Unit Testing Checker"]
11
A
124
#2.Lasso Regression #Model import from sklearn import linear_model #train classifier reg_CC = linear_model.Lasso(alpha=0.1) reg_Fat = linear_model.Lasso(alpha=0.1) #Cross Validation to calculate the score score_CC = cross_val_score(reg_CC, X_train, Y_train_CC, cv = skfold) score_Fat = cross_val_score(reg_Fat, X_t...
No
5
28
Model_Train
compute_train_metric
8,660,923
1
A
1
0
0
0
5
6
ok
3
2
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing Checker", "fix": "Write unit tests for data processing and model components.", "benefits": "Ensures code reliability and prevents bugs.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Excepti...
A
no applicable ML-specific findings
[]
["Exception Handling Checker", "Unit Testing Checker"]
11
A
125
#3. SVM #Model import from sklearn import svm #train classifier reg_CC = svm.SVC() reg_Fat = svm.SVC() #Cross Validation to calculate the score score_CC = cross_val_score(reg_CC, X_train, Y_train_CC, cv = skfold) score_Fat = cross_val_score(reg_Fat, X_train, Y_train_Fat, cv = skfold) #Print the scores print (sco...
No
5
28
Model_Train
compute_train_metric
8,660,923
1
A
0
0
0
0
0
6
ok
3
2
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing Checker", "fix": "Write unit tests for data processing and model components.", "benefits": "Ensures code reliability and prevents bugs.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Excepti...
A
no applicable ML-specific findings
[]
["Exception Handling Checker", "Unit Testing Checker"]
11
A
126
#3. ElasticNet #Model import from sklearn.linear_model import ElasticNet #train classifier reg_CC = ElasticNet(random_state=0) reg_Fat = ElasticNet(random_state=0) #Cross Validation to calculate the score score_CC = cross_val_score(reg_CC, X_train, Y_train_CC, cv = skfold) score_Fat = cross_val_score(reg_Fat, X_tr...
No
5
28
Model_Train
compute_train_metric
8,660,923
2
B
2
0
0
0
10
6
ok
3
2
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing Checker", "fix": "Write unit tests for data processing and model components.", "benefits": "Ensures code reliability and prevents bugs.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Excepti...
A
no applicable ML-specific findings
[]
["Exception Handling Checker", "Unit Testing Checker"]
11
B
127
#5. LinearRegression #Model import from sklearn.linear_model import LinearRegression #train classifier reg_CC = LinearRegression() reg_Fat = LinearRegression() #Cross Validation to calculate the score score_CC = cross_val_score(reg_CC, X_train, Y_train_CC, cv = skfold) score_Fat = cross_val_score(reg_Fat, X_train...
No
5
28
Model_Train
compute_train_metric
8,660,923
1
A
0
0
0
0
0
6
ok
3
2
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing Checker", "fix": "Write unit tests for data processing and model components.", "benefits": "Ensures code reliability and prevents bugs.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Excepti...
A
no applicable ML-specific findings
[]
["Exception Handling Checker", "Unit Testing Checker"]
11
A
128
\
No
5
28
Model_Train
compute_train_metric
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
129
\
No
5
28
Model_Train
compute_train_metric
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
130
\
No
3
28
Model_Train
compute_train_metric
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
131
\
No
5
28
Model_Train
compute_train_metric
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
132
#5. BaggingClassifier from sklearn.ensemble import BaggingRegressor from sklearn.tree import DecisionTreeRegressor clf_bgr_CC = BaggingRegressor(base_estimator = DecisionTreeRegressor()) clf_bgr_Fat = BaggingRegressor(base_estimator = DecisionTreeRegressor()) rmsle_bgr_CC = test_model(clf_bgr_CC, "CC") rmsle_bgr_Fat...
No
5
84
Other
not_enough_vertices
8,660,923
3
C
6
0
0
0
30
7
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
11
C
133
\
No
4
28
Model_Train
compute_train_metric
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
135
reg_CC.fit(X_train, Y_train_CC) Y_pred_CC = reg_CC.predict(X_test) reg_Fat.fit(X_train, Y_train_Fat) Y_pred_Fat = reg_Fat.predict(X_test)
No
5
48
Model_Evaluation
predict_on_test
null
1
A
0
0
0
0
0
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
136
print (Y_pred_Fat)
No
5
53
Other
something_strange
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
137
#Using pd.to_datetime for adding new features df_train['Date'] = pd.to_datetime(df_train['Date']) df_train.insert(1,'Week',df_train['Date'].dt.week) df_train.insert(2,'Day',df_train['Date'].dt.day) df_train.insert(3,'DayofWeek',df_train['Date'].dt.dayofweek) df_train.insert(4,'DayofYear',df_train['Date'].dt.dayofyear) ...
No
5
8
Data_Transform
feature_engineering
null
1
A
0
0
0
0
0
10
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
138
# Replacing all the Province_State that are null by the Country_Region values df_train.Province_State.fillna(df_train.Country_Region, inplace=True) df_test.Province_State.fillna(df_test.Country_Region, inplace=True)
No
5
17
Data_Transform
correct_missing_values
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
139
from sklearn.preprocessing import LabelEncoder le = 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_transfor...
No
5
20
Data_Transform
categorify
null
1
A
0
0
0
0
0
6
ok
14
8
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Pipeline Checker", "fix": "Use Pipelines for all scikit-learn estimators.", "benefits": "Prevents data leakage and ensures correct model evaluation.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross V...
D
Cross Validation Checker=low, Data Leakage Checker=high, No random seed setting detected=low, Pipeline Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Pipeline Checker", "severity": "low"}]
["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"]
0
D
140
#One Hot Encoding columns def one_hot(df, cols): """ @param df pandas DataFrame @param cols a list of columns to encode @return a DataFrame with one-hot encoding """ i = 0 for each in cols: #print (each) dummies = pd.get_dummies(df[each], prefix=each, drop_first= True) ...
No
5
20
Data_Transform
categorify
null
1
A
0
3
3
0
0
9
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
141
#Handling categorical data objList = df_train.select_dtypes(include = "object").columns df_train = one_hot(df_train, objList) df_test = one_hot(df_test, objList) print (df_train.shape)
No
4
8
Data_Transform
feature_engineering
null
1
A
0
0
0
0
0
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
142
#Avoiding duplicated data. df_train = df_train.loc[:,~df_train.columns.duplicated()] df_test = df_test.loc[:,~df_test.columns.duplicated()] print (df_test.shape)
No
4
19
Data_Transform
remove_duplicates
null
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
143
#reading data data = pd.read_csv('../input/covid19-global-forecasting-week-2/train.csv') test_data = pd.read_csv('../input/covid19-global-forecasting-week-2/test.csv') submission = pd.read_csv('../input/covid19-global-forecasting-week-2/submission.csv') print(data.shape) print(test_data.shape) print(submission.shape)
No
4
45
Data_Extraction
load_from_csv
8,592,598
1
A
0
0
0
0
0
6
ok
3
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/covid19-global-forecasting-week-2/train.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 4"}, {"detector": "general_ml", "frame...
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
2
A
144
# This Python 3 environment comes with many helpful analytics libraries installed # It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python # For example, here's several helpful packages to load in import numpy as np # linear algebra import pandas as pd # data processing, CSV file I/O...
No
4
22
Environment
import_modules
8,667,455
1
A
0
2
3
0
0
6
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: /kaggle/input. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 21"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
3
A
145
dftrain = pd.read_csv("/kaggle/input/covid19-global-forecasting-week-2/train.csv") dftrain["GrowthRate"] = dftrain["ConfirmedCases"] / dftrain.ConfirmedCases.shift(1) print(dftrain.Date.unique()) dftest = pd.read_csv("/kaggle/input/covid19-global-forecasting-week-2/test.csv") print(dftest.columns.values) dfsubmission ...
No
3
45
Data_Extraction
load_from_csv
8,667,455
1
A
0
0
0
0
0
6
ok
7
5
[{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida...
B
Cross Validation Checker=low, No random seed setting detected=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}]
["Column Selection Checker", "Hardcoded file path", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness."]
3
B
146
growth_per_country = {} means_per_country = {} last_per_country = {} def train(country, region, growth): if growth < 2.0: print(growth) growth_list = growth_per_country.get((country,region), list()) growth_list.append(growth) growth_per_country[(country,region)] = growth_list ...
No
2
7
Model_Train
train_model
8,667,455
1
A
2
4
2
0
7
14
ok
3
3
[{"detector": "framework_specific", "framework": "NumPy", "name": "Missing Axis Specification", "fix": "Specify axis in array operations.", "benefits": "Improves performance and avoids unexpected behaviour.", "location": "Line 17"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Che...
C
Missing Axis Specification=medium
[{"type": "Missing Axis Specification", "severity": "medium"}]
["Column Selection Checker", "Missing function docstring"]
3
C
147
## Training for row in dftrain.itertuples(): train(row.Country_Region, row.Province_State, row.GrowthRate)
No
3
7
Model_Train
train_model
8,667,455
1
A
0
1
1
0
0
2
ok
2
2
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name...
B
Cross Validation Checker=low, No random seed setting detected=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}]
[]
3
B
148
## Current submission for row in dftest.itertuples(): if(row.ForecastId%100 == 0): print(row.ForecastId) if type(row.Province_State)!=str: dfnow = dftrain[dftrain.Country_Region == row.Country_Region] else: dfnow = dftrain[dftrain.Country_Region == row.Country_Region][dftrain.Provinc...
No
3
27
Model_Train
predict_on_train
null
1
A
1
4
9
1
2
19
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
149
print(dfsubmission.head(60))
No
5
41
Debug
show_table
8,667,455
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
150
dfsubmission["Date"] = dftest["Date"] dfsub = dfsubmission[dftest.Country_Region == 'Ireland'][dftest.Province_State.isnull()] dfsub[:20].plot("Date", "ConfirmedCases")'
No
3
33
Visualization
distribution
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
151
df = pd.read_csv("/kaggle/input/covid19-global-forecasting-week-2/train.csv") df.head(40) print(df.columns.values) df["GrowthRate"] = df["ConfirmedCases"] / df.ConfirmedCases.shift(1) df["Growth"] = df["ConfirmedCases"] - df.ConfirmedCases.shift(1) df["PredictedCasesByRate"] = df["ConfirmedCases"].shift(1) * df.Growth...
No
5
53
Other
something_strange
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
152
dftest = pd.read_csv("/kaggle/input/covid19-global-forecasting-week-2/test.csv") dftest.head(40)
No
4
45
Data_Extraction
load_from_csv
8,667,455
1
A
0
0
0
0
0
2
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: /kaggle/input/covid19-global-forecasting-week-2/test.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 4"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
3
A
153
dfg = df.groupby([df.Country_Region, df.Province_State]) dfg.head()
No
3
60
Data_Transform
groupby
8,667,455
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
154
import numpy as np import pandas as pd df = pd.read_csv("../input/covid19-global-forecasting-week-2/train.csv") df.shape
No
3
45
Data_Extraction
load_from_csv
null
1
A
0
0
0
0
0
4
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/covid19-global-forecasting-week-2/train.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 4"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
0
A
155
loc_group = ["Province_State", "Country_Region"] def preprocess(df): df["Date"] = df["Date"].astype("datetime64[ms]") for col in loc_group: df[col].fillna("none", inplace=True) return df df = preprocess(df) sub_df = preprocess(pd.read_csv("../input/covid19-global-forecasting-week-2/test.csv")) df...
No
4
45
Data_Extraction
load_from_csv
null
1
A
0
2
1
0
0
9
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
156
# Dropping the object type columns df_train.drop(objList, axis=1, inplace=True) df_test.drop(objList, axis=1, inplace=True) print (df_train.shape)
No
4
10
Data_Transform
drop_column
null
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
157
df["Date"].min(), df["Date"].max()
No
5
40
Debug
show_table_attributes
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
158
TARGETS = ["ConfirmedCases", "Fatalities"] for col in TARGETS: df[col] = np.log1p(df[col])
No
5
8
Data_Transform
feature_engineering
null
1
A
0
1
1
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
159
for col in TARGETS: df["prev_{}".format(col)] = df.groupby(loc_group)[col].shift()
No
5
60
Data_Transform
groupby
null
1
A
0
1
1
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
160
df = df[df["Date"] > df["Date"].min()].copy() df.head()
No
4
14
Data_Transform
filter
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
161
df_train
No
5
41
Debug
show_table
null
1
A
0
0
0
1
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
162
X = df_train.drop(['Date', 'ConfirmedCases', 'Fatalities'], axis=1) y = df_train[['ConfirmedCases', 'Fatalities']]
No
5
21
Data_Transform
prepare_x_and_y
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
163
from sklearn.linear_model import LinearRegression from sklearn.linear_model import BayesianRidge from sklearn.neighbors import KNeighborsRegressor from sklearn.ensemble import RandomForestRegressor, GradientBoostingRegressor from sklearn.tree import DecisionTreeRegressor from sklearn.model_selection import train_test_...
No
5
22
Environment
import_modules
8,609,050
1
A
0
0
0
0
0
9
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
13
A
164
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=1)
No
5
13
Data_Transform
split
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
165
y_train.head()
No
5
41
Debug
show_table
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
166
n_folds = 5 cv = KFold(n_splits = 5, shuffle=True, random_state=42).get_n_splits(X_train.values)
No
5
84
Other
not_enough_vertices
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
167
def predict_scores(reg_alg): r2 = make_scorer(r2_score) m = reg_alg() m.fit(X_train, y_train['ConfirmedCases']) y_pred = m.predict(X_test) m_r = cross_val_score(m, X_train, y_train['ConfirmedCases'], cv=cv, scoring = r2) sc_Cases.append(m_r) m.fit(X_train, y_train['Fatalities']) y_p...
No
5
3
Hyperparam_Tuning
find_best_model_class
8,609,050
1
A
1
2
1
0
5
17
ok
14
7
[{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Verbose Mode...
B
No random seed setting detected=low
[{"type": "No random seed setting detected", "severity": "low"}]
["Column Selection Checker", "Exception Handling Checker", "Missing function docstring", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"]
13
B
168
sc_Cases
No
5
53
Other
something_strange
null
1
A
0
0
0
1
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
169
sc_Fatalities
No
5
53
Other
something_strange
null
1
A
0
0
0
1
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
170
from sklearn.ensemble import BaggingRegressor
No
5
22
Environment
import_modules
null
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
0
A
171
#Hyperparameter tuning from sklearn.model_selection import RandomizedSearchCV,GridSearchCV param_grid = { 'n_estimators':[10, 30, 50, 100,250,500,750,1000,1250,1500,1750], 'max_samples':[2,4,6,8,10,20,40,60,100], "max_features": [0.5, 1.0], 'n_jobs':[-2, -1, 1,...
No
5
6
Hyperparam_Tuning
train_on_grid
null
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
0
null
172
model1 = clf_CC model1.fit(X_train, y_train['ConfirmedCases']) model2 = clf_Fat model2.fit(X_train, y_train['Fatalities'])
No
5
7
Model_Train
train_model
8,609,050
1
A
0
0
0
0
0
4
ok
10
8
[{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida...
B
Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}]
["Column Selection Checker", "Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"]
13
B
173
df_test['ConfirmedCases'] = model1.predict(df_test.drop(['Date', 'ForecastId'], axis=1)) df_test['Fatalities'] = model2.predict(df_test.drop(['Date', 'ForecastId', 'ConfirmedCases'], axis=1))
No
5
48
Model_Evaluation
predict_on_test
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
174
import warnings warnings.filterwarnings('ignore') df_results = df_test[['ForecastId', 'ConfirmedCases', 'Fatalities']] df_results['ConfirmedCases'] = df_results['ConfirmedCases'].astype(int) df_results['Fatalities'] = df_results['Fatalities'].astype(int) df_results.head()
No
4
16
Data_Transform
data_type_conversions
null
1
A
0
0
0
0
0
6
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
175
df_results.to_csv('submission.csv', index=False)
No
5
25
Data_Export
save_to_csv
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
176
# This Python 3 environment comes with many helpful analytics libraries installed # It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python # For example, here's several helpful packages to load in import numpy as np # linear algebra import pandas as pd # data processing, CSV file I/O...
No
5
88
Debug
list_files
null
1
A
0
2
3
0
0
11
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: /kaggle/input. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 13"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
0
A
177
import plotly.graph_objects as go import matplotlib.pyplot as plt from tqdm import tqdm import time from datetime import datetime from pathlib import Path from sklearn import preprocessing import keras.backend as K from keras.models import Sequential from keras.layers import Dense, LSTM, Dropout, GRU from keras.callbac...
No
5
22
Environment
import_modules
8,678,201
1
A
0
0
0
0
0
12
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
4
A
178
train = pd.read_csv("/kaggle/input/covid19-global-forecasting-week-2/train.csv") test = pd.read_csv("/kaggle/input/covid19-global-forecasting-week-2/test.csv") train.tail()
No
4
45
Data_Extraction
load_from_csv
null
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
179
test.tail()
No
5
41
Debug
show_table
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
180
train.info()
No
5
40
Debug
show_table_attributes
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
182
train['Date'] = pd.to_datetime(train['Date']) test['Date'] = pd.to_datetime(test['Date']) train['Country_Region'] = train['Country_Region'].astype(str) # train['Province_State'] = train['Province_State'].astype(str) test['Country_Region'] = test['Country_Region'].astype(str) # test['Province_State'] = test['Province_St...
No
5
16
Data_Transform
data_type_conversions
null
2
B
2
0
0
0
10
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
183
EMPTY_VAL = "EMPTY_VAL" def fillState(state, country): if state == EMPTY_VAL: return country return state train['Province_State'].fillna(EMPTY_VAL, inplace=True) train['Province_State'] = train.loc[:, ['Province_State', 'Country_Region']].apply(lambda x : fillState(x['Province_State'], x['Country_Region']), ...
No
5
17
Data_Transform
correct_missing_values
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
184
le = preprocessing.LabelEncoder() train['country_encoder'] = le.fit_transform(train['Country_Region']) train['date_int'] = train['Date'].apply(lambda x: datetime.strftime(x, '%m%d')).astype(int) test['country_encoder'] = le.transform(test['Country_Region']) test['date_int'] = test['Date'].apply(lambda x: datetime.strf...
No
4
20
Data_Transform
categorify
null
1
A
0
0
0
0
0
5
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
185
le = preprocessing.LabelEncoder() train['province_encoder'] = le.fit_transform(train['Province_State']) test['province_encoder'] = le.transform(test['Province_State'])
No
5
20
Data_Transform
categorify
null
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
186
#TODO: takes 44m ish, consider multi-processing, multi-cores, run in GPU #TODO: create data_generate func from joblib import parallel_backend start_time = time.time() country = train['Country_Region'].drop_duplicates() train_df = train.copy() train_df.rename(columns={'Date': 'date', 'ConfirmedCases': 'cc_cases', 'Fata...
No
4
8
Data_Transform
feature_engineering
8,678,201
1
A
4
4
20
0
10
25
ok
4
4
[{"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "Assign operations to a new DataFrame variable.", "benefits": "Prevents data loss and improves code clarity.", "location": "Line 12"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker"...
B
Cross Validation Checker=low, No random seed setting detected=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}]
["Column Selection Checker", "InPlace Checker"]
4
B
187
# train_df.to_csv(Path('/kaggle/working', 'train_df.csv')) # saved locally, reload it train_df = pd.read_csv(Path('/kaggle/working/', 'train_df.csv'), index_col = 0, parse_dates = ['date']) train_df[train_df['country'] == 'Italy'].tail()
No
4
45
Data_Extraction
load_from_csv
8,678,201
1
A
0
0
0
0
0
2
ok
3
3
[{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida...
B
Cross Validation Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}]
["Column Selection Checker", "Hardcoded file path"]
4
B
188
#TODO: walk forward validation def split_train_val(df, val_ratio): val_len = int(len(df) * val_ratio) train_set = df[:-val_len] val_set = df[-val_len:] return train_set, val_set
No
5
13
Data_Transform
split
null
1
A
1
1
0
0
0
5
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
189
test_fixed_cols = ['ForecastId', 'Province_State', 'Country_Region', 'Date'] fixed_cols = ['Id', 'province', 'country', 'date'] output_cols = ['cc_cases', 'ft_cases'] input_cols = list(set(train_df.columns.to_list()) - set(fixed_cols) - set(output_cols)) print('output columns are ', output_cols) print('input columns ar...
No
5
21
Data_Transform
prepare_x_and_y
null
1
A
0
0
0
0
0
8
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
190
# split to cumulative and fatal features and build 2 separate models # split to train and validation set cc_input = ['cc_cases_1', 'cc_cases_2', 'cc_cases_3', 'cc_cases_4', 'cc_cases_5', 'cc_cases_6', 'cc_cases_7', 'country_encoder', 'province_encoder', 'date_int'] ft_input = ['ft_cases_1', 'ft_cases_2', 'ft_cases_3', ...
No
5
13
Data_Transform
split
null
1
A
0
0
0
0
0
12
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
191
idx = np.random.RandomState(seed=42).permutation(train_X_cc.index) train_X_cc = train_X_cc.reindex(idx) train_y_cc = train_y_cc.reindex(idx) train_X_ft = train_X_ft.reindex(idx) train_y_ft = train_y_ft.reindex(idx) # train_y_cc.tail()
No
5
15
Data_Transform
randomize_order
null
1
A
0
0
0
0
0
5
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
192
# normalization X_scaler_cc = MinMaxScaler() X_train_cc = X_scaler_cc.fit_transform(train_X_cc) X_val_cc = X_scaler_cc.transform(val_X_cc) # intput/output 2D array-like y_scaler_cc = MinMaxScaler() y_train_cc = y_scaler_cc.fit_transform(train_y_cc) y_val_cc = y_scaler_cc.transform(val_y_cc) # array-like
No
5
18
Data_Transform
normalization
8,678,201
1
A
0
0
0
0
0
6
ok
12
8
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Pipeline Checker", "fix": "Use Pipelines for all scikit-learn estimators.", "benefits": "Prevents data leakage and ensures correct model evaluation.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross V...
D
Cross Validation Checker=low, Data Leakage Checker=high, No random seed setting detected=low, Pipeline Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Pipeline Checker", "severity": "low"}]
["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"]
4
D
193
X_scaler_ft = MinMaxScaler() X_train_ft = X_scaler_ft.fit_transform(train_X_ft) X_val_ft = X_scaler_ft.transform(val_X_ft) # intput/output 2D array-like y_scaler_ft = MinMaxScaler() y_train_ft = y_scaler_ft.fit_transform(train_y_ft) y_val_ft = y_scaler_ft.transform(val_y_ft) # array-like
No
5
18
Data_Transform
normalization
null
1
A
0
0
0
0
0
6
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
194
print('Validate if train and test is splited correctly for 2 cases: ') print('cumulative cases training has shape ', X_train_cc.shape, y_train_cc.shape) print('fatal cases training has shape ', X_train_ft.shape, y_train_ft.shape) print('cumulative cases valid has shape ', X_val_cc.shape, y_val_cc.shape) print('fatal ca...
No
3
41
Debug
show_table
null
1
A
1
0
0
0
0
6
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
195
# if choose to not apply normalization, however it generates NaN in output... X_train_cc = train_X_cc.to_numpy() X_val_cc = val_X_cc.to_numpy() X_train_ft = train_X_ft.to_numpy() X_val_ft = val_X_ft.to_numpy() y_train_cc = train_y_cc.to_numpy() y_val_cc = val_y_cc.to_numpy() y_train_ft = train_y_ft.to_numpy() y_val_...
No
3
12
Data_Transform
create_dataframe
null
1
A
0
0
0
0
0
8
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
196
# for LSTM, intput.shape = (n_samples, 1, n_features) X_train_cc = X_train_cc.reshape(X_train_cc.shape[0], 1, X_train_cc.shape[1]) X_val_cc = X_val_cc.reshape(X_val_cc.shape[0], 1, X_val_cc.shape[1]) X_train_ft = X_train_ft.reshape(X_train_ft.shape[0], 1, X_train_ft.shape[1]) X_val_ft = X_val_ft.reshape(X_val_ft.shape...
No
3
12
Data_Transform
create_dataframe
null
1
A
0
0
0
0
0
5
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
197
import pandas as pd import datetime import lightgbm as lgb import numpy as np from sklearn import preprocessing
No
4
22
Environment
import_modules
null
1
A
0
0
0
0
0
5
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
0
A
198
train = pd.read_csv("../input/covid19-global-forecasting-week-2/train.csv") test = pd.read_csv("../input/covid19-global-forecasting-week-2/test.csv") sub = pd.read_csv("../input/covid19-global-forecasting-week-2/submission.csv")
No
5
45
Data_Extraction
load_from_csv
null
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
199
train
No
5
41
Debug
show_table
null
1
A
0
0
0
1
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
200
train = train.append(test[test['Date']>'2020-03-31'])
No
5
11
Data_Transform
concatenate
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
201
train['Date'] = pd.to_datetime(train['Date'], format='%Y-%m-%d')
No
5
16
Data_Transform
data_type_conversions
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
202
train['day_dist'] = train['Date']-train['Date'].min()
No
5
8
Data_Transform
feature_engineering
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
203
train['day_dist'] = train['day_dist'].dt.days
No
5
8
Data_Transform
feature_engineering
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
204
print(train['Date'].max()) #print(val['Date'].max()) print(test['Date'].min()) print(test['Date'].max()) #print(test['Date'].max()-test['Date'].min())
No
5
40
Debug
show_table_attributes
null
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null