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
7,071
testAdult = pd.read_csv('../input/adultb/test_data.csv', sep=',',engine='python', na_values='?')
No
5
45
Data_Extraction
load_from_csv
1,560,747
1
A
0
0
0
0
0
3
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/adultb/test_data.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"]
5
A
7,072
testAdult.isnull().sum()
No
4
39
EDA
count_missing_values
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,073
XtestAdult = testAdult[['age','education.num', 'capital.gain','capital.loss', 'hours.per.week']]
No
5
10
Data_Transform
drop_column
1,560,747
1
A
0
0
0
0
0
3
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
5
A
7,074
result = np.vstack((testAdult["Id"], YtestPred)).T x = ["id","income"] submit = pd.DataFrame(columns = x, data = result) submit.to_csv("Resultados.csv", index = False)
Yes
3
25
Data_Export
save_to_csv
1,560,747
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"]
5
A
7,075
import pandas as pd import sklearn import numpy as np import os from sklearn import preprocessing
No
5
22
Environment
import_modules
1,563,153
1
A
0
0
0
0
0
5
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
6
A
7,076
adultOriginal = pd.read_csv("../input/adult-db/train_data.csv",<br> sep=r\'\\s*,\\s*\',<br> engine=\'python\',<br> na_values="?")
No
5
45
Data_Extraction
load_from_csv
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,077
adultOriginal.head()
No
5
41
Debug
show_table
1,563,153
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
6
A
7,078
adultOriginal.shape
No
5
58
Debug
show_shape
1,563,153
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
6
A
7,079
numAdult_1=adultOriginal.fillna(method='pad') numAdult_2=numAdult_1.fillna(method='pad')
No
5
17
Data_Transform
correct_missing_values
1,563,153
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
6
A
7,080
adult = numAdult_2.apply(preprocessing.LabelEncoder().fit_transform) adult
No
5
20
Data_Transform
categorify
1,563,153
1
A
0
0
0
1
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
6
A
7,081
adult["sex"].value_counts().plot(kind="bar")
No
5
33
Visualization
distribution
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,082
adult["race"].value_counts().plot(kind="bar")
No
5
33
Visualization
distribution
1,563,153
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Column Selection Checker"]
6
A
7,083
adult["education"].value_counts().plot(kind="bar")
No
5
33
Visualization
distribution
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,084
test_adult = pd.read_csv(\'../input/adult-db/test_data.csv\',<br> sep=r\'\\s*,\\s*\',<br> engine=\'python\',<br> na_values="?")
No
5
45
Data_Extraction
load_from_csv
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,085
numAdultTest_1=test_adult.fillna(method='pad') numAdultTest_2=numAdultTest_1.fillna(method='pad') adultTest = numAdultTest_2.apply(preprocessing.LabelEncoder().fit_transform) adultTest
Yes
4
17
Data_Transform
correct_missing_values
1,563,153
1
A
0
0
0
1
0
4
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
6
A
7,086
from sklearn.neighbors import KNeighborsClassifier from sklearn.model_selection import cross_val_score
No
5
22
Environment
import_modules
null
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
0
A
7,087
Xadult = adult.drop(['workclass', 'marital.status', 'sex', 'occupation', 'relationship', 'income', 'capital.gain', 'capital.loss', 'native.country'], axis=1) Xadult
No
5
10
Data_Transform
drop_column
1,563,153
1
A
0
0
0
1
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
6
A
7,088
XtestAdult = adultTest.drop(['workclass', 'marital.status', 'sex', 'occupation', 'relationship', 'capital.gain', 'capital.loss', 'native.country'], axis=1)
No
5
10
Data_Transform
drop_column
1,563,153
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
6
A
7,089
knn = KNeighborsClassifier(n_neighbors=21)
No
5
4
Model_Train
choose_model_class
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,090
data = pd.DataFrame(adultTest.Id)
No
5
12
Data_Transform
create_dataframe
1,563,153
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
6
A
7,091
data.to_csv("BaseAdult_KNN.csv", index=False)
No
5
25
Data_Export
save_to_csv
1,563,153
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
6
A
7,092
import pandas as pd import sklearn import matplotlib.pyplot as plt import numpy as np
No
5
22
Environment
import_modules
null
1
A
0
0
0
0
0
4
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
0
A
7,093
train = pd.read_csv("../input/dataset/train_data.csv",<br> na_values = \'?\')
No
5
45
Data_Extraction
load_from_csv
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,094
train = train.dropna()
No
5
17
Data_Transform
correct_missing_values
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,095
Atrain = train[["age","education.num","capital.gain", "capital.loss", "hours.per.week"]] Btrain = train.income
No
5
21
Data_Transform
prepare_x_and_y
1,564,753
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
5
A
7,096
knn = KNeighborsClassifier(n_neighbors=15)
No
5
4
Model_Train
choose_model_class
1,564,753
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
5
A
7,097
knn.fit(Atrain,Btrain)
No
5
7
Model_Train
train_model
1,564,753
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"]
5
B
7,098
test = pd.read_csv("../input/dataset/test_data.csv",<br> na_values = \'?\')
No
5
45
Data_Extraction
load_from_csv
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,099
Atest = test[["age","education.num","capital.gain", "capital.loss", "hours.per.week"]]
No
5
21
Data_Transform
prepare_x_and_y
1,564,753
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
5
A
7,100
Bpred=knn.predict(Atest)
No
5
48
Model_Evaluation
predict_on_test
1,564,753
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"]
5
A
7,101
prediction = pd.DataFrame(index = test.index)
No
5
12
Data_Transform
create_dataframe
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,102
prediction.to_csv("submition.csv",index=False)
No
5
25
Data_Export
save_to_csv
1,564,753
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"]
5
A
7,103
import os, cv2, re, random import numpy as np import pandas as pd from keras.preprocessing.image import ImageDataGenerator from keras.preprocessing.image import img_to_array, load_img from keras import layers, models, optimizers from keras import backend as K from sklearn.model_selection import train_test_split from s...
No
5
23
Environment
set_options
1,583,645
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
0
null
7,104
transform = transforms.Compose( [transforms.ToTensor(), transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))]) trainset = torchvision.datasets.CIFAR10(root='.', train=True, download=False, transform=transform) trainloader = torch.utils.data.DataLoader(trainset, batch_...
No
3
42
Data_Extraction
load_from_url
1,015,888
1
A
0
0
0
0
0
13
ok
4
4
[{"detector": "framework_specific", "framework": "PyTorch", "name": "Deterministic Algorithm Usage Checker", "fix": "Enable deterministic algorithms using torch.use_deterministic_algorithms(True).", "benefits": "Ensures consistent results across different hardware and runs.", "location": ""}, {"detector": "framework_sp...
B
Deterministic Algorithm Usage Checker=low, No random seed setting detected=low, Randomness Control Checker (PyTorch-Dataloader)=low
[{"type": "Deterministic Algorithm Usage Checker", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Randomness Control Checker (PyTorch-Dataloader)", "severity": "low"}]
["No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness."]
2
B
7,105
def imshow(img): img = img / 2 + 0.5 # unnormalize npimg = img.numpy() plt.imshow(np.transpose(npimg, (1, 2, 0))) # get some random training images dataiter = iter(trainloader) images, labels = dataiter.next() # show images imshow(torchvision.utils.make_grid(images)) # print labels print(' '.join('%5...
No
5
84
Other
not_enough_vertices
null
1
A
1
1
0
0
5
8
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,106
class Net(nn.Module): def __init__(self): super(Net, self).__init__() self.conv1 = nn.Conv2d(3, 6, 5) self.pool = nn.MaxPool2d(2, 2) self.conv2 = nn.Conv2d(6, 16, 5) self.fc1 = nn.Linear(16 * 5 * 5, 120) self.fc2 = nn.Linear(120, 84) self.fc3 = nn.Linear(84, 1...
No
5
4
Model_Train
choose_model_class
1,015,888
1
A
0
3
1
0
0
20
ok
4
4
[{"detector": "framework_specific", "framework": "PyTorch", "name": "Deterministic Algorithm Usage Checker", "fix": "Enable deterministic algorithms using torch.use_deterministic_algorithms(True).", "benefits": "Ensures consistent results across different hardware and runs.", "location": ""}, {"detector": "framework_sp...
B
Deterministic Algorithm Usage Checker=low
[{"type": "Deterministic Algorithm Usage Checker", "severity": "low"}]
["Batch Normalisation Checker", "Missing class docstring", "Missing function docstring"]
2
B
7,107
import torch.optim as optim criterion = nn.CrossEntropyLoss() if use_gpu: criterion = criterion.cuda() optimizer = optim.SGD(net.parameters(), lr=0.001, momentum=0.9)
No
3
28
Model_Train
compute_train_metric
null
1
A
1
1
1
0
5
5
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
0
A
7,108
# loop over the dataset multiple times for epoch in tqdm_notebook(range(10)): running_loss = 0.0 for i, data in tqdm_notebook(enumerate(trainloader, 0)): # get the inputs inputs, labels = data if torch.cuda.is_available(): # in versions of Torch < 0.4.0 we have to wrap th...
No
5
7
Model_Train
train_model
1,015,888
1
A
1
4
9
0
5
17
ok
2
2
[{"detector": "framework_specific", "framework": "PyTorch", "name": "Deterministic Algorithm Usage Checker", "fix": "Enable deterministic algorithms using torch.use_deterministic_algorithms(True).", "benefits": "Ensures consistent results across different hardware and runs.", "location": ""}, {"detector": "framework_sp...
B
Deterministic Algorithm Usage Checker=low
[{"type": "Deterministic Algorithm Usage Checker", "severity": "low"}]
["Logging Checker"]
2
B
7,109
dataiter = iter(testloader) images, labels = dataiter.next() # print images imshow(torchvision.utils.make_grid(images)) print('GroundTruth: ', ' '.join('%5s' % classes[labels[j]] for j in range(32)))
No
5
84
Other
not_enough_vertices
null
1
A
1
0
0
0
5
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,110
# in PyTorch 0.4.0 you won't need the Variable wrapper outputs = net(Variable(images).cuda()) if use_gpu else net(Variable(images))
No
5
77
Other
define_variables
null
1
A
0
1
1
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,111
_, predicted = torch.max(outputs.data, 1) print('Predicted: ', ' '.join('%5s' % classes[predicted[j]] for j in range(32)))
No
5
53
Other
something_strange
null
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,112
all_pred = np.empty((0, 10), float)
No
5
53
Other
something_strange
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,113
for data in tqdm_notebook(testloader): images, _ = data if use_gpu: images = images.cuda() outputs = net(Variable(images)) curr_pred = F.softmax(outputs).data.cpu().numpy() all_pred = np.vstack([all_pred, curr_pred])
No
5
48
Model_Evaluation
predict_on_test
null
1
A
0
2
3
0
0
7
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,114
all_pred.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
7,115
pd.DataFrame(all_pred, columns=classes).to_csv('baseline.csv', index_label='id')
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
7,116
# This Python 3 environment comes with many helpful analytics libraries installed<br># It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python<br># For example, here\'s several helpful packages to load in <br><br>import numpy as np # linear algebra<br>import pandas as pd # data processi...
No
5
88
Debug
list_files
null
1
A
0
0
0
0
0
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,117
train_path = '../input/train' path_name = train_path + '/**/*.jpg'
No
4
77
Other
define_variables
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,118
train_image_paths = glob(path_name, recursive=True)
No
5
88
Debug
list_files
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,119
train_image_paths[:10]
No
4
88
Debug
list_files
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,120
train_categories = list(map(os.path.basename,train_image_paths))
No
3
88
Debug
list_files
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,121
train_categories[:3]
No
5
53
Other
something_strange
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,122
labels =[] for category in train_categories: labels.append(category[:3])
No
3
21
Data_Transform
prepare_x_and_y
null
1
A
0
1
1
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,123
labels[:10]
No
5
53
Other
something_strange
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,124
len(labels)
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
7,125
len(train_image_paths)
No
5
53
Other
something_strange
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,126
num_classes = len(np.unique(labels)) num_classes
No
5
54
EDA
count_unique_values
null
1
A
0
0
0
1
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,127
#Encode labels with value between 0 and n_classes-1. from sklearn.preprocessing import LabelEncoder encoder = LabelEncoder() loadedLabels = np.asarray(labels) encoder.fit(loadedLabels) encoded_loadedLabels = encoder.transform(loadedLabels)
No
5
20
Data_Transform
categorify
null
1
A
0
0
0
0
0
5
ok
9
8
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Pipeline Checker", "fix": "Use Pipelines for all scikit-learn estimators.", "benefits": "Prevents data leakage and ensures correct model evaluation.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross V...
D
Cross Validation Checker=low, Data Leakage Checker=high, No random seed setting detected=low, Pipeline Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Pipeline Checker", "severity": "low"}]
["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"]
0
D
7,128
# Encode labels to hot vectors (ex : 2 -> [0,0,1,0,0,0,0,0,0,0]) from keras.utils.np_utils import to_categorical labels_Hot = to_categorical(encoded_loadedLabels, num_classes = num_classes)
No
5
20
Data_Transform
categorify
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,129
labels_Hot[:3]
No
5
53
Other
something_strange
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,130
df = pd.DataFrame()
No
5
12
Data_Transform
create_dataframe
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,131
df
No
5
41
Debug
show_table
null
1
A
0
0
0
1
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,132
df['path']=train_image_paths
No
4
8
Data_Transform
feature_engineering
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,133
df['path'].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
7,134
df['labels'] = list(labels_Hot)
No
5
8
Data_Transform
feature_engineering
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,135
from keras.preprocessing.image import ImageDataGenerator IMG_SIZE = (128, 128) core_idg = ImageDataGenerator(samplewise_center=True, samplewise_std_normalization=True, horizontal_flip = True, vertical_flip = False, ...
No
4
31
Data_Transform
augment
null
1
A
0
0
0
0
0
12
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,136
def flow_from_dataframe(img_data_gen, in_df, path_col, y_col, **dflow_args): base_dir = os.path.dirname(in_df[path_col].values[0]) print('## Ignore next message from keras, values are replaced anyways') df_gen = img_data_gen.flow_from_directory(base_dir, class_mode = 's...
No
3
21
Data_Transform
prepare_x_and_y
null
1
A
0
1
0
0
0
14
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,137
from sklearn.model_selection import train_test_split train_df, valid_df = train_test_split(df, test_size = 0.25, random_state = 2018)
No
5
13
Data_Transform
split
null
1
A
0
0
0
0
0
4
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"}]
[]
0
B
7,138
len(train_df)
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
7,139
len(valid_df)
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
7,140
train_gen = flow_from_dataframe(core_idg, train_df, path_col = 'path', y_col = 'labels', target_size = IMG_SIZE, batch_size = 32) valid_gen = flow_from_dataframe(core_idg, valid_df, ...
No
4
21
Data_Transform
prepare_x_and_y
null
1
A
0
0
0
0
0
16
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,141
t_x, t_y = next(train_gen)
No
5
84
Other
not_enough_vertices
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,142
t_x.shape[1:]
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
7,143
from keras.applications import VGG16 from keras.applications.vgg16 import preprocess_input import keras from keras import backend as K from keras.callbacks import Callback, EarlyStopping, ReduceLROnPlateau, ModelCheckpoint from keras.preprocessing.image import ImageDataGenerator from keras.utils.np_utils import to_cat...
No
5
23
Environment
set_options
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,144
pretrained_model_1 = VGG16(include_top=False, input_shape=t_x.shape[1:]) base_model = pretrained_model_1 # Topless optimizer1 = keras.optimizers.Adam() # Add top layer x = base_model.output x = Conv2D(100, kernel_size = (3,3), padding = 'valid')(x) x = Flatten()(x) x = Dropout(0.75)(x) predictions = Dense(num_classes, ...
Yes
4
30
Model_Train
load_pretrained
null
1
A
0
1
1
0
0
15
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,145
model.fit_generator(train_gen,steps_per_epoch=100,validation_data = (test_X, test_Y), epochs = 10)
No
5
7
Model_Train
train_model
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,146
test_image_paths = glob('../input/test/*.jpg', recursive=True)
No
5
88
Debug
list_files
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,147
img_width = 150 img_height = 150 TRAIN_DIR = '../input/train/' TEST_DIR = '../input/test/' train_images_dogs_cats = [TRAIN_DIR+i for i in os.listdir(TRAIN_DIR)] # use this for full dataset test_images_dogs_cats = [TEST_DIR+i for i in os.listdir(TEST_DIR)]
No
5
77
Other
define_variables
null
1
A
0
0
0
0
0
6
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,148
train_images_dogs_cats.sort(key=natural_keys) train_images_dogs_cats_trim = train_images_dogs_cats[0:1300] train_images_dogs_cats_trim += train_images_dogs_cats[12500:13800] test_images_dogs_cats.sort(key=natural_keys)
Yes
4
9
Data_Transform
sort_values
1,583,645
1
A
0
0
0
0
0
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,149
X, Y = prepare_data(train_images_dogs_cats_trim) # First split the data in two sets, 80% for training, 20% for Val/Test) X_train, X_val, Y_train, Y_val = train_test_split(X,Y, test_size=0.2, random_state=1)
Yes
3
21
Data_Transform
prepare_x_and_y
1,583,645
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,150
model = models.Sequential() model.add(layers.Conv2D(32, (3, 3), input_shape=(img_width, img_height, 3))) model.add(layers.Activation('relu')) model.add(layers.MaxPooling2D(pool_size=(2, 2))) model.add(layers.Conv2D(32, (3, 3))) model.add(layers.Activation('relu')) model.add(layers.MaxPooling2D(pool_size=(2, 2))) mod...
No
5
4
Model_Train
choose_model_class
1,583,645
1
A
0
0
0
0
0
16
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,151
X_test, Y_test = prepare_data(test_images_dogs_cats)
No
5
21
Data_Transform
prepare_x_and_y
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,152
Y_pred = model.predict(np.array(X_val)) #####predict cat | predict dog for i in range(0,5): if Y_pred[i, 0] >= 0.5: print('I am {:.2%} sure this is a Dog'.format(Y_pred[i][0])) else: print('I am {:.2%} sure this is a Cat'.format(1-Y_pred[i][0])) plt.imshow(X_val[i]) plt.s...
Yes
2
48
Model_Evaluation
predict_on_test
null
1
A
0
2
4
0
0
8
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,153
XtestAdult = nTestAdult[["Age","Education-Num","Capital Gain", "Capital Loss", "Hours per week"]] XtestAdult.head()
No
4
41
Debug
show_table
1,554,855
1
A
0
0
0
0
0
2
ok
1
1
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Dependent Threshold Checker"]
3
A
7,154
# Validating the score on validation data score = model.evaluate_generator(validation_generator) print('Test score:', score[0]) print('Test accuracy:', score[1])
No
5
49
Model_Evaluation
compute_test_metric
1,583,645
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,155
knn = KNeighborsClassifier(n_neighbors=3)
No
5
4
Model_Train
choose_model_class
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,157
from sklearn.metrics import accuracy_score
No
5
22
Environment
import_modules
null
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Dependent Threshold Checker"]
0
A
7,158
UCITest = pd.read_csv("../input/mydata/adult.test",<br> names=[<br> "Age", "Workclass", "fnlwgt", "Education", "Education-Num", "Martial Status",<br> "Occupation", "Relationship", "Race", "Sex", "Capital Gain", "Capital Loss",<br> "Hours per week", "Country", "Target"],<br> sep=r\'\\s...
No
5
45
Data_Extraction
load_from_csv
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,159
UCITest.head()
No
5
41
Debug
show_table
1,554,855
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Dependent Threshold Checker"]
3
A
7,160
nUCITest = UCITest.dropna()
No
5
17
Data_Transform
correct_missing_values
1,554,855
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Dependent Threshold Checker"]
3
A
7,161
nUCITest.head()
No
5
41
Debug
show_table
1,554,855
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Dependent Threshold Checker"]
3
A
7,162
XUCITest = nUCITest[["Age","Education-Num","Capital Gain", "Capital Loss", "Hours per week"]]
No
5
77
Other
define_variables
1,554,855
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Dependent Threshold Checker"]
3
A
7,163
XUCITest.head()
No
5
41
Debug
show_table
1,554,855
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Dependent Threshold Checker"]
3
A
7,164
YUCIPred = knn.predict(XUCITest) YUCIPred
No
5
48
Model_Evaluation
predict_on_test
1,554,855
1
A
0
0
0
1
0
2
ok
3
3
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}, {"detector": "framework_specific", "framework":...
A
no applicable ML-specific findings
[]
["Dependent Threshold Checker", "Exception Handling Checker", "Unit Testing Checker"]
3
A
7,165
accuracy_score(YUCIPred, YUCITest)
No
5
49
Model_Evaluation
compute_test_metric
1,554,855
1
A
0
0
0
0
0
1
ok
2
2
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}, {"detector": "framework_specific", "framework":...
A
no applicable ML-specific findings
[]
["Dependent Threshold Checker", "Unit Testing Checker"]
3
A
7,166
knn.fit(Xadult, Yadult)
No
5
7
Model_Train
train_model
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,167
YUCIPred = knn.predict(XUCITest)
No
5
48
Model_Evaluation
predict_on_test
1,554,855
1
A
0
0
0
0
0
1
ok
3
3
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}, {"detector": "framework_specific", "framework":...
A
no applicable ML-specific findings
[]
["Dependent Threshold Checker", "Exception Handling Checker", "Unit Testing Checker"]
3
A
7,168
accuracy_score(YUCITest, YUCIPred)
No
5
49
Model_Evaluation
compute_test_metric
1,554,855
1
A
0
0
0
0
0
1
ok
2
2
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}, {"detector": "framework_specific", "framework":...
A
no applicable ML-specific findings
[]
["Dependent Threshold Checker", "Unit Testing Checker"]
3
A
7,169
accuracies = {} for i in range(1, 100): knn = KNeighborsClassifier(n_neighbors=i) knn.fit(Xadult, Yadult) scores = cross_val_score(knn, Xadult, Yadult, cv=10) Ypred = knn.predict(XUCITest) accuracy = accuracy_score(YUCITest,Ypred) accuracies[i] = accuracy print('k={}, accuracy={}, CVmean={}...
Yes
4
49
Model_Evaluation
compute_test_metric
1,554,855
1
A
0
1
1
0
0
9
ok
9
7
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Verbose Mode Checker", "fix": "Enable verbose mode for long training processes.", "benefits": "Provides better insights into model training progress.", "location": "Line 8"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "...
C
No random seed setting detected=low, Only accuracy metric=medium
[{"type": "No random seed setting detected", "severity": "low"}, {"type": "Only accuracy metric", "severity": "medium"}]
["Dependent Threshold Checker", "Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"]
3
C
7,170
ks = list(accuracies.keys()) acc = list(accuracies.values()) plt.plot(ks, acc) plt.show()
No
5
33
Visualization
distribution
1,554,855
1
A
0
0
0
0
0
4
ok
1
1
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Dependent Threshold Checker"]
3
A
7,171
knn = KNeighborsClassifier(n_neighbors=28)
No
5
4
Model_Train
choose_model_class
1,554,855
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Dependent Threshold Checker"]
3
A