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
1,949
total_epoch = 0 best_loss = 1e6 for i in range(3): print("Epoch", i + 1) total_epoch += 1 train_epoch(resolver, optimizer, train_dl) loss, labels = evaluate(resolver, optimizer, valid_dl) if loss < best_loss: best_loss = loss print(f"Loss improved, saving {total_epoch}") torch.save(resolver.stat...
No
5
7
Model_Train
train_model
3,065,122
1
A
0
2
3
0
0
11
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": "framework_specific", "framework": "ScikitLear...
B
Cross Validation Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}]
["Dependent Threshold Checker", "Magic number"]
1
B
1,950
for param in resolver.encoder.parameters(): param.requires_grad = True
No
4
59
Model_Train
init_hyperparams
3,065,122
1
A
0
1
1
0
0
2
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"]
1
A
1,951
lr = 3e-4 optimizer = torch.optim.Adam(resolver.parameters(), lr=lr)
No
5
4
Model_Train
choose_model_class
3,065,122
1
A
0
0
0
0
0
2
ok
2
2
[{"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": "general_ml", "framework": "Genera...
A
no applicable ML-specific findings
[]
["Dependent Threshold Checker", "Magic number"]
1
A
1,952
x = np.load('../input/prepare-for-submission/0.npy')
No
5
44
Data_Extraction
load_from_disk
3,663,832
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/prepare-for-submission/0.npy. 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
1,953
from keras.models import load_model import tensorflow as tf def logloss(y, y_): return tf.losses.log_loss(y,y_) model = load_model(mf, custom_objects={'logloss':logloss})
No
4
4
Model_Train
choose_model_class
3,663,832
1
A
0
1
0
0
0
5
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
1,954
import gc
No
5
22
Environment
import_modules
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,955
y1 = model.predict(x)
No
5
27
Model_Train
predict_on_train
3,663,832
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "framework_specific", "framework": "TensorFlow", "name": "Memory Release Checker", "fix": "Clear session after model creation/training using tf.keras.backend.clear_session().", "benefits": "Prevents memory leaks and reduces resource usage.", "location": ""}]
A
no applicable ML-specific findings
[]
["Memory Release Checker"]
3
A
1,956
for i in range(6): print("Epoch", i + 1) total_epoch += 1 train_epoch(resolver, optimizer, train_dl) loss, labels = evaluate(resolver, optimizer, valid_dl) if loss < best_loss: best_loss = loss print(f"Loss improved, saving {total_epoch}") torch.save(resolver.state_dict(), data_path/"model_best.pt...
No
4
2
Hyperparam_Tuning
find_best_params
3,065,122
1
A
0
2
3
0
0
9
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": "framework_specific", "framework": "ScikitLear...
B
Cross Validation Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}]
["Dependent Threshold Checker"]
1
B
1,957
resolver.load_state_dict(torch.load(data_path/"model_best.pt"))
No
5
44
Data_Extraction
load_from_disk
3,065,122
1
A
0
0
0
0
0
1
ok
2
2
[{"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"]
1
A
1,958
loss, res = evaluate(resolver, optimizer, test_dl, True) res_s = np.exp(res) # don't forget that we have log-softmax outputs: submission = pd.DataFrame(res_s, index=train["ID"], columns=["A", "B", "NEITHER"]) submission.to_csv("submission.csv", index="id")'
Yes
3
27
Model_Train
predict_on_train
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,959
import pandas as pd import numpy as np import seaborn as sns import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split from sklearn.model_selection import cross_val_score from sklearn.model_selection import GridSearchCV from sklearn.model_sel...
No
5
23
Environment
set_options
244,905
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
0
null
1,960
del x gc.collect()
No
1
53
Other
something_strange
3,663,832
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
1,961
x = np.load('../input/prepare-for-submission-2/1.npy') y2 = model.predict(x) del x gc.collect()
No
2
27
Model_Train
predict_on_train
3,663,832
1
A
0
0
0
0
0
4
ok
2
2
[{"detector": "framework_specific", "framework": "TensorFlow", "name": "Memory Release Checker", "fix": "Clear session after model creation/training using tf.keras.backend.clear_session().", "benefits": "Prevents memory leaks and reduces resource usage.", "location": ""}, {"detector": "general_ml", "framework": "Genera...
A
no applicable ML-specific findings
[]
["Hardcoded file path", "Memory Release Checker"]
3
A
1,962
x = np.load('../input/prepare-for-submission-3/2.npy') y3 = model.predict(x) del x gc.collect()
No
3
27
Model_Train
predict_on_train
3,663,832
1
A
0
0
0
0
0
4
ok
2
2
[{"detector": "framework_specific", "framework": "TensorFlow", "name": "Memory Release Checker", "fix": "Clear session after model creation/training using tf.keras.backend.clear_session().", "benefits": "Prevents memory leaks and reduces resource usage.", "location": ""}, {"detector": "general_ml", "framework": "Genera...
A
no applicable ML-specific findings
[]
["Hardcoded file path", "Memory Release Checker"]
3
A
1,963
y = np.concatenate([y1, y2, y3])
No
5
11
Data_Transform
concatenate
3,663,832
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
1,964
b"df = pd.DataFrame()\ndf['ID'] = pd.read_csv('../input/gendered-pronoun-resolution/test_stage_2.tsv', delimiter='\\t')['ID']"
No
5
45
Data_Extraction
load_from_csv
null
1
A
0
0
0
0
0
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,965
df_train = pd.read_csv('../input/train.csv') df_test = pd.read_csv('../input/test.csv') df_store = pd.read_csv('../input/store.csv')
No
5
45
Data_Extraction
load_from_csv
244,905
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,966
df_s = pd.read_csv('../input/gendered-pronoun-resolution/sample_submission_stage_2.csv')
No
5
45
Data_Extraction
load_from_csv
3,663,832
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/gendered-pronoun-resolution/sample_submission_stage_2.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
1,967
df['A'] = y[:,0] #, 'B', 'NEITHER'
No
5
8
Data_Transform
feature_engineering
3,663,832
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"]
3
A
1,968
df['B'] = y[:,1] df['NEITHER'] = y[:,2]
No
5
8
Data_Transform
feature_engineering
3,663,832
1
A
0
0
0
0
0
2
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"]
3
A
1,969
y = df_train["Sales"].values
No
5
21
Data_Transform
prepare_x_and_y
244,905
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,970
df.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
1,971
df_train['Year'] = df_train['Date'].apply(lambda x: int(x[0:4])) df_train['Month'] = df_train['Date'].apply(lambda x: int(x[5:7])) df_train['Day'] = df_train['Date'].apply(lambda x: int(x[8:10])) df_test['Year'] = df_test['Date'].apply(lambda x: int(x[0:4])) df_test['Month'] = df_test['Date'].apply(lambda x: int(x[5:7]...
No
5
8
Data_Transform
feature_engineering
244,905
1
A
0
0
0
0
0
6
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,972
b"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\n%matplotlib inline\n\nplt.style.use('ggplot')\nplt.rcParams['figure.figsize'] = (12,8)\n\n# \nfont = {'family': 'Verdana',\n 'weight': 'normal'}\nplt.rc('font', **font)"
No
5
23
Environment
set_options
null
1
A
0
0
0
0
0
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,973
data_train = pd.read_csv("../input/train.csv") data_test = pd.read_csv("../input/test.csv") data_store = pd.read_csv("../input/store.csv")
No
5
45
Data_Extraction
load_from_csv
244,962
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."]
3
A
1,974
data_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
1,975
df_store.CompetitionDistance.fillna(value=0, inplace=True) df_test.Open.fillna(value=0, inplace=True) df_train.StateHoliday[df_train["StateHoliday"] == 0] = "0"
Yes
5
17
Data_Transform
correct_missing_values
244,905
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,976
print(df_train.shape) print(df_test.shape) print(df_store.shape)
No
5
58
Debug
show_shape
244,905
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,977
fig, (axis1,axis2) = plt.subplots(1,2,figsize=(12,4)) sns.barplot(x='Year', y='Sales', data=df_train, ax=axis1) sns.barplot(x='Year', y='Customers', data=df_train, ax=axis2)
No
5
75
Visualization
time_series
244,905
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,978
data_train.shape
No
5
58
Debug
show_shape
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,979
df_train.query('Open == 1')[['Sales', 'Customers']].hist(bins=100, figsize=(13,7));
No
5
33
Visualization
distribution
244,905
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,980
data_test.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
1,981
fig, (axis1,axis2) = plt.subplots(1,2,figsize=(12,4)) sns.barplot(x='Month', y='Sales', data=df_train, ax=axis1) sns.barplot(x='Month', y='Customers', data=df_train, ax=axis2)
No
5
75
Visualization
time_series
244,905
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,982
data_store.head(n=3)
No
5
41
Debug
show_table
244,962
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
1,983
fig, (axis1,axis2) = plt.subplots(1,2,figsize=(12,4)) sns.barplot(x='DayOfWeek', y='Sales', data=df_train, ax=axis1) sns.barplot(x='DayOfWeek', y='Customers', data=df_train, ax=axis2)
No
5
75
Visualization
time_series
244,905
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,984
data_train.StateHoliday = data_train.StateHoliday.replace(0,'0') data_test.StateHoliday = data_test.StateHoliday.replace(0,'0') data_train.DayOfWeek.value_counts()
No
4
8
Data_Transform
feature_engineering
244,962
1
A
0
0
0
0
0
3
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"}]
[]
3
B
1,986
df_train[['Sales', 'Customers']].corr()
No
3
41
Debug
show_table
244,905
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,987
df_DayOfWeek = pd.get_dummies(df_train.DayOfWeek, prefix='DayOfWeek') df_StateHoliday = pd.get_dummies(df_train.StateHoliday, prefix="StateHoliday_") df_train = pd.concat([df_train, df_DayOfWeek, df_StateHoliday], axis=1) del df_train["Date"] del df_train["Day"] del df_train["Customers"] del df_train["DayOfWeek"] del d...
Yes
4
12
Data_Transform
create_dataframe
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,988
df_StoreType = pd.get_dummies(df_store.StoreType, prefix='StoreType_') df_Assortment = pd.get_dummies(df_store.Assortment, prefix='Assortment_') df_store = pd.concat([df_store, df_StoreType, df_Assortment], axis=1) del df_store["StoreType"] del df_store["Assortment"] del df_store["PromoInterval"]'
Yes
4
12
Data_Transform
create_dataframe
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,989
df = pd.merge(df_train, df_store, how='left', on=['Store'])
No
5
32
Data_Transform
merge
244,905
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,990
df.fillna(0, inplace=True)
No
5
17
Data_Transform
correct_missing_values
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,991
X = df.values[:,1:]
No
5
21
Data_Transform
prepare_x_and_y
244,905
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,992
parametrs = range(40, 241, 40)
No
5
5
Hyperparam_Tuning
define_search_space
244,905
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,993
b"scores, tst_scr = validation_curve(RandomForestRegressor(n_jobs = 4), X[:20000],\\\n y[:20000], 'n_estimators', parametrs, cv=5, scoring='r2', verbose=2)"
No
5
2
Hyperparam_Tuning
find_best_params
null
1
A
0
0
0
0
0
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,994
scores_mean = scores.mean(axis=1) scores_std = scores.std(axis=1) tst_scr_mean = tst_scr.mean(axis=1) tst_scr_std = tst_scr.std(axis=1) plt.plot(parametrs, tst_scr_mean) plt.fill_between(parametrs, tst_scr_mean + tst_scr_std, tst_scr_mean - tst_scr_std, alpha=0.3) plt.plot(parametrs, scores_mean) plt.fill_between(param...
No
5
35
Visualization
learning_history
244,905
1
A
0
0
0
0
0
8
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,995
parametrs = range(3, 24)
No
5
5
Hyperparam_Tuning
define_search_space
244,905
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,996
b"scores, tst_scr = validation_curve(RandomForestRegressor(n_estimators=120, n_jobs = 4), X[:20000], \\\n y[:20000], 'max_features', parametrs, cv=3, scoring='r2', verbose=2)"
No
5
1
Hyperparam_Tuning
find_best_score
null
1
A
0
0
0
0
0
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,997
data_train['Year'] = data_train['Date'].apply(lambda x: int(x[:4])) data_train['Month'] = data_train['Date'].apply(lambda x: int(x[5:7])) data_train.head()
No
4
8
Data_Transform
feature_engineering
244,962
1
A
0
0
0
0
0
3
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"}]
[]
3
B
1,998
parametrs = range(4, 61, 4)
No
5
5
Hyperparam_Tuning
define_search_space
244,905
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
1,999
average_sales_per_month = data_train.groupby('Month')["Sales"].mean() plt.figure(figsize=(8, 5)) average_sales_per_month.plot(legend=True, marker='o', title="Average sales per month")'
No
4
33
Visualization
distribution
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,000
b"scores, tst_scr = validation_curve(RandomForestRegressor(n_estimators=120, n_jobs = 4, max_features=16), X[:20000], \\\n y[:20000], 'max_depth', parametrs, cv=3, scoring='r2', verbose=2)"
No
5
84
Other
not_enough_vertices
null
1
A
0
0
0
0
0
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,001
average_sales_per_day = data_train.groupby('Date')["Sales"].mean() fig = plt.subplots(1,1, sharex=True, figsize=(18, 5)) average_sales_per_day.plot(legend=True, title="Average Daily Sales")'
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,002
model = RandomForestRegressor(n_estimators=120, max_depth=20, max_features=16, n_jobs=4, verbose=2)
No
5
4
Model_Train
choose_model_class
244,905
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,003
model.fit(X, y)
No
5
7
Model_Train
train_model
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,004
idx = model.feature_importances_.argsort()[::-1]
No
5
79
Visualization
model_coefficients
244,905
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,005
ax = sns.barplot(x=model.feature_importances_[idx], y=df.drop('Store', axis=1).columns[idx])
No
5
79
Visualization
model_coefficients
244,905
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,006
df_DayOfWeek = pd.get_dummies(df_test.DayOfWeek, prefix='DayOfWeek') df_StateHoliday = pd.get_dummies(df_test.StateHoliday, prefix="StateHoliday_") df_StateHoliday = pd.concat([df_StateHoliday, pd.DataFrame(columns=['StateHoliday__b', 'StateHoliday__c'])], axis = 1)'
Yes
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
2,007
columns_corr = ['Sales', 'Customers', 'Promo', 'StateHoliday', 'SchoolHoliday'] data_train[columns_corr].corr(method='pearson')
No
5
40
Debug
show_table_attributes
244,962
1
A
0
0
0
0
0
2
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"}]
[]
3
B
2,008
df_StateHoliday.fillna(0, inplace=True)
No
5
17
Data_Transform
correct_missing_values
244,905
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,011
data_train['StateHoliday'] = data_train['StateHoliday'].replace(0, '0') data_train["HolidayBin"] = data_train['StateHoliday'].map({"0": 0, "a": 1, "b": 1, "c": 1}) data_train.StateHoliday.unique()'
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,013
del df_test["Date"] del df_test["Day"] del df_test["DayOfWeek"] del df_test["StateHoliday"] df_test = pd.concat([df_test, df_DayOfWeek, df_StateHoliday], axis=1) test_df = pd.merge(df_test, df_store, how='left', on=['Store']) test_df.fillna(0, inplace=True)'
Yes
4
12
Data_Transform
create_dataframe
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,014
y_test_pred = model.predict(test_df.values[:,2:])
No
5
48
Model_Evaluation
predict_on_test
244,905
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,015
average_customers_per_month = data_train.groupby('Month')['Customers'].mean() average_sales_per_month = data_train.groupby('Month')['Sales'].mean()
No
4
60
Data_Transform
groupby
244,962
1
A
0
0
0
0
0
2
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"}]
[]
3
B
2,016
submission = pd.DataFrame({ "Id": test_df.Id, "Sales": y_test_pred.reshape(-1.1)})
No
5
12
Data_Transform
create_dataframe
244,905
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,017
plt.figure(figsize=(6, 4)) plt.plot(average_sales_per_month)
No
5
33
Visualization
distribution
244,962
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
2,018
plt.figure(figsize=(6, 4)) plt.plot(average_customers_per_month)
No
5
33
Visualization
distribution
244,962
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
2,019
submission.to_csv("rossman.csv",index=False)
No
5
25
Data_Export
save_to_csv
244,905
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,020
import pandas as pd import sklearn import numpy as np import matplotlib.pyplot as plt from sklearn.ensemble import RandomForestRegressor import seaborn as sns %matplotlib inline
No
5
23
Environment
set_options
245,675
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
0
null
2,021
total_customers_for_store = data_train.groupby('Store')['Sales', 'Customers'].sum()
No
5
60
Data_Transform
groupby
244,962
1
A
0
0
0
0
0
1
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"}]
[]
3
B
2,022
data_total_customers_for_store = pd.DataFrame({'Sales': total_customers_for_store['Sales'], 'Customers': total_customers_for_store['Customers']}, index = total_customers_for_store.index)
No
5
12
Data_Transform
create_dataframe
244,962
1
A
0
0
0
0
0
3
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
2,023
storedf = pd.read_csv("../input/store.csv") storedf = storedf [["Store", "Assortment", "CompetitionDistance","Promo2"]] storedf = storedf.set_index("Store") storedf.CompetitionDistance = storedf.CompetitionDistance.fillna(storedf.CompetitionDistance.max()) storedf.head()
Yes
3
45
Data_Extraction
load_from_csv
245,675
1
A
0
0
0
0
0
5
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,024
data_total_customers_for_store = data_total_customers_for_store.reset_index()
No
5
61
Data_Transform
rename_columns
244,962
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
2,025
average_sales_customers = data_train.groupby('Store')['Sales', 'Customers'].mean()
No
5
60
Data_Transform
groupby
244,962
1
A
0
0
0
0
0
1
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"}]
[]
3
B
2,026
def f(traindf): #traindf = traindf[traindf.Open==1] traindf = traindf.join(storedf, on="Store") traindf['isWeekEnd'] = traindf.DayOfWeek>=5 traindf['Month'] = list (map (lambda x: int(x[5:7]), traindf.Date)) traindf['Day'] = list (map (lambda x: int(x[8:]), traindf.Date)) traindf['isWinter'] = ...
Yes
3
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,027
data_average_sales_customers = pd.DataFrame({'Sales': average_sales_customers['Sales'], 'Customers': average_sales_customers['Customers']}, index = average_sales_customers.index) data_average_sales_customers = data_average_sales_custom...
Yes
4
12
Data_Transform
create_dataframe
244,962
1
A
0
0
0
0
0
6
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
2,028
data_average_sales_customers = pd.DataFrame({'Sales': average_sales_customers['Sales'], 'Customers': average_sales_customers['Customers']}, index = average_sales_customers.index)
No
5
12
Data_Transform
create_dataframe
244,962
1
A
0
0
0
0
0
3
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
2,029
traindf = pd.read_csv("../input/train.csv", low_memory=False) traindf = f(traindf) traindf = traindf[traindf.Open == 1] ytrain = traindf.Sales.values del traindf ["Sales"] del traindf ["Customers"] del traindf ["Open"] traindf.head()
Yes
4
45
Data_Extraction
load_from_csv
245,675
1
A
0
0
0
0
0
8
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,030
data_average_sales_customers = data_average_sales_customers.reset_index()
No
5
84
Other
not_enough_vertices
244,962
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
2,031
testdf = pd.read_csv("../input/test.csv") testdf = f(testdf) testdf.head()
Yes
4
45
Data_Extraction
load_from_csv
245,675
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,032
data_stores_average = data_average_sales_customers.join(data_store.set_index('Store'), on='Store')
No
5
32
Data_Transform
merge
244,962
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
2,033
model = RandomForestRegressor(min_samples_leaf=2, max_depth=30, n_estimators=30) %time model.fit(traindf.values, ytrain)
No
5
7
Model_Train
train_model
245,675
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,034
data_stores_average.head(n=3)
No
5
41
Debug
show_table
244,962
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
2,035
data_stores_new = data_total_customers_for_store.join(data_store.set_index('Store'), on='Store')
No
5
32
Data_Transform
merge
244,962
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
2,036
average_store_type = data_stores_new.groupby('StoreType')['Sales', 'Customers', 'CompetitionDistance'].mean()
No
5
60
Data_Transform
groupby
244,962
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
2,038
y = model.predict(testdf.values[:, 2:]) df = pd.DataFrame([]) df['Sales'] = y df['Sales'][testdf.Open == 0] = 0 df = df.set_index(testdf.Id) pd.DataFrame.to_csv(df, 'ans.csv') df.head()
Yes
4
27
Model_Train
predict_on_train
245,675
1
A
0
0
0
0
0
7
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,039
Data_cmp = pd.DataFrame() Data_cmp['Customers'] = average_store_type['Sales'] Data_cmp['Sales'] = average_store_type['Customers'] Data_cmp['Comp'] = average_store_type['CompetitionDistance']
No
4
12
Data_Transform
create_dataframe
244,962
1
A
0
0
0
0
0
4
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
2,040
columns_corr = ['Sales', 'Customers', 'Comp'] Data_cmp[columns_corr].corr(method='pearson')
No
5
40
Debug
show_table_attributes
244,962
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
2,041
average_assort = data_stores_new.groupby('Assortment')['Sales', 'Customers'].mean()
No
5
60
Data_Transform
groupby
244,962
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
2,043
closed_store_data = data_test["Id"][data_test["Open"] == 0].values data_train.StateHoliday = data_train.StateHoliday.replace(0,'0') data_test.StateHoliday = data_test.StateHoliday.replace(0,'0')'
No
5
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,044
data_train['Year'] = data_train['Date'].apply(lambda x: int(x[:4])) data_train['Month'] = data_train['Date'].apply(lambda x: int(x[5:7])) data_train["HolidayBin"] = data_train.StateHoliday.map({"0": 0, "a": 1, "b": 1, "c": 1})'
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,045
del data_train['Date'] del data_train['StateHoliday']
No
5
10
Data_Transform
drop_column
244,962
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
2,046
data_test['Year'] = data_test['Date'].apply(lambda x: int(x[:4])) data_test['Month'] = data_test['Date'].apply(lambda x: int(x[5:7])) data_test["HolidayBin"] = data_test.StateHoliday.map({"0": 0, "a": 1, "b": 1, "c": 1})'
No
5
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,047
del data_test['Date'] del data_test['StateHoliday']
No
5
10
Data_Transform
drop_column
244,962
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
2,048
data_test = data_test[data_test["Open"] != 0]
No
5
14
Data_Transform
filter
244,962
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
2,049
data_test[data_test['Store'] == 1].head()
No
5
41
Debug
show_table
244,962
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
2,050
arr_tmp = [] for i in data_test['Store']: arr_tmp.append(float(data_store['CompetitionDistance'][data_store['Store'] == i])) data_test['CompetitionDistance'] = arr_tmp
No
3
8
Data_Transform
feature_engineering
244,962
1
A
0
1
1
0
0
4
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
2,051
arr_tmp = [] for i in data_train['Store']: arr_tmp.append(float(data_store['CompetitionDistance'][data_store['Store'] == i])) data_train['CompetitionDistance'] = arr_tmp data_train['CompetitionDistance'] = data_train['CompetitionDistance'].fillna(data_train['CompetitionDistance'].mean())
No
3
8
Data_Transform
feature_engineering
244,962
1
A
0
1
1
0
0
5
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"}]
[]
3
B
2,052
train_stores = dict(list(data_train.groupby('Store'))) test_stores = dict(list(data_test.groupby('Store')))
No
4
60
Data_Transform
groupby
244,962
1
A
0
0
0
0
0
2
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"}]
[]
3
B
2,053
from sklearn.linear_model import LinearRegression from sklearn.ensemble import RandomForestRegressor from sklearn.model_selection import GridSearchCV
No
5
22
Environment
import_modules
244,962
1
A
0
0
0
0
0
3
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
2,055
# result = pd.Series() for i in test_stores: store = train_stores[i] X_train = store.drop(["Sales", "Store", "Customers"],axis=1) Y_train = store["Sales"] X_test = test_stores[i].copy() store_ind = X_test["Id"] X_test.drop(["Id","Store"], axis=1,inplace=True) X_train = X_train.fil...
Yes
4
25
Data_Export
save_to_csv
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null