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,813
df['Intersection']=df['Address'].apply(lambda x : 1 if '/' in x else 0) df['Block']=df['Address'].apply(lambda x : 1 if 'Block' in x else 0) df_test['Intersection']=df_test['Address'].apply(lambda x : 1 if '/' in x else 0) df_test['Block']=df_test['Address'].apply(lambda x : 1 if 'Block' in x else 0)
No
5
8
Data_Transform
feature_engineering
2,236,557
1
A
0
4
4
0
0
4
ok
2
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: /. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 3"}, {"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path d...
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
2
A
7,814
Id=df['Id'] df=df.drop(['Descript','Resolution','Id'],axis=1) #----------test data--------- Id_test=df_test['Id'] df_test=df_test.drop(['Descript','Resolution','Id'],axis=1)
No
5
10
Data_Transform
drop_column
2,236,557
1
A
0
0
0
0
0
4
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
7,815
lasso = linear_model.Lasso(alpha=0.1) score1 = cross_val_score(lasso, X_train, y_train, cv=10) score1.mean()
No
5
28
Model_Train
compute_train_metric
2,078,255
1
A
0
0
0
0
0
3
ok
3
3
[{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing ...
A
no applicable ML-specific findings
[]
["Exception Handling Checker", "Import Checker", "Unit Testing Checker"]
6
A
7,816
ridge = linear_model.Ridge(alpha=0.1) score2 = cross_val_score(ridge, X_train, y_train, cv=10) score2.mean()
No
5
28
Model_Train
compute_train_metric
2,078,255
1
A
0
0
0
0
0
3
ok
3
3
[{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing ...
A
no applicable ML-specific findings
[]
["Exception Handling Checker", "Import Checker", "Unit Testing Checker"]
6
A
7,817
from sklearn.neighbors import KNeighborsRegressor
No
5
22
Environment
import_modules
null
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
0
A
7,818
score3 = [] neighbor = [] for k in range(10, 100, 10): knn = KNeighborsRegressor(n_neighbors=k, weights='distance') score3.append(cross_val_score(knn, X_train, y_train, cv=10).mean()) neighbor.append(k)
No
5
2
Hyperparam_Tuning
find_best_params
2,078,255
1
A
0
1
1
0
0
6
ok
4
3
[{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing ...
A
no applicable ML-specific findings
[]
["Exception Handling Checker", "Import Checker", "Unit Testing Checker"]
6
A
7,819
score3
No
5
53
Other
something_strange
null
1
A
0
0
0
1
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,820
plt.plot(neighbor, score3, 'ro')
No
5
33
Visualization
distribution
2,078,255
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}]
A
no applicable ML-specific findings
[]
["Import Checker"]
6
A
7,821
score3 = [] neighbor = [] for k in range(1, 32, 2): knn = KNeighborsRegressor(n_neighbors=k, weights='distance') score3.append(cross_val_score(knn, X_train, y_train, cv=10).mean()) neighbor.append(k)
No
5
84
Other
not_enough_vertices
2,078,255
1
A
0
1
1
0
0
6
ok
4
3
[{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing ...
A
no applicable ML-specific findings
[]
["Exception Handling Checker", "Import Checker", "Unit Testing Checker"]
6
A
7,822
neighbor
No
5
41
Debug
show_table
2,078,255
1
A
0
0
0
1
0
1
ok
1
1
[{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}]
A
no applicable ML-specific findings
[]
["Import Checker"]
6
A
7,823
knn = KNeighborsRegressor(n_neighbors=21) score3 = cross_val_score(knn, X_train, y_train, cv=10) score3.mean()
No
5
28
Model_Train
compute_train_metric
2,078,255
1
A
0
0
0
0
0
3
ok
3
3
[{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing ...
A
no applicable ML-specific findings
[]
["Exception Handling Checker", "Import Checker", "Unit Testing Checker"]
6
A
7,824
score4 = [] trees = [] for n in range(10,101,10): regr = RandomForestRegressor(max_depth=2, random_state=0, n_estimators=n) score4.append(cross_val_score(regr, X_train, y_train, cv=10).mean()) trees.append(n)
No
2
27
Model_Train
predict_on_train
2,078,255
1
A
0
1
1
0
0
6
ok
5
4
[{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Verbose Mode ...
A
no applicable ML-specific findings
[]
["Exception Handling Checker", "Import Checker", "Unit Testing Checker", "Verbose Mode Checker"]
6
A
7,825
plt.plot(trees, score4, 'ro')
No
5
56
Visualization
plot_predictions
2,078,255
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}]
A
no applicable ML-specific findings
[]
["Import Checker"]
6
A
7,826
regr = RandomForestRegressor(max_depth=2, random_state=0, n_estimators=80) score4.append(cross_val_score(regr, X_train, y_train, cv=10).mean())
No
5
28
Model_Train
compute_train_metric
2,078,255
1
A
0
0
0
0
0
2
ok
5
4
[{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Verbose Mode ...
A
no applicable ML-specific findings
[]
["Exception Handling Checker", "Import Checker", "Unit Testing Checker", "Verbose Mode Checker"]
6
A
7,827
score4[-1]
No
5
41
Debug
show_table
2,078,255
1
A
0
0
0
0
0
1
ok
2
2
[{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C...
A
no applicable ML-specific findings
[]
["Column Selection Checker", "Import Checker"]
6
A
7,828
df["raw_radial"]=np.sqrt(np.power(df[\'X\'],2) + np.power(df[\'Y\'],2))<br><br>df_test["raw_radial"]=np.sqrt(np.power(df_test[\'X\'],2) + np.power(df_test[\'Y\'],2))
No
5
8
Data_Transform
feature_engineering
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,829
test = pd.read_csv('../input/datasetss/test.csv')
No
5
45
Data_Extraction
load_from_csv
2,078,255
1
A
0
0
0
0
0
1
ok
2
2
[{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path de...
A
no applicable ML-specific findings
[]
["Hardcoded file path", "Import Checker"]
6
A
7,830
le_res=le.fit_transform(df['Category']) cat=pd.DataFrame(le_res) cat.columns=['Category'] df=df.drop(labels=['Category'],axis=1) df=pd.concat([cat,df],axis=1) df.columns
Yes
3
20
Data_Transform
categorify
2,236,557
1
A
0
0
0
0
0
6
ok
5
5
[{"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...
D
Cross Validation Checker=low, Data Leakage Checker=high
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}]
["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
2
D
7,831
X_test = test.drop('Id',axis=1)
No
5
10
Data_Transform
drop_column
2,078,255
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}]
A
no applicable ML-specific findings
[]
["Import Checker"]
6
A
7,832
lasso.fit(X_train, y_train)
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,833
prediction1 = lasso.predict(X_test)
No
5
48
Model_Evaluation
predict_on_test
2,078,255
1
A
0
0
0
0
0
1
ok
3
3
[{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing ...
A
no applicable ML-specific findings
[]
["Exception Handling Checker", "Import Checker", "Unit Testing Checker"]
6
A
7,834
df_test.columns
No
5
71
Debug
show_columns
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,835
df=df[['Address', 'Minute', 'Hour', 'Day', 'Month', 'Year', 'District', 'DayOfWeek', 'X', 'Y', 'rot45_X', 'rot45_Y', 'rot30_X', 'rot30_Y', 'radial60', 'Intersection', 'Block', 'raw_radial', 'closest_centers_f', 'label']] df_test=df_test[['Address', 'Minute', 'Hour', 'Day', 'Month', 'Year', 'Distr...
No
5
10
Data_Transform
drop_column
2,236,557
1
A
0
0
0
0
0
8
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
7,836
prediction1 = abs(prediction) prediction1[0]
Yes
4
55
Data_Export
prepare_output
2,078,255
1
A
0
0
0
0
0
2
ok
2
2
[{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C...
A
no applicable ML-specific findings
[]
["Column Selection Checker", "Import Checker"]
6
A
7,837
prediction = pd.DataFrame({'Id':test.Id,'median_house_value': prediction1[0]})
No
5
55
Data_Export
prepare_output
2,078,255
1
A
0
0
0
0
0
1
ok
2
2
[{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C...
A
no applicable ML-specific findings
[]
["Column Selection Checker", "Import Checker"]
6
A
7,838
prediction
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,839
# 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,840
train_df = pd.read_csv('../input/train.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
7,841
train_df.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,842
train_df['president'].value_counts().plot(kind = 'bar') plt.show()
No
5
33
Visualization
distribution
2,279,813
1
A
0
0
0
0
0
2
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, 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"}]
["Column Selection Checker", "Dependent Threshold Checker"]
8
B
7,850
#Independent Column X=df X.shape
No
5
58
Debug
show_shape
2,236,557
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
7,851
#Dependent X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.20,shuffle=False)
No
5
13
Data_Transform
split
2,236,557
1
A
0
0
0
0
0
1
ok
2
2
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear...
B
Cross Validation Checker=low, Randomness Control Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Randomness Control Checker", "severity": "low"}]
[]
2
B
7,853
train_data = [] for i, row in train_df.iterrows(): for text in row['text'].split('.'): train_data.append([row['president'], text]) train_data = pd.DataFrame(train_data, columns=['president', 'text'])
No
5
12
Data_Transform
create_dataframe
2,279,813
1
A
0
2
3
0
0
5
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, 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"}]
["Column Selection Checker", "Dependent Threshold Checker"]
8
B
7,854
train_data['president'].value_counts().plot(kind = 'bar') plt.show()
No
5
33
Visualization
distribution
2,279,813
1
A
0
0
0
0
0
2
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, 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"}]
["Column Selection Checker", "Dependent Threshold Checker"]
8
B
7,855
train_data.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,856
def remove_punctuation_numbers(text): punc_numbers = string.punctuation + '0123456789' return ''.join([l for l in text if l not in punc_numbers])
No
5
78
Data_Transform
string_transform
2,279,813
1
A
0
2
0
0
0
3
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"]
8
A
7,857
def tokeniser(text): return TreebankWordTokenizer().tokenize(text)
No
5
78
Data_Transform
string_transform
2,279,813
1
A
0
1
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"]
8
A
7,858
def lemmetizer(tokens): wordnet_lemmatizer = WordNetLemmatizer() return [wordnet_lemmatizer.lemmatize(word) for word in tokens]
No
5
84
Other
not_enough_vertices
2,279,813
1
A
0
1
0
0
0
3
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"]
8
A
7,859
def remove_stop_words(tokens): return [t for t in tokens if t not in set(stopwords.words('english'))]
No
5
84
Other
not_enough_vertices
2,279,813
1
A
0
2
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"]
8
A
7,860
def data_cleaner(text): text = text.lower() text = remove_punctuation_numbers(text) lst = tokeniser(text) lst = remove_stop_words(lst) return ' '.join(lemmetizer(lst))
No
5
78
Data_Transform
string_transform
2,279,813
1
A
0
1
0
0
0
6
ok
2
2
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}, {"detector": "general_ml", "framework": "Genera...
A
no applicable ML-specific findings
[]
["Dependent Threshold Checker", "Missing function docstring"]
8
A
7,861
train_data['clean_text'] = train_data['text'].apply(data_cleaner)
No
5
8
Data_Transform
feature_engineering
2,279,813
1
A
0
0
0
0
0
1
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
[{"type": "Cross Validation Checker", "severity": "low"}]
["Column Selection Checker", "Dependent Threshold Checker"]
8
B
7,862
for pres in train_data['president'].unique(): words =[] for sentence in train_data[train_data['president'] == pres].clean_text: words.extend(tokeniser(sentence)) wordcloud = WordCloud().generate_from_frequencies(frequencies=Counter(words)) plt.figure(figsize=(12,8)) plt.imshow(wordcloud...
No
5
53
Other
something_strange
2,279,813
1
A
0
2
3
0
0
10
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
[{"type": "Cross Validation Checker", "severity": "low"}]
["Column Selection Checker", "Dependent Threshold Checker"]
8
B
7,863
train_data.president = train_data.president.map({'deKlerk':0,'Mandela':1, 'Mbeki':2, 'Motlanthe':3, 'Zuma': 4, 'Ramaphosa':5})
No
5
20
Data_Transform
categorify
2,279,813
1
A
0
0
0
0
0
3
ok
2
2
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear...
B
Cross Validation Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}]
["Dependent Threshold Checker"]
8
B
7,864
X = train_data.clean_text y = train_data.president X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=0, stratify=y)
Yes
4
13
Data_Transform
split
2,279,813
1
A
0
0
0
0
0
6
ok
2
2
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear...
B
Cross Validation Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}]
["Dependent Threshold Checker"]
8
B
7,865
vect = CountVectorizer(ngram_range=(1,2))
No
5
84
Other
not_enough_vertices
2,279,813
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"]
8
A
7,866
X_train_ = vect.fit_transform(X_train)
No
5
8
Data_Transform
feature_engineering
2,279,813
1
A
0
0
0
0
0
1
ok
6
6
[{"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...
D
Cross Validation Checker=low, Data Leakage Checker=high
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}]
["Dependent Threshold Checker", "Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
8
D
7,867
log = LogisticRegressionCV(dual=False, penalty='l2', multi_class='multinomial')
No
5
4
Model_Train
choose_model_class
2,279,813
1
A
0
0
0
0
0
1
ok
2
2
[{"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": "Dependent Thresh...
C
Scaler Missing Checker=medium
[{"type": "Scaler Missing Checker", "severity": "medium"}]
["Dependent Threshold Checker"]
8
C
7,868
log.fit(X_train_, y_train)
No
5
7
Model_Train
train_model
2,279,813
1
A
0
0
0
0
0
1
ok
5
5
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear...
B
Cross Validation Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}]
["Dependent Threshold Checker", "Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
8
B
7,869
print(accuracy_score(y_train, log.predict(X_train_)))
No
5
28
Model_Train
compute_train_metric
2,279,813
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"]
8
A
7,870
print(accuracy_score(y_test, log.predict(vect.transform(X_test))))
No
5
49
Model_Evaluation
compute_test_metric
2,279,813
1
A
0
0
0
0
0
1
ok
6
5
[{"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":...
B
No random seed setting detected=low
[{"type": "No random seed setting detected", "severity": "low"}]
["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"]
8
B
7,871
test_data = pd.read_csv('../input/test.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
7,872
test_data.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,873
test_data.text = test_data.text.apply(data_cleaner)
No
5
8
Data_Transform
feature_engineering
2,279,813
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"]
8
A
7,874
test_data['president'] = log.predict(vect.transform(test_data.text))
No
5
48
Model_Evaluation
predict_on_test
2,279,813
1
A
0
0
0
0
0
1
ok
7
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": "Dependent Th...
B
No random seed setting detected=low
[{"type": "No random seed setting detected", "severity": "low"}]
["Column Selection Checker", "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"]
8
B
7,875
test_data.drop('text', axis=1, inplace=True,)
No
5
10
Data_Transform
drop_column
2,279,813
1
A
0
0
0
0
0
1
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 9"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold C...
A
no applicable ML-specific findings
[]
["Dependent Threshold Checker", "InPlace Checker"]
8
A
7,876
test_data.to_csv('Thapelo_log.csv',index=False)
No
5
25
Data_Export
save_to_csv
2,279,813
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"]
8
A
7,877
import pandas as pd import numpy as np import string import re import seaborn as sns import matplotlib.pyplot as plt sns.set(style='whitegrid', palette='muted', rc={'figure.figsize': (15,10)})
Yes
4
22
Environment
import_modules
2,297,927
1
A
0
0
0
0
0
8
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
7
A
7,878
print(train.shape, test.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,879
pres = {'deKlerk': 0, 'Mandela': 1, 'Mbeki': 2, 'Motlanthe': 3, 'Zuma': 4, 'Ramaphosa': 5} train.replace({'president': pres}, inplace=True)
No
5
20
Data_Transform
categorify
null
1
A
0
0
0
0
0
7
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,880
# speech number: intro lines starts = { 0: 1, 1: 1, 2: 1, 3: 12, 4: 12, 5: 5, 6: 1, 7: 1, 8: 8, 9: 9, 10: 12, 11: 14, 12: 14, 13: 15, 14: 15, 15: 15, 16: 15, 17: 15, 18: 15, 19: 15, 20: 20, 21: 1, 22: 15, 23: 20, 24: 20,...
No
5
77
Other
define_variables
null
1
A
0
0
0
0
0
33
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,881
def divide_on(df, char): # iterate over text column of DataFrame, splitting at each occurrence of char sentences = [] # let's split the data into senteces for i, row in df.iterrows(): # skip the intro lines of the speech for sentence in row['text'].split(char)[starts[i]:]:...
No
5
78
Data_Transform
string_transform
null
1
A
0
3
3
0
0
7
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,882
train = divide_on(train, '.')
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,883
train.head(5)
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,884
train['president'].value_counts()
No
5
72
EDA
count_values
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,885
# proportion of total train['president'].value_counts()/train.shape[0]
No
5
72
EDA
count_values
null
1
A
0
0
0
1
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,886
train['sentence'] = None test['president'] = None df = pd.concat([train, test], axis=0, sort=False)
No
5
11
Data_Transform
concatenate
null
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,887
# reorder columns df = df[['sentence', 'text', 'president']]
No
5
10
Data_Transform
drop_column
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,888
df.tail()
No
5
41
Debug
show_table
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,889
def fixup(text):<br> <br> # remove punctuation<br> text = \'\'.join([char for char in text if char == \'-\' or char not in string.punctuation])<br> # remove special characters<br> text = text.replace(r\'^[*-]\', \'\')<br> # remove numbers<br> text = \'\'.join([char for char in text if not char.isdi...
No
5
78
Data_Transform
string_transform
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,890
# get length of sentence as variable df['length'] = df['text'].apply(len)
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,891
# what are our longest sentences? df.sort_values(by='length', ascending=False).head(10)
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,892
df.loc[3930][1]
No
5
14
Data_Transform
filter
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,893
# what are our shortest sentences? df.sort_values(by='length').head(5)
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,894
# let's check the shortest sentences in our test set df[pd.isnull(df['president'])].sort_values(by='length').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,895
# sentences with just a few characters are of no use to us df = df[df['length']>10]
No
5
14
Data_Transform
filter
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,896
# what are our shortest sentences now? df.sort_values(by='length').head(5)
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,897
df['president'].value_counts()
No
5
72
EDA
count_values
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,898
from sklearn.preprocessing import StandardScaler from sklearn.model_selection import train_test_split from sklearn.model_selection import GridSearchCV from keras.wrappers.scikit_learn import KerasClassifier from keras.models import Sequential from keras.layers import Dense, Activation, Dropout from sklearn.preprocessin...
No
5
22
Environment
import_modules
2,297,927
1
A
0
0
0
0
0
8
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
7
A
7,899
tfidf = TfidfVectorizer(strip_accents='unicode', ngram_range=(1,3), stop_words='english', min_df=6) X = tfidf.fit_transform(df['text']).todense() X.shape
Yes
4
8
Data_Transform
feature_engineering
2,297,927
1
A
0
0
0
0
0
3
ok
11
9
[{"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, Cross-validation not detected=low, Data Leakage Checker=high, No random seed setting detected=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"}]
["Column Selection 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"]
7
D
7,900
tfidf.get_feature_names()
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,901
X = pd.DataFrame(data=X, columns=tfidf.get_feature_names())
No
5
21
Data_Transform
prepare_x_and_y
2,297,927
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
7
A
7,902
df = df.drop(columns=['text', 'length'], axis=1)
No
5
10
Data_Transform
drop_column
2,297,927
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
7
A
7,903
X = pd.DataFrame(np.hstack((df, X)))
No
5
12
Data_Transform
create_dataframe
2,297,927
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
7
A
7,904
HYPER_PARAMS = { 'learning_rate': 0.02, 'n_estimators':800, 'max_depth': 6, 'subsample': 0.8, 'colsample_bytree': 0.8, 'max_delta_step': 1, 'objective': 'multi:softmax', 'nthread': 4, 'seed': 1747 } model = xgb.XGBClassifier(**HYPER_PARAMS) model.fit(X,y)
No
5
7
Model_Train
train_model
2,236,557
1
A
0
0
0
0
0
13
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"]
2
B
7,905
X.columns = ['sentence_id', 'president_id'] + tfidf.get_feature_names()
No
5
61
Data_Transform
rename_columns
2,297,927
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
7
A
7,906
y_pred=model.predict_proba(df_test)
No
5
48
Model_Evaluation
predict_on_test
2,236,557
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"]
2
A
7,907
train = X[pd.isnull(X['sentence_id'])] test = X[pd.notnull(X['sentence_id'])]
No
5
14
Data_Transform
filter
2,297,927
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"]
7
A
7,908
X_train = train.drop(['sentence_id', 'president_id'], axis=1) X_test = test.drop(['sentence_id', 'president_id'], axis=1)
No
5
10
Data_Transform
drop_column
2,297,927
1
A
0
0
0
0
0
2
ok
1
1
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}]
B
Cross Validation Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}]
[]
7
B
7,909
y_pred= pd.DataFrame(y_pred, index=Id_test,columns = le.classes_)
No
5
12
Data_Transform
create_dataframe
2,236,557
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
7,910
y_pred.to_csv("submit.csv", float_format = \'%.5F\')
No
5
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
7,918
def one_hot_encode(label): # initialize zero array vec = [0, 0, 0, 0, 0, 0] # set index of array corresponding to label = 1 vec[label] = 1 return vec # save encoded labels as target for model y_train = np.vstack(row for row in train['president_id'].apply(one_hot_encode).values)
No
5
20
Data_Transform
categorify
2,297,927
1
A
1
1
0
0
5
5
ok
4
4
[{"detector": "framework_specific", "framework": "Pandas", "name": "DataFrame Conversion Checker", "fix": "Use .to_numpy() instead of .values.", "benefits": "Ensures future compatibility and avoids unexpected behaviour.", "location": "Line 19"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column ...
B
Cross Validation Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}]
["Column Selection Checker", "DataFrame Conversion Checker", "Missing function docstring"]
7
B
7,919
y_train[600]
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,920
print('Train size:', X_train.shape) print('Test size:', X_test.shape)
No
5
58
Debug
show_shape
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,921
# 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,922
# importing the modulus from keras.preprocessing.image import ImageDataGenerator,img_to_array,load_img from keras.models import Sequential from keras.layers import Dropout, Flatten, Dense , Activation from keras import applications import re
No
5
22
Environment
import_modules
2,309,282
1
A
0
0
0
0
0
5
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
7,923
def create_model(lyrs=[X_train.shape[1], 1028, 512, 256], act='relu', opt='Adam', dr=0.25): model = Sequential() # create first hidden layer model.add(Dense(lyrs[0], input_dim=X_train.shape[1], activation=act)) # create additional hidden layers for i in range(1,len(lyrs)): mod...
No
5
4
Model_Train
choose_model_class
2,297,927
1
A
0
2
1
0
0
9
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"]
7
A
7,924
model = create_model() print(model.summary())
No
5
84
Other
not_enough_vertices
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,925
# train model on full train set, with 80/20 CV split<br>training = model.fit(X_train, y_train, epochs=5, batch_size=64, validation_split=0.2)<br>val_acc = np.mean(training.history[\'val_acc\'])<br>print("\<br>%s: %.2f%%" % (\'val_acc\', val_acc*100))
Yes
4
7
Model_Train
train_model
null
1
A
0
0
0
0
0
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,926
# summarize history for accuracy plt.plot(training.history['acc']) plt.plot(training.history['val_acc']) plt.title('model accuracy') plt.ylabel('accuracy') plt.xlabel('epoch') plt.legend(['train', 'validation'], loc='upper left') plt.show()
No
5
35
Visualization
learning_history
null
1
A
0
0
0
0
0
7
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,927
predictions = model.predict(X_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