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
2,057
print(df_test.shape, df_test.columns)
Yes
3
17
Data_Transform
correct_missing_values
243,149
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Dependent Threshold Checker"]
6
A
2,058
for c in rlnrs.keys(): X_c = df_test[(df_test.label == c) & (df_test.Open != 0)].drop(['Store', 'Date', 'Sales'], axis=1).values df_test.loc[(df_test.label == c) & (df_test.Open != 0), 'Sales'] = rlnrs[c].predict(X_c) df_test.Sales.mean(), df_test.Sales.min(), df_test.Sales.max()
Yes
2
16
Data_Transform
data_type_conversions
243,149
1
A
0
1
1
0
0
4
ok
3
3
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}, {"detector": "framework_specific", "framework":...
A
no applicable ML-specific findings
[]
["Dependent Threshold Checker", "Exception Handling Checker", "Unit Testing Checker"]
6
A
2,059
out = pd.DataFrame({ "Id": df_test.index, "Sales": df_test.Sales.values }) out.to_csv('submission.csv', index=False)'
No
2
58
Debug
show_shape
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,060
import numpy as np import pandas as pd from sklearn.model_selection import GridSearchCV from lightgbm import LGBMRegressor from sklearn.metrics import make_scorer from sklearn.preprocessing import LabelEncoder, Imputer, OneHotEncoder, FunctionTransformer from sklearn.preprocessing import StandardScaler from sklearn.b...
No
5
23
Environment
set_options
874,590
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
0
null
2,061
df_train = pd.read_csv("../input/train.csv", parse_dates=["Date"], date_parser=pd.to_datetime, low_memory=False) df_test = pd.read_csv("../input/test.csv", parse_dates=["Date"], date_parser=pd.to_datetime, low_memory=False) df_store = pd.read_csv("../input/store.csv")
No
5
45
Data_Extraction
load_from_csv
874,590
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,062
train = df_train.merge(df_store) test = df_test.merge(df_store)
No
5
32
Data_Transform
merge
874,590
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,063
print("train") print("max: ", df_train.Date.min()) print("min:", df_train.Date.max()) print("delta: ", df_train.Date.max() - df_train.Date.min())
No
5
40
Debug
show_table_attributes
874,590
1
A
0
0
0
0
0
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,064
print("test") print("max: ", df_test.Date.min()) print("min:", df_test.Date.max()) print("delta: ", df_test.Date.max() - df_test.Date.min())
No
5
40
Debug
show_table_attributes
874,590
1
A
0
0
0
0
0
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,065
df_train.groupby("DayOfWeek").agg({"Sales": "mean"}).plot(kind="bar")
No
5
33
Visualization
distribution
874,590
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,066
df_train[(df_train.DayOfWeek == 7) & (df_train.Open == 1)].Store.unique().shape[0]
No
5
54
EDA
count_unique_values
874,590
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,067
df_train.groupby("StateHoliday").agg({"Sales": "mean"}).plot(kind="bar")
No
5
33
Visualization
distribution
874,590
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,068
df_train.groupby("SchoolHoliday").agg({"Sales": "mean"}).plot(kind="bar")
No
5
33
Visualization
distribution
874,590
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,069
df_train.groupby("Promo").agg({"Sales": "mean"}).plot(kind="bar")
No
5
33
Visualization
distribution
874,590
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,070
train.PromoInterval.unique()
No
5
57
Debug
show_unique_values
874,590
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,071
def get_Promo2Active(df): months_map = {v:i+1 for i, v in enumerate(["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"])} def is_Promo2_active(row): if row.Promo2 == 0: return 0 current_week, c...
No
5
8
Data_Transform
feature_engineering
874,590
2
B
3
6
5
0
25
12
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,072
def get_CompetitionActive(df): def is_competition_active(row): if np.isnan(row.CompetitionDistance): return 0 if np.isnan(row.CompetitionOpenSinceMonth) and np.isnan(row.CompetitionOpenSinceYear): return 1 current_month, current_year = row.Date.month...
No
5
8
Data_Transform
feature_engineering
874,590
1
A
1
7
7
0
10
10
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,073
train["Promo2Active"] = get_Promo2Active(train) train["CompetitionActive"] = get_CompetitionActive(train)
No
5
8
Data_Transform
feature_engineering
874,590
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,074
train[train.Promo2 == 1].groupby("Promo2Active").agg({"Sales": "mean"}).plot(kind="bar")
No
5
60
Data_Transform
groupby
874,590
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,075
train.groupby("CompetitionActive").agg({"Sales": "mean"}).plot(kind="bar")
No
5
33
Visualization
distribution
874,590
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,076
# we already have these, but for the sake of consistence, let's do it again train = df_train.merge(df_store) test = df_test.merge(df_store) train["Promo2Active"] = get_Promo2Active(train) train["CompetitionActive"] = get_CompetitionActive(train) test["Promo2Active"] = get_Promo2Active(test) test["CompetitionActive"] ...
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
2,077
train["DayOfYear"] = train.Date.apply(lambda x: x.timetuple().tm_yday) test["DayOfYear"] = test.Date.apply(lambda x: x.timetuple().tm_yday)
No
5
16
Data_Transform
data_type_conversions
874,590
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,078
min_date = train.Date.min() # we know that all test data happened later def date_to_day_number(df): return (df.Date - min_date).apply(lambda x: x.days)
No
5
8
Data_Transform
feature_engineering
874,590
1
A
0
1
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,079
train["Day"] = date_to_day_number(train) test["Day"] = date_to_day_number(test)
No
5
8
Data_Transform
feature_engineering
874,590
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,080
train.sort_values("Day", inplace=True) test.sort_values("Day", inplace=True)
No
5
9
Data_Transform
sort_values
874,590
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,081
def rmspe(y_true, y_pred): w = np.zeros(y_true.shape, dtype=float) ind = y_true != 0 w[ind] = 1./ (y_true[ind]**2) return np.sqrt(np.mean(w * (y_true - y_pred)**2)) rmspe_scorer = make_scorer(rmspe, greater_is_better=False)
No
5
84
Other
not_enough_vertices
874,590
1
A
0
1
0
0
0
6
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,082
train_baseline = train.copy() train_baseline['Last_Week_Sales'] = train_baseline.groupby("Store")["Sales"].shift() train_baseline['Last_Week_Diff'] = train_baseline.groupby("Store")["Last_Week_Sales"].diff() train_baseline.dropna(inplace=True, subset=["Last_Week_Sales", "Last_Week_Diff"]) train_baseline.head()'
No
2
60
Data_Transform
groupby
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,083
mean_error = [] for day in range(2, train_baseline.Day.max() + 1): val = train_baseline[train_baseline.Day == day] p = val.Last_Week_Sales.values error = rmspe(val.Sales.values, p) mean_error.append(error) print('Mean Error = %.5f' % np.mean(mean_error))
No
2
60
Data_Transform
groupby
874,590
1
A
0
1
1
0
0
7
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,084
class LabelEncoderPipelineFriendly(LabelEncoder): def fit(self, X, y=None): """this would allow us to fit the model based on the X input.""" super(LabelEncoderPipelineFriendly, self).fit(X) def transform(self, X, y=None): return super(LabelEncoderPipelineFriendly, self).tra...
No
5
20
Data_Transform
categorify
null
1
A
0
3
0
0
0
7
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,085
def prepare_pipeline(df): def get_DayOfWeek(df): return df["DayOfWeek"] def get_Open(df): return df[["Open"]] def get_Promo(df): return df[["Promo"]] def get_StateHoliday(df): return df["StateHoliday"] def get_SchoolHoliday(df): return...
No
5
4
Model_Train
choose_model_class
874,590
2
B
12
12
0
0
115
50
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,086
pipeline = prepare_pipeline(train)
No
3
4
Model_Train
choose_model_class
874,590
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,087
x_train, y_train = pipeline.fit_transform(train), train.Sales x_test = pipeline.transform(test)
No
4
7
Model_Train
train_model
874,590
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,088
params = {"boosting_type" : ["gbdt"], "learning_rate": [0.1], "n_estimators": [200], "objective": ["regression"], "reg_alpha": [1.0],# [0.0, 0.5, 1.0], # no time for an actual CV on kaggle "reg_lambda": [1.0],# [0.0, 0.5, 1.0], "random_state": [0], "...
No
5
59
Model_Train
init_hyperparams
874,590
1
A
0
0
0
0
0
9
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,089
gs = GridSearchCV(LGBMRegressor(), params, scoring=rmspe_scorer, cv=2, n_jobs=1) gs.fit(x_train, y_train)
No
5
6
Hyperparam_Tuning
train_on_grid
874,590
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,090
prediction = gs.predict(x_test)
No
5
48
Model_Evaluation
predict_on_test
874,590
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,091
pd.DataFrame({"Id": test.Id, "Sales": prediction}).to_csv("submission.csv", sep=",", index=False)
No
5
25
Data_Export
save_to_csv
874,590
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,092
def prepare_pipeline_ts(df, min_shift, max_shift): def get_shifted_date(df, for_sales=False): return (df.Date.min() + pd.DateOffset(days_to_shift)) def get_DayOfWeek(df): return df["DayOfWeek"] def get_Open(df): return df[["Open"]] def get_Promo(df): r...
No
5
53
Other
something_strange
874,590
2
B
14
15
2
0
125
61
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,093
test_size = len(test) min_shift = (test.Date.max() - test.Date.min()).days max_shift = 180 to_drop = len(train[train.Date < train.Date.min() + pd.DateOffset(max_shift)])
No
5
77
Other
define_variables
874,590
1
A
0
0
0
0
0
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,094
import warnings warnings.filterwarnings("ignore") #Data Manipulation and Treatment import numpy as np import pandas as pd from datetime import datetime #Plotting and Visualizations import matplotlib.pyplot as plt %matplotlib inline import seaborn as sns from scipy import stats import itertools #Scikit-Learn for Modeli...
No
5
23
Environment
set_options
null
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
0
null
2,095
def str_to_date(date): return datetime.strptime(date, '%Y-%m-%d').date()
No
5
16
Data_Transform
data_type_conversions
null
1
A
0
1
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,096
#The training Set df_train = pd.read_csv("../input/train.csv",sep=',', parse_dates=['Date'] , date_parser=str_to_date, low_memory = False) #Additional Information on those stores df_store = pd.read_csv("../input/store.csv" , low_memory = False)'
No
5
45
Data_Extraction
load_from_csv
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,097
df_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
2,098
df_train.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
2,099
df_train.dtypes,print ("The Train dataset has {} Rows and {} Variables".format(str(df_train.shape[0]),str(df_train.shape[1])))
No
3
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
2,100
df_store.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
2,101
df_store.dtypes ,print ("The Store dataset has {} Rows (which means unique Shops) and {} Variables".format(str(df_store.shape[0]),str(df_store.shape[1])))
No
3
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
2,102
df_train.count(0)/df_train.shape[0] * 100
No
2
54
EDA
count_unique_values
null
1
A
0
0
0
1
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,103
class bert(nn.Module): def __init__(self, bert_path): super().__init__() BERT = BertModel.from_pretrained(bert_path, config = BertConfig.from_pretrained(bert_path, output_hidden_states = True)) self.BERT = BERT self.fc = nn.Sequential(nn.BatchNorm1d(self.BERT.config.hidden_size * 3),...
Yes
3
4
Model_Train
choose_model_class
11,400,829
1
A
1
4
1
0
5
29
ok
12
11
[{"detector": "framework_specific", "framework": "Pandas", "name": "Chain Indexing", "fix": "Use single indexing or .loc[], .iloc[] methods.", "benefits": "Enhances code readability and prevents performance issues.", "location": "Line 23"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selec...
B
Cross-validation not detected=low, Deterministic Algorithm Usage Checker=low, No random seed setting detected=low
[{"type": "Cross-validation not detected", "severity": "low"}, {"type": "Deterministic Algorithm Usage Checker", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}]
["Chain Indexing", "Column Selection Checker", "Data Augmentation Checker", "Early stopping not implemented", "Efficient data loading not detected", "Logging Checker", "Missing class docstring", "Missing function docstring"]
6
B
2,104
epoch_len = 20 model, criteria, optimizer, scheduler = create_model(len(df_train), epoch_len) set_trainable(model.BERT, False) aaa = 0 for t in range(epoch_len): tot_loss = 0 correct_train = 0 val_loss = 0 val_correct = 0 model = model.train() if GPU: model = model.cuda() f...
No
4
7
Model_Train
train_model
11,400,829
1
A
0
8
17
0
0
51
ok
8
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": "PyTorch", "name": "Deterministic Al...
B
Cross-validation not detected=low, Deterministic Algorithm Usage Checker=low, No random seed setting detected=low
[{"type": "Cross-validation not detected", "severity": "low"}, {"type": "Deterministic Algorithm Usage Checker", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}]
["Column Selection Checker", "Data Augmentation Checker", "Early stopping not implemented", "Efficient data loading not detected", "Logging Checker"]
6
B
2,105
def predict(df, dataloader, model): tmp_array = np.zeros((len(df), 3)) with torch.no_grad(): model = model.eval() if GPU: model = model.cuda() j = 0 for item in tqdm(dataloader): token = item[0] at_mask = item[2] ...
No
4
49
Model_Evaluation
compute_test_metric
11,400,829
1
A
0
5
6
0
0
20
ok
5
5
[{"detector": "framework_specific", "framework": "NumPy", "name": "Array Creation Efficiency", "fix": "Specify dtype when creating arrays.", "benefits": "Improves memory efficiency and avoids unnecessary conversions.", "location": "Line 8"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Sele...
B
Deterministic Algorithm Usage Checker=low
[{"type": "Deterministic Algorithm Usage Checker", "severity": "low"}]
["Array Creation Efficiency", "Column Selection Checker", "Efficient data loading not detected", "Missing function docstring"]
6
B
2,106
a = predict(test_2, test_2_loader, bst_model)
No
5
48
Model_Evaluation
predict_on_test
11,400,829
1
A
0
0
0
0
0
1
ok
2
2
[{"detector": "framework_specific", "framework": "PyTorch", "name": "Deterministic Algorithm Usage Checker", "fix": "Enable deterministic algorithms using torch.use_deterministic_algorithms(True).", "benefits": "Ensures consistent results across different hardware and runs.", "location": ""}, {"detector": "hugging_face...
B
Deterministic Algorithm Usage Checker=low
[{"type": "Deterministic Algorithm Usage Checker", "severity": "low"}]
["Efficient data loading not detected"]
6
B
2,107
bla = test_2[['ID']].merge(pd.DataFrame(torch.nn.functional.softmax(torch.tensor(a), dim = 1).numpy()), left_index=True, right_index=True).set_index('ID') bla.columns = ['A', 'B', 'NEITHER'] bla.to_csv('sbmsn2.csv')
No
4
25
Data_Export
save_to_csv
11,400,829
1
A
0
0
0
0
0
3
ok
3
3
[{"detector": "framework_specific", "framework": "Pandas", "name": "Merge Parameter Checker", "fix": "Specify how, on, and validate parameters in merge operations.", "benefits": "Ensures accurate data merging and prevents data loss.", "location": "Line 7"}, {"detector": "framework_specific", "framework": "PyTorch", "na...
B
Deterministic Algorithm Usage Checker=low
[{"type": "Deterministic Algorithm Usage Checker", "severity": "low"}]
["Efficient data loading not detected", "Merge Parameter Checker"]
6
B
2,108
data.columns
No
5
71
Debug
show_columns
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,109
data.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
2,110
data['Type'].unique()
No
5
57
Debug
show_unique_values
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,111
import matplotlib.pyplot as plt import seaborn as sns plt.figure(figsize=(14,6)) plt.subplot(1,2,1) sns.boxplot(data.revenue) plt.subplot(1,2,2) sns.distplot(data.revenue, bins=20, kde=False) plt.show()
No
5
33
Visualization
distribution
null
1
A
0
0
0
0
0
8
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,112
#City distribution data["City"].value_counts().plot(kind='bar')'
No
5
33
Visualization
distribution
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,113
data["Type"].value_counts().plot(kind='bar')'
No
5
33
Visualization
distribution
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,114
data["City Group"].value_counts().plot(kind='bar')'
No
5
33
Visualization
distribution
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,115
# Crrelation between revenue and feature (p)s def numFeaturePlot(): features=(data.loc[:,'P1':'P37']).columns.tolist() plt.figure(figsize=(35,18)) j=1 while j<len(features): col=features[j-1] plt.subplot(6,6,j) sorted_grp = data.groupby(col)["revenue"].sum().sort_values(ascending...
No
5
81
Visualization
relationship
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,116
df_train=df_train.drop(df_train[(df_train.Open == 0) & (df_train.Sales == 0)].index)
No
5
14
Data_Transform
filter
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,117
print ("Our new training set has now {} rows ".format(df_train.shape[0]))
No
3
58
Debug
show_shape
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,118
df_train.Sales.describe() #we see here a minimum of 0 which means some stores even opened got 0 sales on some days.
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
2,119
df_train=df_train.drop(df_train[(df_train.Open == 1) & (df_train.Sales == 0)].index) df_train = df_train.reset_index(drop=True)
No
3
14
Data_Transform
filter
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,120
fig, axes = plt.subplots(1, 2, figsize=(17,3.5)) axes[0].boxplot(df_train.Sales, showmeans=True,vert=False) axes[0].set_xlim(0,max(df_train["Sales"]+1000)) axes[0].set_title('Boxplot For Sales Values') axes[1].hist(df_train.Sales, cumulative=False, bins=20) axes[1].set_title("Sales histogram") axes[1].set_xlim((min(df...
No
5
33
Visualization
distribution
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,121
tst_model = torch.load('/kaggle/input/gendered-model/model1.pth')['model']
No
5
30
Model_Train
load_pretrained
11,400,829
1
A
0
0
0
0
0
1
ok
3
3
[{"detector": "framework_specific", "framework": "PyTorch", "name": "Deterministic Algorithm Usage Checker", "fix": "Enable deterministic algorithms using torch.use_deterministic_algorithms(True).", "benefits": "Ensures consistent results across different hardware and runs.", "location": ""}, {"detector": "hugging_face...
B
Deterministic Algorithm Usage Checker=low
[{"type": "Deterministic Algorithm Usage Checker", "severity": "low"}]
["Efficient data loading not detected", "Hardcoded file path"]
6
B
2,122
avg = df_train.groupby('Month')["Customers"].mean() avg_sales = df_train.groupby('Month')['Sales'].mean() total_sales_customers = df_train.groupby('Store')['Sales', 'Customers'].sum() total_sales_customers.head()'
No
4
60
Data_Transform
groupby
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,123
df_total_sales_customers = pd.DataFrame({'Sales': total_sales_customers['Sales'], 'Customers': total_sales_customers['Customers']}, index = total_sales_customers.index) df_total_sales_customers = df_total_sales_customers.reset_index() ...
No
5
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
2,124
avg_sales_customers = df_train.groupby('Store')['Sales', 'Customers'].mean() avg_sales_customers.head()
No
4
60
Data_Transform
groupby
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,125
df_avg_sales_customers = pd.DataFrame({'Sales': avg_sales_customers['Sales'], 'Customers': avg_sales_customers['Customers']}, index = avg_sales_customers.index) df_avg_sales_customers = df_avg_sales_customers.reset_index() df_stor...
No
4
12
Data_Transform
create_dataframe
244,890
1
A
0
0
0
0
0
6
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
4
A
2,126
df_stores_new = df_total_sales_customers.join(df_store.set_index('Store'), on='Store') df_stores_new.head()
No
4
32
Data_Transform
merge
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,127
b"# b\n# , , b , \n# \n\naverage_storetype = df_stores_new.groupby('StoreType')['Sales', 'Customers', 'CompetitionDistance'].mean()\n\nfig, (axis1,axis2,axis3) = plt.subplots(1,3,figsize=(15,4))\nsns.barplot(average_storetype.index, average_storetype['Sales'], ax=axis1)\nsns.barplot(average_sto...
No
5
33
Visualization
distribution
null
1
A
0
0
0
0
0
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,128
b"# , , \ncomp_sales_cust = pd.DataFrame()\n\ncomp_sales_cust['Customers'] = average_storetype['Customers']\ncomp_sales_cust['Sales'] = average_storetype['Sales']\ncomp_sales_cust['Comp'] = average_storetype['CompetitionDistance']\ncorr_matrix = comp_sales_cust.corr()\n\nplt.subplots(figsize=(13, 9))\ns...
No
5
80
Visualization
heatmap
null
1
A
0
0
0
0
0
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,129
b"# \navg_assort = df_stores_new.groupby('Assortment')['Sales', 'Customers'].mean()\n\nfig, (axis1,axis2) = plt.subplots(1, 2, figsize=(15, 4))\nsns.barplot(avg_assort.index, avg_assort['Sales'], ax=axis1)\nsns.barplot(avg_assort.index, avg_assort['Customers'], ax=axis2)"
No
5
33
Visualization
distribution
null
1
A
0
0
0
0
0
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,130
df_train = pd.read_csv("../input/train.csv") df_store = pd.read_csv("../input/store.csv") df_test = pd.read_csv("../input/test.csv")
No
5
45
Data_Extraction
load_from_csv
244,890
1
A
0
0
0
0
0
3
ok
4
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."]
4
A
2,131
closed_store_ids = df_test["Id"][df_test["Open"] == 0].values df_train['Year'] = df_train['Date'].apply(lambda x: int(x[:4])) df_train['Month'] = df_train['Date'].apply(lambda x: int(x[5:7])) df_train["HolidayBin"] = df_train.StateHoliday.map({"0": 0, "a": 1, "b": 1, "c": 1}) del df_train['Date'] del df_tr...
No
3
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
2,132
df_test['Year'] = df_test['Date'].apply(lambda x: int(x[:4])) df_test['Month'] = df_test['Date'].apply(lambda x: int(x[5:7])) df_test["HolidayBin"] = df_test.StateHoliday.map({"0": 0, "a": 1, "b": 1, "c": 1}) del df_test['Date'] del df_test['StateHoliday'] df_test.head()'
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
2,133
df_test = df_test[df_test["Open"] != 0] df_test[df_test['Store'] == 1].head()'
No
5
14
Data_Transform
filter
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,134
b"# numpy\na = list()\nfor i in df_test['Store']:\n a.append(float(df_store['CompetitionDistance'][df_store['Store'] == i]))\n\ndf_test['CompetitionDistance'] = a\ndf_test.head()"
No
5
8
Data_Transform
feature_engineering
null
1
A
0
0
0
0
0
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,135
a = list() for i in df_train['Store']: a.append(float(df_store['CompetitionDistance'][df_store['Store'] == i])) df_train['CompetitionDistance'] = a df_train['CompetitionDistance'] = df_train['CompetitionDistance'].fillna(df_train['CompetitionDistance'].mean()) df_train.head()
No
4
8
Data_Transform
feature_engineering
244,890
1
A
1
1
1
0
5
6
ok
3
3
[{"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, 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"}]
[]
4
B
2,136
b"# , \ndf_train['CompetitionDistance'] = np.log(df_train['CompetitionDistance'])\ndf_test ['CompetitionDistance'] = np.log(df_test ['CompetitionDistance'])"
No
5
8
Data_Transform
feature_engineering
null
1
A
0
0
0
0
0
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,137
gs_ts = GridSearchCV(LGBMRegressor(), params, scoring=rmspe_scorer, cv=2, n_jobs=1) gs_ts.fit(x_train_ts, y_train_ts)
No
5
6
Hyperparam_Tuning
train_on_grid
874,590
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,138
pd.DataFrame({"Id": test.Id, "Sales": prediction_ts}).to_csv("submission_ts.csv", sep=",", index=False)
No
5
25
Data_Export
save_to_csv
874,590
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,139
# This method helps in understanding the correlation between the different features and the Revenue. def featureCatPlot(col): plt.figure(figsize=(15,6)) i=1 if not data[col].dtype.name=='int64' and not data[col].dtype.name=='float64': plt.subplot(1,2,i) sns.boxplot(x=col,y='revenue',dat...
Yes
5
33
Visualization
distribution
null
1
A
3
3
2
0
14
19
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,140
featureCatPlot('City Group')
No
5
33
Visualization
distribution
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,141
# Splitting 01/31/2018 as 01, 31, 2018 train_date=data['Open Date'].str.split('/', n = 2, expand = True) data['month']=train_date[0] data['days']=train_date[1] data['year']=train_date[2] test_date=test_data['Open Date'].str.split('/', n = 2, expand = True) test_data['month']=test_date[0] test_data['days']=test_date[1]...
No
5
8
Data_Transform
feature_engineering
null
1
A
0
0
0
0
0
9
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,142
featureCatPlot('month')
No
5
33
Visualization
distribution
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,143
data.sort_values('revenue', ascending=False)[:20]
No
5
9
Data_Transform
sort_values
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,144
top_6= data.sort_values('revenue', ascending=False)[:20] plt.figure(figsize=(13,12)) plt.title("The top 6 resturants") sns.barplot(x=top_6['City'], y=top_6['revenue']) '
No
4
9
Data_Transform
sort_values
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,145
best_month= data.sort_values('revenue', ascending=False)[:20]
No
5
9
Data_Transform
sort_values
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,146
plt.figure(figsize=(13,12)) sns.barplot(x=best_month['month'], y=best_month['revenue']) plt.xticks(rotation=60)
No
5
75
Visualization
time_series
null
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,147
# 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 warnings warnings.filterwarnings("ignore") import numpy as np # linear algebra i...
No
4
23
Environment
set_options
2,095,107
1
A
0
0
0
0
0
12
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 25"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
6
A
2,148
sales = pd.read_csv("../input/train.csv") sales.head()
No
5
45
Data_Extraction
load_from_csv
2,095,107
1
A
0
0
0
0
0
2
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/train.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 7"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
6
A
2,149
sales.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
2,150
stores = pd.read_csv("../input/store.csv") stores.head()
No
4
45
Data_Extraction
load_from_csv
2,095,107
1
A
0
0
0
0
0
2
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/store.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 7"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
6
A
2,151
stores.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
2,152
df_train.Customers.describe()
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
2,153
#Number of stores in sales not in stores data print(len(set(sales['Store']) - set(stores['Store'])))
No
5
72
EDA
count_values
2,095,107
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Column Selection Checker"]
6
A
2,154
#Number of test stores not in train stores print(len(set(test['Store']) - set(data['Store'])))
No
5
72
EDA
count_values
2,095,107
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Column Selection Checker"]
6
A
2,155
fig, axes = plt.subplots(1, 2, figsize=(17,3.5)) axes[0].boxplot(df_train.Customers, showmeans=True,vert=False) axes[0].set_xlim(0,max(df_train["Customers"]+100)) axes[0].set_title('Boxplot For Customer Values') axes[1].hist(df_train.Customers, cumulative=False, bins=20) axes[1].set_title("Customers histogram") axes[1...
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
2,156
#Number of train stores not in test stores print(len(set(data['Store']) - set(test['Store'])))
No
5
72
EDA
count_values
2,095,107
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Column Selection Checker"]
6
A