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,990
train.fillna(method='ffill', inplace=True) train.tail().T
No
4
17
Data_Transform
correct_missing_values
3,344,044
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,991
train.isnull().any().describe()
No
4
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,992
Img = [] for i in range(7049): img = train["Image"][i].split(' ') img = ['0' if x=='' else x for x in img] Img.append(img)'
No
4
17
Data_Transform
correct_missing_values
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,993
PATH_WEEK2='/kaggle/input/covid19-global-forecasting-week-2' df_train = pd.read_csv(f'{PATH_WEEK2}/train.csv') df_test = pd.read_csv(f'{PATH_WEEK2}/test.csv') df_train.head() df_test.head() df_train.rename(columns={'Country_Region':'Country'}, inplace=True) df_test.rename(columns={'Country_Region':'Country'}, inplace=T...
No
3
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,994
Y_train = train.drop('Image', axis=1) Y_train = Y_train.values Y_train = np.array(Y_train, dtype='float') Y_train.shape, X_train.shape
No
4
21
Data_Transform
prepare_x_and_y
3,344,044
1
A
0
0
0
0
0
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,995
# keras CNN # model = Sequential() model.add(Conv2D(filters=32, kernel_size=(5,5), padding = 'same', activation = 'relu', input_shape = (96,96,1))) model.add(MaxPool2D(pool_size = (2,2))) model.add(Dropout(0.25)) model.add(Conv2D(filters=32, kernel_size=(3,3), padding = 'same', activation = 'relu')) model.add(MaxPool...
No
3
4
Model_Train
choose_model_class
3,344,044
1
A
0
0
0
0
0
11
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,996
optimizer = RMSprop(lr = 0.001, epsilon = 1e-8) optimizer1 =Adam(lr=0.001, beta_1=0.9, beta_2=0.999, epsilon=1e-08, decay=0.0) model.compile(optimizer1, loss = "mse", metrics = ["accuracy"] )
No
3
4
Model_Train
choose_model_class
3,344,044
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,997
learning_rate_reduction = ReduceLROnPlateau(monitor='val_acc', patience=3, verbose=1, factor=0.5, min_lr=0.00001) tensorboard = TensorBoard...
No
4
28
Model_Train
compute_train_metric
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,998
model1 = Sequential([Flatten(input_shape=(96,96,1)), Dense(128, activation="relu"), Dropout(0.1), Dense(64, activation="relu"), Dense(30) ]) model1.compile(optimizer='adam', loss=...
No
3
4
Model_Train
choose_model_class
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,999
batch_size =100 epochs = 50 history = model.fit(X_train, Y_train, epochs = epochs, batch_size=batch_size, callbacks=callback_list, validation_split=0.1, verbose = 2)
No
4
7
Model_Train
train_model
3,344,044
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,000
# Plot the loss and accuracy curves for training and validation fig, ax = plt.subplots(2,1) ax[0].plot(history.history['loss'], color='b', label="Training loss") ax[0].plot(history.history['val_loss'], color='r', label="validation loss",axes =ax[0]) legend = ax[0].legend(loc='best', shadow=True) ax[1].plot(history.hi...
No
5
35
Visualization
learning_history
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,001
#preparing test data timag = [] for i in range(0,1783): timg = test['Image'][i].split(' ') timg = ['0' if x == '' else x for x in timg] timag.append(timg)
No
3
14
Data_Transform
filter
3,344,044
1
A
0
2
3
0
0
5
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,002
X_test = np.array(timag,dtype = 'float') X_test = X_test/255 X_test = X_test.reshape(-1,96,96,1) X_test.shape
No
4
21
Data_Transform
prepare_x_and_y
3,344,044
1
A
0
0
0
0
0
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,003
opt_model = load_model('./optimized_model.h5')
No
5
30
Model_Train
load_pretrained
3,344,044
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,004
pred = model.predict(X_test, batch_size = 100) pred.shape
No
4
48
Model_Evaluation
predict_on_test
3,344,044
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,005
feature = [] for f in list( look_id['FeatureName']): feature.append(lookid_list.index(f))
No
2
8
Data_Transform
feature_engineering
3,344,044
2
B
1
1
1
0
5
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,006
rowid = pd.Series(rowid,name = 'RowId') loc = pd.Series(preded,name = 'Location') submission = pd.concat([rowid,loc],axis = 1) submission.to_csv('face_key_detection_submission.csv',index = False)
No
4
25
Data_Export
save_to_csv
3,344,044
1
A
0
0
0
0
0
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,007
# This Python 3 environment comes with many helpful analytics libraries installed # It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python # For example, here's several helpful packages to load in import numpy as np # linear algebra import pandas as pd # data processing, CSV file I/O...
No
4
22
Environment
import_modules
4,178,004
1
A
0
0
0
0
0
7
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 18"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
4
A
3,008
df = pd.read_csv('../input/training/training.csv')
No
5
45
Data_Extraction
load_from_csv
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,009
print(df.isnull().any().value_counts(), df.shape) df.dropna(inplace=True) #df.fillna(method = 'ffill',inplace = True) #df.reset_index(drop = True, inplace = True) print(df.isnull().any().value_counts(), df.shape)
No
3
17
Data_Transform
correct_missing_values
4,178,004
2
B
1
0
0
0
5
3
ok
1
1
[{"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "Assign operations to a new DataFrame variable.", "benefits": "Prevents data loss and improves code clarity.", "location": "Line 6"}]
A
no applicable ML-specific findings
[]
["InPlace Checker"]
4
B
3,010
df = df.sample(frac=1) img_data = df['Image'].values df.drop('Image', inplace=True, axis=1)
No
4
10
Data_Transform
drop_column
4,178,004
1
A
0
0
0
0
0
3
ok
2
2
[{"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "Assign operations to a new DataFrame variable.", "benefits": "Prevents data loss and improves code clarity.", "location": "Line 7"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker",...
A
no applicable ML-specific findings
[]
["Column Selection Checker", "InPlace Checker"]
4
A
3,011
# 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 import numpy as np # linear algebra import pandas as pd # data processing, CSV file I/O (e....
No
5
88
Debug
list_files
null
1
A
0
2
3
0
0
11
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: /kaggle/input. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 16"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
0
A
3,012
!unzip ../input/facial-keypoints-detection/training.zip -d train
No
5
44
Data_Extraction
load_from_disk
10,073,555
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
3
null
3,013
!unzip ../input/facial-keypoints-detection/test.zip -d test
No
5
84
Other
not_enough_vertices
10,073,555
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
3
null
3,014
train = pd.read_csv("../working/train/training.csv")
No
5
45
Data_Extraction
load_from_csv
10,073,555
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../working/train/training.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
3,015
test = pd.read_csv("../working/test/test.csv")
No
5
45
Data_Extraction
load_from_csv
10,073,555
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../working/test/test.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 4"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
3
A
3,016
print(test)
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
3,017
train.head().T
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
3,018
train.fillna(method='ffill',inplace=True)
No
5
17
Data_Transform
correct_missing_values
10,073,555
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "Assign operations to a new DataFrame variable.", "benefits": "Prevents data loss and improves code clarity.", "location": "Line 4"}]
A
no applicable ML-specific findings
[]
["InPlace Checker"]
3
A
3,019
print(train)
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
3,020
len(train["Image"][4].split(' '))'
No
3
40
Debug
show_table_attributes
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,021
images = np.ndarray((7049,9216)) for i in range(7049): img = np.array(train["Image"][i].split(' ')) img = ['0' if x == '' else x for x in img] images[i,:] = img'
No
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
3,022
Y_test = np.ndarray((1783,9216)) for i in range(1783): img = np.array(test["Image"][i].split(' ')) img = ['0' if x == '' else x for x in img] Y_test[i,:] = img'
No
4
17
Data_Transform
correct_missing_values
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,023
images = images.reshape(-1,96,96,1)
No
5
84
Other
not_enough_vertices
10,073,555
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
3,024
Y_test = Y_test.reshape(-1,96,96,1)
No
5
84
Other
not_enough_vertices
10,073,555
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
3,025
images.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
3,026
plt.imshow(images[34].reshape(96,96),cmap='gray')
No
5
84
Other
not_enough_vertices
10,073,555
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
3,027
train.drop('Image',axis=1)
No
5
10
Data_Transform
drop_column
10,073,555
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
3,028
Y_train = np.array(train.drop("Image",axis=1),dtype='float')'
No
5
21
Data_Transform
prepare_x_and_y
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,029
print(Y_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
3,030
model = Sequential() model.add(Conv2D(32,(3,3),input_shape=(96,96,1),padding = 'SAME',activation='relu')) model.add(Conv2D(32,(3,3),padding = 'SAME',activation='relu')) model.add(MaxPooling2D(pool_size=(2,2),strides=(2,2))) model.add(Dropout(0.2)) model.add(Conv2D(64,(3,3),padding = 'SAME',activation='relu')) model.a...
No
3
4
Model_Train
choose_model_class
10,073,555
1
A
0
0
0
0
0
28
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": "framework_specific", "framework":...
A
no applicable ML-specific findings
[]
["Batch Normalisation Checker", "Memory Release Checker"]
3
A
3,031
model.compile(loss='mean_squared_error',optimizer='adam',metrics=['mae'])
No
3
4
Model_Train
choose_model_class
10,073,555
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
3,032
model.fit(images,Y_train,epochs=10,batch_size=256,validation_split=0.2)
No
5
7
Model_Train
train_model
10,073,555
1
A
0
0
0
0
0
1
ok
4
4
[{"detector": "framework_specific", "framework": "TensorFlow", "name": "Early Stopping Checker", "fix": "Implement early stopping using tf.keras.callbacks.EarlyStopping.", "benefits": "Prevents overfitting and reduces unnecessary training time.", "location": ""}, {"detector": "framework_specific", "framework": "TensorF...
A
no applicable ML-specific findings
[]
["Data Augmentation Checker", "Early Stopping Checker", "Memory Release Checker", "Model Evaluation Checker"]
3
A
3,033
pred = model.predict(Y_test)
No
5
48
Model_Evaluation
predict_on_test
10,073,555
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
3,034
lookid_data = pd.read_csv("/kaggle/input/facial-keypoints-detection/IdLookupTable.csv")
No
5
45
Data_Extraction
load_from_csv
10,073,555
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: /kaggle/input/facial-keypoints-detection/IdLookupTable.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
3,035
lookid_list = list(lookid_data['FeatureName']) imageID = list(lookid_data['ImageId']-1) pre_list = list(pred) rowid = lookid_data['RowId'] rowid=list(rowid) feature = [] for f in list(lookid_data['FeatureName']): feature.append(lookid_list.index(f)) preded = [] for x,y in zip(imageID,feature): preded.append(pre...
Yes
4
25
Data_Export
save_to_csv
10,073,555
1
A
1
2
2
0
5
15
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
3,036
train_file = 'training.csv' test_file = 'test.csv' lookup_file = '../input/facial-keypoints-detection/IdLookupTable.csv' train = pd.read_csv(train_file) test = pd.read_csv(test_file) lookup = pd.read_csv(lookup_file)
No
4
45
Data_Extraction
load_from_csv
11,186,959
1
A
0
0
0
0
0
6
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/facial-keypoints-detection/IdLookupTable.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 6"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
3
A
3,037
import tensorflow as tf import numpy as np import pandas as pd from tensorflow import keras from keras.preprocessing.image import ImageDataGenerator import matplotlib as mpl import matplotlib.pyplot as plt !pip install py7zr from keras.preprocessing.image import load_img,img_to_array from py7zr import unpack_7zarchive ...
No
4
87
Environment
install_modules
9,829,311
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
0
null
3,038
shutil.unpack_archive('/kaggle/input/cifar-10/train.7z', '/kaggle/working')
No
4
73
Data_Extraction
load_from_zip
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,039
train_dir = os.listdir("./train"); train_dir_len = len(train_dir) print(".\\\\train:\\t",train_dir_len) print("files:\\t\\t",train_dir[:3])'
No
5
88
Debug
list_files
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,040
train_labels = pd.read_csv('/kaggle/input/cifar-10/trainLabels.csv',dtype=str) train_images = pd.DataFrame(columns = ['id','label','path'],dtype=str) test_labels = pd.read_csv('/kaggle/input/cifar-10/sampleSubmission.csv') train_labels.info()
No
4
45
Data_Extraction
load_from_csv
9,829,311
1
A
0
0
0
0
0
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,041
path_base = '/kaggle/working/train/' for index in range(0,train_dir_len): path = path_base + str(index+1)+'.png' if os.path.exists(path): train_images = train_images.append([{ 'id': str(train_labels['id'].iloc[index]),'path': path, 'label':train_labels['label'].iloc[index]}]) train_images.head...
No
3
41
Debug
show_table
null
1
A
0
2
3
0
0
6
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,042
train_images.head(2)
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
3,043
display_groupby = train_images.groupby(['label']).count() display_groupby.head(10)
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
3,044
class_names = ['airplane','automobile','bird','cat','deer','dog','frog','horse','ship','truck'] for name in class_names: index = class_names.index(name) train_images.loc[train_images.label==name,'label'] = str(index) display_groupby = train_images.groupby(['label']).count() display_groupby.head(10)
No
4
60
Data_Transform
groupby
9,829,311
1
A
0
1
1
0
0
6
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,045
path_base = '/kaggle/working/train' batch_size = 64 train_data_generator = ImageDataGenerator( rescale=1./255., validation_split=0.2, horizontal_flip=True ) train_generator = train_data_generator.flow_from_dataframe(dataframe=train_images, directory="./train/"...
Yes
4
31
Data_Transform
augment
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,046
num_classes = 10
No
5
77
Other
define_variables
9,829,311
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,047
validation_generator = train_data_generator.flow_from_dataframe(dataframe=train_images, directory="./train/", x_col="path", y_col="label", subset="validation", batch_size=batch_size, shuffle=True, target_size=(32,32), class_...
No
5
84
Other
not_enough_vertices
9,829,311
1
A
0
0
0
0
0
9
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,048
b"train_size = len(train_generator.filenames)\nvalidation_size = len(validation_generator.filenames)\nprint('validation_size:\\t',validation_size)\nprint('train_size:\\t\\t',train_size)"
No
5
58
Debug
show_shape
null
1
A
0
0
0
0
0
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,049
index = 0 fig = plt.figure(figsize = (16,10)) for item in train_images.values[:20]: index += 1 plt.subplot(5, 5, index) test_path = item[2] test_image = load_img(test_path, target_size=(32,32)) plt.imshow(test_image) plt.colorbar() plt.grid(False) plt.axis("off") plt.title(class_...
No
5
84
Other
not_enough_vertices
9,829,311
1
A
0
1
1
0
0
13
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,050
import warnings warnings.filterwarnings("ignore") import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns from sklearn.model_selection import cross_val_score
No
4
22
Environment
import_modules
13,885,246
1
A
0
0
0
0
0
7
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
13
A
3,051
# Import dataset df = pd.read_csv('../input/loan-default-prediction/train_v2.csv.zip') df.head()
No
4
45
Data_Extraction
load_from_csv
13,885,246
1
A
0
0
0
0
0
2
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/loan-default-prediction/train_v2.csv.zip. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 15"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
13
A
3,052
# Check duplication in dataframe df[df.duplicated()].shape
No
5
38
EDA
count_duplicates
13,885,246
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"]
13
A
3,053
# The number of each data type in the dataframe df.dtypes.value_counts()
No
5
72
EDA
count_values
13,885,246
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
13
A
3,054
# Loss Distribution fig , ax = plt.subplots() plt.hist(df['loss'], bins = 20, range=(0,100)) ax.set_ylim([0,3000]) plt.show()
No
5
33
Visualization
distribution
13,885,246
1
A
0
0
0
0
0
4
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"]
13
A
3,055
# Calculate percent of missing in each row df['num_missing'] = df.isnull().sum(axis = 1)/df.shape[1] # Drop row that percent of missing more than 20% missing_row = df[df['num_missing'] > 0.20].index df.drop(df.index[missing_row], inplace = True) df.shape
No
4
17
Data_Transform
correct_missing_values
13,885,246
1
A
0
0
0
0
0
4
ok
2
2
[{"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "Assign operations to a new DataFrame variable.", "benefits": "Prevents data loss and improves code clarity.", "location": "Line 19"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker"...
A
no applicable ML-specific findings
[]
["Column Selection Checker", "InPlace Checker"]
13
A
3,056
# Drop id and num_missing collumn df.drop(columns = ['id','num_missing'], inplace = True)
No
5
10
Data_Transform
drop_column
13,885,246
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "Assign operations to a new DataFrame variable.", "benefits": "Prevents data loss and improves code clarity.", "location": "Line 15"}]
A
no applicable ML-specific findings
[]
["InPlace Checker"]
13
A
3,057
# Calculate percent of missing in each column col_pct_miss = [] for col in df.columns: percent_miss = np.mean(df[col].isnull())*100 if percent_miss > 0: col_pct_miss.append([col, percent_miss]) col_pct_miss_df = pd.DataFrame(col_pct_miss, columns = ['column_name','% of Missing']).sort_values(by = '...
No
4
17
Data_Transform
correct_missing_values
13,885,246
1
A
0
2
3
1
0
7
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": "NumPy", "name": "Inefficient Operat...
C
Missing Axis Specification=medium
[{"type": "Missing Axis Specification", "severity": "medium"}]
["Column Selection Checker", "Inefficient Operations"]
13
C
3,058
# Impute missing value in numeric columns with median numeric_cols = df.select_dtypes(include=['number']).columns.values for col in numeric_cols: if col in list(col_pct_miss_df.column_name) : med = df[col].median() df[col] = df[col].fillna(med)
No
5
17
Data_Transform
correct_missing_values
13,885,246
1
A
0
2
3
0
0
5
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"]
13
A
3,059
# Impute missing value in categorical columns with mode not_numeric_cols = df.select_dtypes(exclude=['number']).columns.values for col in not_numeric_cols: if col in list(col_pct_miss_df.column_name): mode = df[col].mode()[0] df[col] = df[col].fillna(mode)
No
5
17
Data_Transform
correct_missing_values
13,885,246
1
A
0
2
3
0
0
5
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"]
13
A
3,060
# Check missing value df.isnull().sum().value_counts()
No
5
39
EDA
count_missing_values
13,885,246
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
13
A
3,061
# Drop Highly Corelated Columns # Create correlation matrix corr_matrix = df.corr().abs() # Select upper triangle of correlation matrix upper = corr_matrix.where(np.triu(np.ones(corr_matrix.shape), k=1).astype(np.bool)) # Find index of feature columns with correlation greater than 0.95 to_drop = [column for column i...
No
5
10
Data_Transform
drop_column
13,885,246
1
A
0
1
0
0
0
4
ok
4
3
[{"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "Assign operations to a new DataFrame variable.", "benefits": "Prevents data loss and improves code clarity.", "location": "Line 25"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker"...
A
no applicable ML-specific findings
[]
["Array Creation Efficiency", "Column Selection Checker", "InPlace Checker"]
13
A
3,062
#Drop Repetitive Columns num_rows = df.shape[0] rep_cols = [] for col in df.loc[:, df.columns != 'loss'].columns : cnts = df[col].value_counts() top_pct = (cnts/num_rows).iloc[0] if top_pct > 0.80: rep_cols.append([col,top_pct]) rep_col_df = pd.DataFrame(rep_cols, columns = ['column_n...
No
3
10
Data_Transform
drop_column
13,885,246
1
A
0
2
3
1
0
10
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"]
13
A
3,063
cat_cols = df.select_dtypes(exclude=['number']).columns.values drop_cols = [] keep_cols = [] for col in cat_cols: if df[col].value_counts().count() > 20000 : print('column {} has {} categories > drop'.format(col,df[col].value_counts().count())) drop_cols.append(col) else : print('colu...
No
4
10
Data_Transform
drop_column
13,885,246
1
A
0
2
4
0
0
10
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"]
13
A
3,064
# Binary Encoding import category_encoders as ce encoder = ce.BinaryEncoder(cols = keep_cols) bi_enc_df = encoder.fit_transform(df[keep_cols]) bi_col_name = bi_enc_df.columns bi_enc_df.head() #Add Binary Encding to dataframe and drop all categorical columns df = pd.concat([df,bi_enc_df],axis = 1) df.head()
No
3
20
Data_Transform
categorify
13,885,246
1
A
0
0
0
0
0
7
ok
6
6
[{"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...
D
Cross Validation Checker=low, Data Leakage Checker=high
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}]
["Column Selection Checker", "Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
13
D
3,065
# Add a 'loan_status' collumn which 1 represents default loan and 0 represents not default loan. df['loan_status'] = np.where(df['loss'] > 0, 1, 0) df.head()
No
5
8
Data_Transform
feature_engineering
13,885,246
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"]
13
A
3,066
# After generate a visualization from loan_status in dataframe. # We found that the data is imbalance. ax = sns.countplot(x = 'loan_status', data=df) plt.show() df['loan_status'].value_counts()
No
5
33
Visualization
distribution
13,885,246
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"]
13
A
3,067
from sklearn.model_selection import train_test_split X = resample_df.drop(columns = ['loss','loan_status']) Y = resample_df['loss'] X_train, X_test, Y_train, Y_test = train_test_split( X, Y, test_size = 0.2, random_state = 1234, stratify = resample_df['loan_status']) print('training set = {} records, test set= {} rec...
No
4
21
Data_Transform
prepare_x_and_y
13,885,246
1
A
0
0
0
0
0
5
ok
3
3
[{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida...
B
Cross Validation Checker=low, Cross-validation not detected=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}]
["Column Selection Checker"]
13
B
3,068
from sklearn.feature_selection import SelectPercentile , SelectKBest, f_regression , f_classif
No
5
22
Environment
import_modules
13,885,246
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
13
A
3,069
#Select top 170 important numerical columns with filter method X_train_num = X_train.drop(columns = bi_col_name) selector = SelectKBest(score_func = f_regression, k = 170) selector.fit(X_train_num,Y_train) select_cols = selector.get_support(indices = True) select_num_cols = X_train_num.iloc[:,select_cols] select_num...
No
5
86
Model_Interpretation
features_selection
13,885,246
1
A
0
0
0
0
0
7
ok
7
7
[{"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", "Unit Testing Checker", "Verbose Mode Checker"]
13
B
3,070
#Select top 150 important numerical columns with RFE from sklearn.feature_selection import RFE from sklearn.linear_model import LogisticRegression selector = RFE(LogisticRegression(), n_features_to_select=150, step=1, verbose = 2) selector = selector.fit(select_num_cols, Y_train) select_cols = selector.get_support(ind...
No
5
86
Model_Interpretation
features_selection
13,885,246
1
A
0
0
0
0
0
8
ok
5
5
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Scaler Missing Checker", "fix": "Apply scaling before scaling-sensitive operations.", "benefits": "Improves model performance and accuracy.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation...
C
Cross Validation Checker=low, Scaler Missing Checker=medium
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Scaler Missing Checker", "severity": "medium"}]
["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
13
C
3,071
# Select top 5 important categorical columns with filter method from sklearn.preprocessing import OrdinalEncoder from sklearn.preprocessing import LabelEncoder X_train_cat = X_train.select_dtypes(exclude = 'number').copy() # Create encoder le = LabelEncoder() X_train_cat = X_train_cat.apply(lambda col: le.fit_transf...
No
3
86
Model_Interpretation
features_selection
13,885,246
1
A
0
0
0
0
0
14
ok
15
10
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Pipeline Checker", "fix": "Use Pipelines for all scikit-learn estimators.", "benefits": "Prevents data leakage and ensures correct model evaluation.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross V...
D
Cross Validation Checker=low, Cross-validation not detected=low, Data Leakage Checker=high, No random seed setting detected=low, Pipeline Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Pipeline Checker", "severity": "low"}]
["Exception Handling Checker", "Feature selection detected without clear validation strategy. Ensure it's applied with proper validation to avoid selection bias.", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mo...
13
D
3,072
#Combine categorical and non-categorical dataframe together def filter_x_df(x): df = x.copy() all_filter_col = [] for keep in select_cat_col_name[select_cat_col_name.isin(keep_cols)]: filter_col = [col for col in df.columns if col.startswith(str(keep))] for col in filter_col : ...
No
5
11
Data_Transform
concatenate
13,885,246
1
A
0
5
6
0
0
11
ok
2
2
[{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name": "Missing docstring for...
A
no applicable ML-specific findings
[]
["Column Selection Checker", "Missing function docstring"]
13
A
3,073
filter_X_train.head()
No
5
41
Debug
show_table
13,885,246
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"}]
[]
13
B
3,074
from sklearn.preprocessing import StandardScaler scaler = StandardScaler() scaler.fit(filter_X_train) X_train_scal = scaler.fit_transform(filter_X_train) X_test_scal = scaler.fit_transform(filter_X_test)
No
5
18
Data_Transform
normalization
13,885,246
1
A
0
0
0
0
0
5
ok
13
9
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Pipeline Checker", "fix": "Use Pipelines for all scikit-learn estimators.", "benefits": "Prevents data leakage and ensures correct model evaluation.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross V...
D
Cross Validation Checker=low, Cross-validation not detected=low, Data Leakage Checker=high, No random seed setting detected=low, Pipeline Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Pipeline Checker", "severity": "low"}]
["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"]
13
D
3,075
from sklearn.neighbors import KNeighborsClassifier neigh = KNeighborsClassifier() neigh.fit(X_train_scal, Y_train) Knn_y_pred_train = neigh.predict(X_train_scal) Knn_y_pred_test = neigh.predict(X_test_scal) scores_kn = cross_val_score(estimator = neigh, y = Y_train, X = X_train_scal, cv=5) print('Cross Validation ...
Yes
4
7
Model_Train
train_model
13,885,246
1
A
1
0
0
0
5
7
ok
9
6
[{"detector": "framework_specific", "framework": "NumPy", "name": "Missing Axis Specification", "fix": "Specify axis in array operations.", "benefits": "Improves performance and avoids unexpected behaviour.", "location": "Line 23"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Verbose Mode Ch...
C
Missing Axis Specification=medium, No random seed setting detected=low
[{"type": "Missing Axis Specification", "severity": "medium"}, {"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"]
13
C
3,076
from sklearn.linear_model import LogisticRegression logisticRegr = LogisticRegression() logisticRegr = logisticRegr.fit(X_train_scal, Y_train) Lr_y_pred_train = logisticRegr.predict(X_train_scal) Lr_y_pred_test = logisticRegr.predict(X_test_scal) scores_lr = cross_val_score(estimator = logisticRegr, y = Y_train, X =...
Yes
4
7
Model_Train
train_model
13,885,246
1
A
0
0
0
0
0
7
ok
10
7
[{"detector": "framework_specific", "framework": "NumPy", "name": "Missing Axis Specification", "fix": "Specify axis in array operations.", "benefits": "Improves performance and avoids unexpected behaviour.", "location": "Line 23"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Scaler Missing ...
C
Missing Axis Specification=medium, No random seed setting detected=low, Scaler Missing Checker=medium
[{"type": "Missing Axis Specification", "severity": "medium"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Scaler Missing Checker", "severity": "medium"}]
["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"]
13
C
3,077
from sklearn.ensemble import RandomForestClassifier rf = RandomForestClassifier(max_depth = 70) rf.fit(filter_X_train, Y_train) rf_y_pred_train = rf.predict(filter_X_train) rf_y_pred_test = rf.predict(filter_X_test) scores_rf = cross_val_score(estimator = rf, y = Y_train, X = filter_X_train, cv=5) print('Cross Val...
Yes
4
7
Model_Train
train_model
13,885,246
1
A
2
0
0
0
10
7
ok
11
7
[{"detector": "framework_specific", "framework": "NumPy", "name": "Missing Axis Specification", "fix": "Specify axis in array operations.", "benefits": "Improves performance and avoids unexpected behaviour.", "location": "Line 23"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Randomness Cont...
C
Missing Axis Specification=medium, No random seed setting detected=low, Randomness Control Checker=low
[{"type": "Missing Axis Specification", "severity": "medium"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Randomness Control 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"]
13
C
3,078
from xgboost import XGBClassifier xgb = XGBClassifier(gamma=0, learning_rate=0.1, max_depth=100, n_estimators=100) xgb.fit(filter_X_train,Y_train) xgb_y_pred_train = xgb.predict(filter_X_train) xgb_y_pred_test = xgb.predict(filter_X_test) scores_xg = cross_val_score(estimator = rf, y = Y_train, X = filter_X_train, ...
Yes
4
7
Model_Train
train_model
13,885,246
1
A
0
0
0
0
0
7
ok
9
6
[{"detector": "framework_specific", "framework": "NumPy", "name": "Missing Axis Specification", "fix": "Specify axis in array operations.", "benefits": "Improves performance and avoids unexpected behaviour.", "location": "Line 23"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Verbose Mode Ch...
C
Missing Axis Specification=medium, No random seed setting detected=low
[{"type": "Missing Axis Specification", "severity": "medium"}, {"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"]
13
C
3,079
# Split Train Set & Test Set from sklearn.model_selection import train_test_split Y = X_sm['loss'] X = X_sm.drop(columns = 'loss') X_train, X_test, Y_train, Y_test = train_test_split( X, Y, test_size = 0.2, random_state = 1234, stratify = Y_sm) print('training set = {} records, test set= {} records'.format(X_train.sh...
No
4
13
Data_Transform
split
13,885,246
1
A
0
0
0
0
0
5
ok
3
3
[{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida...
B
Cross Validation Checker=low, Cross-validation not detected=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}]
["Column Selection Checker"]
13
B
3,080
# Select top 170 important numerical columns with filter method X_train_num = X_train.drop(columns = bi_col_name) selector = SelectKBest(score_func = f_regression, k = 170) selector.fit(X_train_num,Y_train) select_cols_sm = selector.get_support(indices = True) select_num_cols_sm = X_train_num.iloc[:,select_cols_sm] ...
No
5
86
Model_Interpretation
features_selection
13,885,246
1
A
0
0
0
0
0
7
ok
7
7
[{"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", "Unit Testing Checker", "Verbose Mode Checker"]
13
B
3,081
# Select top 150 important numerical columns with RFE from sklearn.feature_selection import RFE from sklearn.linear_model import LogisticRegression selector = RFE(LogisticRegression(), n_features_to_select=150, step=1, verbose = 2) selector = selector.fit(select_num_cols_sm, Y_train) select_cols_sm = selector.get_supp...
No
5
86
Model_Interpretation
features_selection
13,885,246
1
A
0
0
0
0
0
8
ok
5
5
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Scaler Missing Checker", "fix": "Apply scaling before scaling-sensitive operations.", "benefits": "Improves model performance and accuracy.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation...
C
Cross Validation Checker=low, Scaler Missing Checker=medium
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Scaler Missing Checker", "severity": "medium"}]
["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
13
C
3,082
# Combine categorical and non-categorical dataframe together def filter_x_df_sm(x): df = x.copy() all_filter_col = [] for keep in select_cat_col_name[select_cat_col_name.isin(keep_cols)]: filter_col = [col for col in df.columns if col.startswith(str(keep))] for col in filter_col : ...
No
5
11
Data_Transform
concatenate
13,885,246
1
A
0
5
6
0
0
10
ok
2
2
[{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name": "Missing docstring for...
A
no applicable ML-specific findings
[]
["Column Selection Checker", "Missing function docstring"]
13
A
3,083
#Standardize scaler = StandardScaler() scaler.fit(filter_X_train_sm) X_train_scal_sm = scaler.fit_transform(filter_X_train_sm) X_test_scal_sm = scaler.fit_transform(filter_X_test_sm)
No
5
18
Data_Transform
normalization
13,885,246
1
A
0
0
0
0
0
4
ok
13
9
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Pipeline Checker", "fix": "Use Pipelines for all scikit-learn estimators.", "benefits": "Prevents data leakage and ensures correct model evaluation.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross V...
D
Cross Validation Checker=low, Cross-validation not detected=low, Data Leakage Checker=high, No random seed setting detected=low, Pipeline Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Pipeline Checker", "severity": "low"}]
["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"]
13
D
3,084
# Train Logistic Regression model logisticRegr_sm = LogisticRegression() logisticRegr_sm = logisticRegr_sm.fit(X_train_scal_sm, Y_train) Lr_y_pred_train_sm = logisticRegr_sm.predict(X_train_scal_sm) Lr_y_pred_test_sm = logisticRegr_sm.predict(X_test_scal_sm) scores_lr_sm = cross_val_score(estimator = logisticRegr_sm...
Yes
4
7
Model_Train
train_model
13,885,246
1
A
0
0
0
0
0
6
ok
10
7
[{"detector": "framework_specific", "framework": "NumPy", "name": "Missing Axis Specification", "fix": "Specify axis in array operations.", "benefits": "Improves performance and avoids unexpected behaviour.", "location": "Line 22"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Scaler Missing ...
C
Missing Axis Specification=medium, No random seed setting detected=low, Scaler Missing Checker=medium
[{"type": "Missing Axis Specification", "severity": "medium"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Scaler Missing Checker", "severity": "medium"}]
["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"]
13
C
3,085
cat_cols = df.select_dtypes(exclude=['number']).columns.values for col in cat_cols: if df[col].value_counts().count() > 20000 : print('Column {} has {} categories'.format(col,df[col].value_counts().count()))
No
5
54
EDA
count_unique_values
13,885,246
1
A
0
2
3
0
0
4
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"]
13
A
3,086
b"featurename = filter_X_train.columns\nimportances = list(rf.feature_importances_)\n\nfeature_importances = [(feature, round(importance, 3)) for feature, importance in zip(featurename, importances)]\nfeature_importances = sorted(feature_importances, key = lambda x: x[1], reverse = True)\n\nprint('Top 50 Importance Fea...
No
5
86
Model_Interpretation
features_selection
null
1
A
0
0
0
0
0
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,087
test_df = pd.read_csv('../input/loan-default-prediction/test_v2.csv.zip') test_df.head()
No
5
45
Data_Extraction
load_from_csv
13,885,246
1
A
0
0
0
0
0
2
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/loan-default-prediction/test_v2.csv.zip. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 14"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
13
A
3,088
# Binary Encoding encoder = ce.BinaryEncoder(cols = keep_cols) bi_enc_df = encoder.fit_transform(test_df[keep_cols]) bi_col_name = bi_enc_df.columns test_df = pd.concat([test_df,bi_enc_df],axis = 1) test_df.head()
Yes
4
20
Data_Transform
categorify
13,885,246
1
A
0
0
0
0
0
5
ok
6
6
[{"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...
D
Cross Validation Checker=low, Data Leakage Checker=high
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}]
["Column Selection Checker", "Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
13
D
3,089
# Create select_test_df by drop some columns in test_df select_test_df = pd.concat([test_df['id'],test_df[filter_X_train.columns]],axis = 1) select_test_df.head()
No
4
11
Data_Transform
concatenate
13,885,246
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"]
13
A