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
5,785
model.fit(X_train1,y_train1)
No
5
7
Model_Train
train_model
8,666,356
1
A
0
0
0
0
0
1
ok
4
4
[{"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"}]
["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
3
B
5,786
(pd.DataFrame([X_train.columns,model.feature_importances_],columns=feature).T).plot.bar()
No
5
79
Visualization
model_coefficients
8,666,356
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"}]
[]
3
B
5,787
holidays = X_test1['IsHoliday'].to_numpy() y_test1 = y_test1.to_numpy()
No
5
16
Data_Transform
data_type_conversions
8,666,356
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
5,788
result = model.predict(X_test1)
No
5
48
Model_Evaluation
predict_on_test
8,666,356
1
A
0
0
0
0
0
1
ok
2
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"]
3
A
5,789
WMAE = wmae(result, y_test1, holidays) print(WMAE)
No
5
49
Model_Evaluation
compute_test_metric
8,666,356
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
5,790
'''from sklearn.model_selection import GridSearchCV # Create the parameter grid based on the results of random search param_grid = { 'bootstrap': [True], 'max_depth': [80, 90, 100, 110], 'max_features': [2, 3], 'min_samples_leaf': [3, 4, 5], 'min_samples_split': [8, 10, 12], 'n_estimators': [10...
Yes
4
5
Hyperparam_Tuning
define_search_space
8,666,356
1
A
1
0
0
0
5
0
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
5,792
grid_search.best_params_
No
5
2
Hyperparam_Tuning
find_best_params
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,794
data_dmatrix = xgb.DMatrix(data=X_train,label=y_train)
No
5
84
Other
not_enough_vertices
8,666,356
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
5,795
xg_reg = xgb.XGBRegressor(objective ='reg:linear', colsample_bytree = 0.3, learning_rate = 0.1, # max_depth = 5, alpha = 10, n_estimators = 10)
No
5
4
Model_Train
choose_model_class
8,666,356
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
3
null
5,796
xg_reg.fit(X_train1,y_train1) result = xg_reg.predict(X_test1)
Yes
4
7
Model_Train
train_model
8,666,356
1
A
0
0
0
0
0
2
ok
8
7
[{"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, 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"}]
["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"]
3
B
5,801
%%time from sklearn.ensemble import RandomForestRegressor #model = RandomForestRegressor(bootstrap= True, max_depth= 110, max_features= 3, min_samples_leaf= 3, min_samples_split= 8, n_estimators= 200) model = RandomForestRegressor(n_estimators= 500) model.fit(X_train,y_train) result = model.predict(X_test)
Yes
4
7
Model_Train
train_model
8,666,356
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
3
null
5,802
sub = pd.read_csv("/kaggle/input/walmart-recruiting-store-sales-forecasting/sampleSubmission.csv.zip")
No
5
45
Data_Extraction
load_from_csv
8,666,356
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: /kaggle/input/walmart-recruiting-store-sales-forecasting/sampleSubmission.csv.zip. 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
5,803
sub["Weekly_Sales"] = result sub.head()
Yes
4
55
Data_Export
prepare_output
8,666,356
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
5,804
sub.to_csv("walmart_predict_sub.csv",index=False)
No
5
25
Data_Export
save_to_csv
8,666,356
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
5,805
import numpy as np import scipy as sp import pandas as pd import matplotlib.pyplot as plt import random import os import sys import re from datetime import datetime import math from subprocess import check_output print(check_output(["ls", "../input"]).decode("utf8"))
No
4
22
Environment
import_modules
null
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 13"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
0
A
5,806
pd.options.display.max_colwidth = 400 from IPython.display import FileLink, FileLinks
Yes
5
23
Environment
set_options
7,463,061
1
A
0
0
0
0
0
2
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Magic number detected: 400", "fix": "Not specified", "benefits": "Not specified", "location": "Line 3"}]
A
no applicable ML-specific findings
[]
["Magic number"]
2
A
5,807
train = pd.read_csv('/kaggle/input/web-traffic-time-series-forecasting/train_2.csv.zip') keys = pd.read_csv('/kaggle/input/web-traffic-time-series-forecasting/key_2.csv.zip') sub = pd.read_csv('/kaggle/input/web-traffic-time-series-forecasting/sample_submission_2.csv.zip')
No
5
45
Data_Extraction
load_from_csv
7,463,061
1
A
0
0
0
0
0
3
ok
3
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: /kaggle/input/web-traffic-time-series-forecasting/train_2.csv.zip. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 3"}, {"detector": "genera...
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
2
A
5,808
keys.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
5,809
def split_page_col(page): tokens = page.split('_') article_name = ''.join(tokens[:-3]) org = tokens[-3] access = tokens[-2] crawler = tokens[-1] return (article_name, org, access, crawler) def split_page_col_wdate(page): tokens = page.split('_') article_name = ''.join(tokens[:-4]) o...
No
5
78
Data_Transform
string_transform
7,463,061
1
A
0
2
0
0
0
15
ok
3
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": "general_ml", "framework": "General ML", "name": "Missing docstring for...
A
no applicable ML-specific findings
[]
["Column Selection Checker", "Missing function docstring"]
2
A
5,810
keys['date'] = keys['Page'].apply(lambda x: x.split('_')[-1]) keys['Page'] = keys['Page'].apply(lambda x: '_'.join(x.split('_')[:-1])) keys['date'] = pd.to_datetime(keys['date'], format='%Y-%m-%d')
No
5
8
Data_Transform
feature_engineering
7,463,061
1
A
0
0
0
0
0
3
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"]
2
A
5,811
keys.tail()
No
5
41
Debug
show_table
7,463,061
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
5,812
sub = sub.merge(keys, on='Id', how='left')
No
5
32
Data_Transform
merge
7,463,061
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
5,813
sub['date'] = pd.to_datetime(sub['date'], format='%Y-%m-%d')
No
5
16
Data_Transform
data_type_conversions
7,463,061
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"]
2
A
5,814
print(sub['date'].min(), sub['date'].max()) print(sub['date'].max() - sub['date'].min())
No
3
40
Debug
show_table_attributes
7,463,061
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"]
2
A
5,815
print(sub['Page'].nunique()) print(train['Page'].nunique())
No
5
54
EDA
count_unique_values
7,463,061
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"]
2
A
5,816
train.iloc[:, 755:803]
No
5
14
Data_Transform
filter
7,463,061
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
5,817
print(sub.shape) print(train.shape)
No
5
58
Debug
show_shape
7,463,061
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
5,818
prev_year_data_cols = pd.date_range('2016-09-13', '2016-11-13') train_flat = pd.melt(train.loc[:, ['Page'] + list(prev_year_data_cols.date.astype(str))], id_vars='Page', var_name='date') train_flat['date'] = pd.to_datetime(train_flat['date'], format='%Y-%m-%d')
Yes
4
16
Data_Transform
data_type_conversions
7,463,061
1
A
0
0
0
0
0
3
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"]
2
A
5,819
train_flat.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
5,820
train_flat['prediction_date'] = train_flat['date'] + pd.DateOffset(years=1) sub = sub[['Page', 'date', 'Id']].merge(train_flat[['Page', 'prediction_date', 'value']], left_on=('Page', 'date'), right_on=('Page', 'prediction_date')) sub['value'] = sub['value'].fillna(0)
Yes
3
32
Data_Transform
merge
7,463,061
1
A
0
0
0
0
0
3
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
5,821
sub[['Id', 'value']].rename(columns={'value': 'visits'}).to_csv('all_submission.csv', index=False) FileLink('all_submission.csv')
Yes
5
25
Data_Export
save_to_csv
7,463,061
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
5,822
page_median = train.iloc[:, 1:].median(axis=1, skipna=True)
No
3
40
Debug
show_table_attributes
7,463,061
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
5,823
page_median = pd.DataFrame({'Page': train['Page'], 'median': page_median})
No
5
12
Data_Transform
create_dataframe
7,463,061
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"]
2
A
5,824
page_median.head()
No
5
41
Debug
show_table
7,463,061
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
5,825
sub_median = sub.merge(page_median, on='Page')[['Id', 'median']]
No
5
32
Data_Transform
merge
7,463,061
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
5,826
sub_median.isnull().mean()
No
3
40
Debug
show_table_attributes
7,463,061
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
5,827
sub_median
No
5
53
Other
something_strange
7,463,061
1
A
0
0
0
1
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
5,828
sub_median.rename(columns={'median': 'visits'}).to_csv('submission.csv', index=False) FileLink('submission.csv')
Yes
5
25
Data_Export
save_to_csv
7,463,061
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
5,829
prev_year_data_cols = pd.date_range('2016-09-13', '2016-11-13') prev_year_median = train.loc[:, list(prev_year_data_cols.date.astype(str))].median(axis=1, skipna=True)
Yes
5
77
Other
define_variables
7,463,061
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
5,830
prev_year_median = pd.DataFrame({'Page': train['Page'], 'visits': prev_year_median})
No
5
12
Data_Transform
create_dataframe
7,463,061
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"]
2
A
5,831
sub_prev_year_median = sub.merge(prev_year_median, on='Page')[['Id', 'visits']]
No
5
32
Data_Transform
merge
7,463,061
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
5,832
sub_prev_year_median.isnull().mean()
No
4
57
Debug
show_unique_values
7,463,061
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
5,833
sub_prev_year_median['visits'] = sub_prev_year_median['visits'].fillna(sub_prev_year_median['visits'].median())
No
5
17
Data_Transform
correct_missing_values
7,463,061
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"]
2
A
5,835
median_60 = train.iloc[:, -60:].median(axis=1, skipna=True) median_60 = pd.DataFrame({'Page': train['Page'], 'visits': median_60}) sub_median_60 = sub.merge(median_60, on='Page')[['Id', 'visits']]
Yes
4
12
Data_Transform
create_dataframe
7,463,061
1
A
0
0
0
0
0
3
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"]
2
A
5,836
sub_median_60.isnull().mean()
No
3
57
Debug
show_unique_values
7,463,061
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
5,837
sub_median_60['visits'] = sub_median_60['visits'].fillna(0)
No
5
17
Data_Transform
correct_missing_values
7,463,061
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"]
2
A
5,839
# Libraries import numpy as np import pandas as pd pd.set_option('max_columns', None) import matplotlib.pyplot as plt import seaborn as sns plt.style.use('seaborn') %matplotlib inline import copy import datetime import lightgbm as lgb from scipy import stats from sklearn.model_selection import train_test_split, Stratif...
Yes
5
23
Environment
set_options
null
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
0
null
5,840
class LGBWrapper(object): """ A wrapper for lightgbm model so that we will have a single api for various models. """ def __init__(self): self.model = lgb.LGBMClassifier() def fit(self, X_train, y_train, X_valid=None, y_valid=None, X_holdout=None, y_holdout=None, params=None): eval...
Yes
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
5,841
class ClassifierModel(object): """ A wrapper class for classification models. It can be used for training and prediction. Can plot feature importance and training progress (if relevant for model). """ def __init__(self, columns: list = None, model_wrapper=None): """ :param ori...
Yes
5
53
Other
something_strange
null
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
0
null
5,842
data_dict = {} for i in glob.glob('/kaggle/input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/*'): name = i.split('/')[-1].split('.')[0] if name != 'MTeamSpellings': data_dict[name] = pd.read_csv(i) else: data_dict[name] = pd.read_csv(i, encoding='cp1252'...
No
3
45
Data_Extraction
load_from_csv
null
1
A
0
2
4
0
0
7
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,843
data_dict.keys()
No
2
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
5,844
data_dict['MNCAATourneySeeds'].head()
No
5
41
Debug
show_table
7,982,339
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,845
data_dict['MNCAATourneyCompactResults'].head()
No
5
41
Debug
show_table
7,982,339
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,846
data_dict['MNCAATourneyCompactResults'].groupby(['Season'])['WScore'].mean().plot(kind='line'); plt.title('Mean scores of winning teams by season in tourneys');
No
5
75
Visualization
time_series
7,982,339
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,847
data_dict['MRegularSeasonCompactResults']
No
5
41
Debug
show_table
7,982,339
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,848
data_dict['MRegularSeasonCompactResults'].groupby(['Season'])['WScore'].mean().plot(); plt.title('Mean scores of winning teams by season in regular plays');
No
5
75
Visualization
time_series
7,982,339
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,849
# process seed data_dict['MNCAATourneySeeds'] = data_dict['MNCAATourneySeeds'].loc[data_dict['MNCAATourneySeeds']['Season'] <= 2014] data_dict['MNCAATourneySeeds']['Seed'] = data_dict['MNCAATourneySeeds']['Seed'].apply(lambda x: int(x[1:3])) # take only useful columns data_dict['MNCAATourneySeeds'] = data_dict['MNCAATo...
Yes
3
8
Data_Transform
feature_engineering
7,982,339
1
A
0
0
0
0
0
11
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,850
team_win_score = data_dict['MRegularSeasonCompactResults'].groupby(['Season', 'WTeamID']).agg({'WScore':['sum', 'count']}).reset_index() team_win_score.columns = ['Season', 'WTeamID', 'WScore_sum', 'WScore_count'] team_loss_score = data_dict['MRegularSeasonCompactResults'].groupby(['Season', 'LTeamID']).agg({'LScore':[...
Yes
3
32
Data_Transform
merge
7,982,339
1
A
0
0
0
0
0
10
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,851
df_win = df.copy() df_los = df.copy() df_win = df_win[['WSeed', 'LSeed', 'x_score', 'y_score', 'x_count', 'y_count']] df_los = df_los[['LSeed', 'WSeed', 'y_score', 'x_score', 'y_count', 'x_count']] df_win.columns = ['Seed_1', 'Seed_2', 'Score_1', 'Score_2', 'Count_1', 'Count_2'] df_los.columns = ['Seed_1', 'Seed_2', 'S...
Yes
4
12
Data_Transform
create_dataframe
7,982,339
1
A
0
0
0
0
0
6
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,852
df_win['Seed_diff'] = df_win['Seed_1'] - df_win['Seed_2'] df_win['Score_diff'] = df_win['Score_1'] - df_win['Score_2'] df_los['Seed_diff'] = df_los['Seed_1'] - df_los['Seed_2'] df_los['Score_diff'] = df_los['Score_1'] - df_los['Score_2'] df_win['Count_diff'] = df_win['Count_1'] - df_win['Count_2'] df_win['Mean_score1'...
No
3
8
Data_Transform
feature_engineering
7,982,339
1
A
0
0
0
0
0
12
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,853
df_win['result'] = 1 df_los['result'] = 0 data = pd.concat((df_win, df_los)).reset_index(drop=True)
No
4
11
Data_Transform
concatenate
null
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,854
for col in ['Score_1', 'Score_2', 'Count_1', 'Count_2', 'Score_diff', 'Count_diff']: print(col) data[col] = data[col].fillna(0).astype(int)
No
5
17
Data_Transform
correct_missing_values
7,982,339
1
A
0
1
1
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,855
X = data.drop(['result'], axis=1) y = data['result']
No
5
21
Data_Transform
prepare_x_and_y
7,982,339
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,856
# some of params are from this kernel: https://www.kaggle.com/ratan123/march-madness-2020-ncaam-simple-lightgbm-on-kfold param = {'n_estimators':10000, 'num_leaves': 400, 'min_child_weight': 0.034, 'feature_fraction': 0.379, 'bagging_fraction': 0.418, 'min_data_in_leaf'...
Yes
3
59
Model_Train
init_hyperparams
null
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
0
null
5,857
test = pd.read_csv('../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MSampleSubmissionStage1_2020.csv') test = test.drop(['Pred'], axis=1) test['Season'] = test['ID'].apply(lambda x: int(x.split('_')[0])) test['Team1'] = test['ID'].apply(lambda x: int(x.split('_')[1])) test['Team2'] = test['ID']...
Yes
2
45
Data_Extraction
load_from_csv
7,982,339
1
A
0
0
0
0
0
12
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,858
test['x_score'] = test['WScore_sum_x'] + test['LScore_sum_y'] test['y_score'] = test['WScore_sum_y'] + test['LScore_sum_x'] test['x_count'] = test['WScore_count_x'] + test['LScore_count_y'] test['y_count'] = test['WScore_count_y'] + test['WScore_count_x']
No
5
8
Data_Transform
feature_engineering
7,982,339
1
A
0
0
0
0
0
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,859
test = test[['Seed_x', 'Seed_y', 'x_score', 'y_score', 'x_count', 'y_count']] test.columns = ['Seed_1', 'Seed_2', 'Score_1', 'Score_2', 'Count_1', 'Count_2']
No
4
10
Data_Transform
drop_column
7,982,339
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,860
test['Seed_diff'] = test['Seed_1'] - test['Seed_2'] test['Score_diff'] = test['Score_1'] - test['Score_2'] test['Seed_diff'] = test['Seed_1'] - test['Seed_2'] test['Score_diff'] = test['Score_1'] - test['Score_2'] test['Count_diff'] = test['Count_1'] - test['Count_2'] test['Mean_score1'] = test['Score_1'] / test['Coun...
No
5
8
Data_Transform
feature_engineering
7,982,339
1
A
0
0
0
0
0
12
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,861
test_preds = lgb_model.predict(test)
No
5
48
Model_Evaluation
predict_on_test
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,862
plt.hist(test_preds);
No
5
56
Visualization
plot_predictions
7,982,339
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,863
submission_df = pd.read_csv('../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MSampleSubmissionStage1_2020.csv') submission_df['Pred'] = test_preds submission_df
Yes
5
45
Data_Extraction
load_from_csv
null
1
A
0
0
0
1
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,864
submission_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
5,865
import numpy as np # linear algebra import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) import matplotlib.pyplot as plt from itertools import cycle, islice import seaborn as sb import matplotlib.dates as dates import datetime as dt import plotly.offline as py py.init_notebook_mode(connected=True) fr...
No
4
88
Debug
list_files
null
1
A
0
2
3
0
0
17
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 17"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
0
A
5,866
train_data = pd.read_csv("/kaggle/input/covid19-global-forecasting-week-4/train.csv")#index_col=0 display(train_data.head()) test_data = pd.read_csv("/kaggle/input/covid19-global-forecasting-week-4/test.csv")#index_col=0 display(test_data.head())
Yes
4
45
Data_Extraction
load_from_csv
null
2
B
2
0
0
0
10
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,867
sum_df = pd.pivot_table(train_data, values=['ConfirmedCases','Fatalities'], index=['Date'],aggfunc=np.sum) display(sum_df.max())
Yes
3
12
Data_Transform
create_dataframe
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,868
def getColumnInfo(df): n_province = df['Province_State'].nunique() n_country = df['Country_Region'].nunique() n_days = df['Date'].nunique() start_date = df['Date'].unique()[0] end_date = df['Date'].unique()[-1] return n_province, n_country, n_days, start_date, end_date n_train = tra...
No
3
54
EDA
count_unique_values
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,869
prob_confirm_check_train = train_data.ConfirmedCases.value_counts(normalize=True) prob_fatal_check_train = train_data.Fatalities.value_counts(normalize=True) n_confirm_train = train_data.ConfirmedCases.value_counts()[1:].sum() n_fatal_train = train_data.Fatalities.value_counts()[1:].sum() print('Percentage of confirm...
No
3
72
EDA
count_values
null
1
A
0
0
0
0
0
6
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,870
from itertools import cycle, islice discrete_col = list(islice(cycle(['orange', 'r', 'g', 'k', 'b', 'c', 'm']), None, len(train_data_by_country_confirm.head(30)))) plt.rcParams.update({'font.size': 22}) train_data_by_country_confirm.head(20).plot(figsize=(20,15), kind='barh', color=discrete_col) plt.legend(["Confirmed ...
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
5,871
def reformat_time(reformat, ax): ax.xaxis.set_major_locator(dates.WeekdayLocator()) ax.xaxis.set_major_formatter(dates.DateFormatter('%b %d')) if reformat: #reformat again if you wish date_list = train_data_by_date.reset_index()["Date"].tolist() x_ticks = [dt.datetime.strftime(t,'%Y-%m-%...
No
4
75
Visualization
time_series
null
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
0
null
5,872
fig = plt.figure() fig,(ax4,ax5) = plt.subplots(1,2,figsize=(20, 8)) #train_data_by_date.loc[(train_data_by_date.ConfirmedCases > 200)]#useless, its already summed. train_data_by_date.MortalityRate.plot(ax=ax4, x_compat=True, legend='Mortality Rate',color='r')#tell pandas not to use its own datetime format reformat_tim...
No
4
75
Visualization
time_series
null
1
A
0
1
1
0
0
10
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,873
train_data_by_max_date = train_data_by_country.query('(Date == @max_train_date) & (ConfirmedCases > 100)') train_data_by_max_date.loc[:, 'MortalityRate'] = train_data_by_max_date.loc[:,'Fatalities']/train_data_by_max_date.loc[:,'ConfirmedCases'] train_data_by_mortality = train_data_by_max_date.sort_values('MortalityRat...
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
5,874
#import plotly.io as pio # to set shahin plot layout world_df = train_data_by_country.query('Date == @max_train_date') world_df.loc[:,'Date'] = world_df.loc[:,'Date'].apply(str) world_df.loc[:,'Confirmed_log'] = round(np.log10(world_df.loc[:,'ConfirmedCases'] + 1), 3) world_df.loc[:,'Fatalities...
No
5
84
Other
not_enough_vertices
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,875
fig2 = px.scatter_geo(world_df, locations="Country_Region", locationmode="country names", color="ConfirmedCases", size='ConfirmedCases', hover_name="Country_Region", hover_data=['ConfirmedCases', 'Fatalities', ...
No
5
84
Other
not_enough_vertices
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,877
from sklearn.linear_model import Ridge from sklearn.preprocessing import PolynomialFeatures from sklearn.pipeline import make_pipeline from tqdm import tqdm plt.rcParams.update({'font.size': 12}) fig,(ax0,ax1) = plt.subplots(1,2,figsize=(20, 8)) countries_europe = ['Italy', 'France', 'Spain', 'Germany', 'United Kingd...
Yes
5
56
Visualization
plot_predictions
null
1
A
5
1
1
0
25
40
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...
B
Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low, Pipeline Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"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
B
5,878
from scipy.optimize.minpack import curve_fit from sklearn.metrics import r2_score from scipy.special import expit def Gompertz(a, c, t, t0): Q = a * np.exp(-np.exp(-c*(t-t0))) return Q def Boltzman(a, c, t, t0): Q = a / (1 + np.exp(-c*(t-t0))) return Q emerging_countries = ['Albania', 'Andorra', 'A...
Yes
3
33
Visualization
distribution
null
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
0
null
5,879
nCountries= train_data['Country_Region'].unique() isState = bool x_train = range(n_train_days) x_test = range(n_train_days+n_test_days-overlap_days) for country in tqdm(nCountries): fig,(ax0,ax1) = plt.subplots(1,2,figsize=(20,8)) fig,(ax2,ax3) = plt.subplots(1,2,figsize=(20,8)) #print('\ \ \ \ country...
Yes
3
56
Visualization
plot_predictions
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
5,880
submit_data = pd.read_csv("/kaggle/input/covid19-global-forecasting-week-4/submission.csv")#, index_col=0) test_data['Fatalities'] = test_data['Fatalities'].fillna(0.0).astype(int) test_data['ConfirmedCases'] = test_data['ConfirmedCases'].fillna(0.0).astype(int) submit_data['Fatalities'] = test_data['Fatalities'].ast...
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
5,881
display(submit_data.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
5,882
import numpy as np import pandas as pd from sklearn.model_selection import train_test_split df = pd.read_csv('../input/44352/training_solutions_rev1.csv') df_train, df_test = train_test_split(df, test_size=.2) df_train.shape, df_test.shape
No
3
45
Data_Extraction
load_from_csv
4,373,850
1
A
1
0
0
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": "framework_specific", "framework": "ScikitLear...
B
Cross Validation Checker=low, Randomness Control Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Randomness Control Checker", "severity": "low"}]
["Hardcoded file path"]
3
B
5,883
from skimage.transform import resize from tqdm import tqdm import matplotlib.pyplot as plt %matplotlib inline ORIG_SHAPE = (424,424) CROP_SIZE = (256,256) IMG_SHAPE = (64,64) def get_image(path, x1,y1, shape, crop_size): x = plt.imread(path) x = x[x1:x1+crop_size[0], y1:y1+crop_size[1]] x = res...
Yes
3
44
Data_Extraction
load_from_disk
4,373,850
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
3
null
5,884
from keras.models import Sequential from keras.layers import Conv2D, MaxPooling2D from keras.layers import Activation, Dropout, Flatten, Dense, BatchNormalization, GlobalMaxPooling2D from keras import backend as K def root_mean_squared_error(y_true, y_pred): return K.sqrt(K.mean(K.square(y_pred - y_true))) m...
Yes
5
4
Model_Train
choose_model_class
4,373,850
1
A
0
1
0
0
0
33
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
5,885
batch_size = 128 model.fit(X_train, y_train, epochs=30, validation_data=(X_test, y_test))
No
5
7
Model_Train
train_model
4,373,850
1
A
0
0
0
0
0
2
ok
4
4
[{"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"}]
["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
3
B
5,886
import os from tqdm import tqdm def test_image_generator(ids, shape=IMG_SHAPE): x1 = (ORIG_SHAPE[0]-CROP_SIZE[0])//2 y1 = (ORIG_SHAPE[1]-CROP_SIZE[1])//2 x_batch = [] for i in ids: x = get_image('../input/44352/images_test_rev1/'+i, x1, y1, shape=IMG_SHAPE, crop_size=CROP_SIZE) x_batch....
Yes
2
48
Model_Evaluation
predict_on_test
4,373,850
1
A
0
4
5
0
0
28
ok
12
7
[{"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 14"}, {"detector": "framework_specific", "framework": "NumPy", "name": "Array Creat...
B
No random seed setting detected=low
[{"type": "No random seed setting detected", "severity": "low"}]
["Array Creation Efficiency", "Column Selection Checker", "Exception Handling Checker", "Hardcoded file path", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker"]
3
B
5,887
import numpy as np # linear algebra import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) import os from catboost.datasets import amazon train, test = amazon() print(train.shape, test.shape) target = "ACTION" col4train = [x for x in train.columns if x not in [target, "ROLE_TITLE"]] y = train[target].v...
No
3
58
Debug
show_shape
3,402,586
1
A
0
1
0
0
0
9
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"]
8
A
5,888
from sklearn.ensemble import ExtraTreesClassifier from sklearn.model_selection import StratifiedKFold from sklearn.model_selection import cross_validate # returns model instance def get_model(): params = { "n_estimators":300, "n_jobs": 3, "random_state":5436, } return ExtraTreesCl...
Yes
3
28
Model_Train
compute_train_metric
null
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
0
null
5,889
MJTCP = 32292 #Michael Jordan total career points #for each column in dataset creates N column with random integers def assign_rnd_integer(dataset, number_of_times = 5, seed = MJTCP): new_dataset = pd.DataFrame() np.random.seed(seed) for c in dataset.columns: for i in range(number_of_times): ...
Yes
3
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
5,890
new_train, new_test = transform_dataset( train[col4train], test[col4train], assign_rnd_integer, {"number_of_times":5} ) print(new_train.shape, new_test.shape) new_train.head(5)
Yes
3
41
Debug
show_table
3,402,586
1
A
0
0
0
0
0
6
ok
5
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", "Exception Handling Checker", "Unit Testing Checker"]
8
B
5,891
validate_model( model = get_model(), data = [new_train.values, y] )
No
3
28
Model_Train
compute_train_metric
3,402,586
1
A
0
0
0
0
0
4
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
8
A
5,892
new_train, new_test = transform_dataset( train[col4train], test[col4train], assign_rnd_integer, {"number_of_times":1} ) print(new_train.shape, new_test.shape) validate_model( model = get_model(), data = [new_train.values, y] )
Yes
3
28
Model_Train
compute_train_metric
3,402,586
1
A
0
0
0
0
0
9
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": "Unit Testing...
A
no applicable ML-specific findings
[]
["Column Selection Checker", "Exception Handling Checker", "Unit Testing Checker"]
8
A
5,893
new_train, new_test = transform_dataset( train[col4train], test[col4train], assign_rnd_integer, {"number_of_times":10} ) print(new_train.shape, new_test.shape) validate_model( model = get_model(), data = [new_train.values, y] )
Yes
4
28
Model_Train
compute_train_metric
3,402,586
1
A
0
0
0
0
0
9
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": "Unit Testing...
A
no applicable ML-specific findings
[]
["Column Selection Checker", "Exception Handling Checker", "Unit Testing Checker"]
8
A