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,581
from sklearn import preprocessing scaler = preprocessing.StandardScaler().fit(X_train) X_train_scaled = scaler.transform(X_train)
No
5
18
Data_Transform
normalization
2,077,825
1
A
0
0
0
0
0
3
ok
10
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...
E
Cross Validation Checker=low, Data Leakage Checker=high, Inconsistent scaling methods=high, No random seed setting detected=low, Pipeline Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "Inconsistent scaling methods", "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"]
7
E
7,582
from sklearn import linear_model from sklearn.model_selection import cross_val_score from sklearn.metrics import mean_squared_error reg = linear_model.LinearRegression().fit(X_train_scaled, Y) reg.score(X_train_scaled, Y)
Yes
4
7
Model_Train
train_model
2,077,825
1
A
0
0
0
0
0
5
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, Cross-validation not detected=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}]
["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
7
B
7,583
from sklearn import neighbors knn = neighbors.KNeighborsRegressor(n_neighbors=6) knn.fit(X_train_scaled, Y) knn_scores = cross_val_score(knn, X_train_scaled, Y, cv=10) np.mean(knn_scores)
Yes
3
7
Model_Train
train_model
2,077,825
1
A
0
0
0
0
0
5
ok
4
3
[{"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 11"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": ...
A
no applicable ML-specific findings
[]
["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
7
A
7,584
from sklearn import ensemble params = {'n_estimators': 500, 'max_depth': 5, 'min_samples_split': 2, 'learning_rate': 0.01, 'loss': 'ls'} gbr = ensemble.GradientBoostingRegressor(**params) gbr.fit(X_train_scaled, Y)
Yes
4
7
Model_Train
train_model
2,077,825
1
A
0
0
0
0
0
5
ok
5
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"]
7
B
7,585
Yreg = reg.predict(X_train_scaled) Yknn = knn.predict(X_train_scaled) Ygbr = gbr.predict(X_train_scaled)
No
5
27
Model_Train
predict_on_train
2,077,825
1
A
0
0
0
0
0
3
ok
6
4
[{"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...
B
No random seed setting detected=low
[{"type": "No random seed setting detected", "severity": "low"}]
["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker"]
7
B
7,586
from sklearn.metrics import mean_squared_log_error mean_squared_log_error(Y, Yknn)
No
5
28
Model_Train
compute_train_metric
2,077,825
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
7
A
7,587
mean_squared_log_error(Y, Ygbr)
No
5
28
Model_Train
compute_train_metric
2,077,825
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
7
A
7,588
testdf = pd.read_csv("../input/atividade-3-pmr3508/test.csv",<br> sep=r\'\\s*,\\s*\',<br> engine=\'python\',<br> na_values="?")<br>testdf = testdf.replace(np.nan,\' \', regex=True)
Yes
4
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,589
testdf["coord"] = testdf["latitude"].map(str) + \', \' + testdf["longitude"].map(str)
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,590
texts = ["Hooli stock price soared after a dip in PiedPiper revenue growth.",<br> "Captain Tsubasa scores a magnificent goal for the Japanese team.",<br> "Merryweather mercenaries are sent on another mission, as government oversight groups call for new sanctions.",<br> "Beyonc releases a new alb...
Yes
4
8
Data_Transform
feature_engineering
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,591
test_loc = pd.read_csv("../input/california-prices/test_loc.csv",<br> sep=r\'\\s*"\',<br> engine=\'python\')<br><br>test_loc.columns = [col.replace(\'"\', \'\') for col in test_loc.columns]<br>test_loc = test_loc.replace(\'"\',\'\', regex=True)<br><br>test_loc[\'location\'] = test_loc[\'location\'].st...
Yes
4
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,592
#import os print(os.listdir("../input/bbc-test"))
No
5
88
Debug
list_files
1,967,574
3
C
1
0
0
0
5
1
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/bbc-test. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 11"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
9
C
7,593
TEST_PATH = os.path.join("../input/bbc-test", "BBC News Test (1).csv") #Load the data using pandas : Create a DataFrame test_df = pd.read_csv(TEST_PATH)
No
5
45
Data_Extraction
load_from_csv
1,967,574
1
A
0
0
0
0
0
2
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/bbc-test. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 10"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
9
A
7,594
test_cities = pd.DataFrame(test_loc.Id)<br>test_cities = test_cities.set_index(\'Id\')<br>test_cities[\'city\'] = \'\'<br><br>for index, row in test_loc.iterrows():<br> row_id = row[\'Id\']<br> city = row[\'location\'][-2]<br> if city != \'n\':<br> test_cities.at[row_id, \'city\'] = city.lstrip(\' \')<b...
Yes
4
25
Data_Export
save_to_csv
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,595
test_cities = pd.read_csv("../input/california-prices/test_cities.csv",<br> engine=\'python\')<br><br>testdf[\'cities\'] = test_cities[\'city\']<br>
Yes
4
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,596
import pandas as pd import numpy
No
5
22
Environment
import_modules
2,078,255
1
A
0
0
0
0
0
2
ok
2
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"}, {"detector": "framework_specific", "framework": "General", "name": "Import Checker", ...
A
no applicable ML-specific findings
[]
["Import Checker"]
6
A
7,597
data = pd.read_csv("../input/datasetss/train.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,598
X_test = testdf.copy() X_test['people_pb'] = X_test.population/X_test.total_bedrooms X_test['people_ph'] = X_test.population/X_test.households X_test['income_pr'] = X_test.median_income/X_test.total_rooms X_test = X_test.filter(['median_age','total_rooms', 'total_bedrooms', 'population', 'households', 'median_income'...
Yes
3
8
Data_Transform
feature_engineering
2,077,825
1
A
0
0
0
0
0
6
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
7
A
7,599
data
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,600
X_test_scaled = scaler.transform(X_test)
No
5
18
Data_Transform
normalization
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,601
Ypred = knn.predict(X_test_scaled)
No
5
48
Model_Evaluation
predict_on_test
2,077,825
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"]
7
A
7,602
prediction.to_csv("prediction.csv", index=False)
No
5
25
Data_Export
save_to_csv
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,603
data = data.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,604
import pandas as pd import matplotlib.pyplot as plt import numpy as np import sklearn as skl from sklearn.neighbors import KNeighborsRegressor as KNR from sklearn.tree import DecisionTreeRegressor as DTR from sklearn.linear_model import Lasso, LassoCV from sklearn.model_selection import cross_val_score as cvs
No
5
22
Environment
import_modules
2,078,637
1
A
0
0
0
0
0
8
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
7
A
7,605
data.isna().sum()
No
5
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,606
arquivo1 = '../input/test.csv' tester = pd.read_csv(arquivo1, engine = 'python') tester.shape
Yes
4
45
Data_Extraction
load_from_csv
2,078,637
1
A
0
0
0
0
0
3
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/test.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 8"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
7
A
7,607
X_train = data.drop('median_house_value', axis=1) y_train = data.median_house_value
No
5
21
Data_Transform
prepare_x_and_y
2,078,255
1
A
0
0
0
0
0
2
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,608
from sklearn import linear_model 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,609
arquivo2 = '../input/train.csv' trainer = pd.read_csv(arquivo2, engine = 'python') trainer.shape
Yes
4
45
Data_Extraction
load_from_csv
2,078,637
1
A
0
0
0
0
0
3
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/train.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 8"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
7
A
7,610
trainer.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,611
best_knr = KNR(n_neighbors=melhor_knr(train,5,50)[1])
No
4
4
Model_Train
choose_model_class
2,078,637
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
7
A
7,612
best_knr.fit(train,trainer['median_house_value'])
No
5
7
Model_Train
train_model
2,078,637
1
A
0
0
0
0
0
1
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
[{"type": "Cross Validation Checker", "severity": "low"}]
["Column Selection Checker", "Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
7
B
7,613
knr_pred = best_knr.predict(test)
No
5
48
Model_Evaluation
predict_on_test
2,078,637
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"]
7
A
7,614
Submit1 = pd.DataFrame() Submit1.insert(0, 'Id', tester['Id']) Submit1.insert(1,'median_house_value', knr_pred)
Yes
4
12
Data_Transform
create_dataframe
2,078,637
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"]
7
A
7,615
best_tree = DTR(max_depth=10)
No
5
4
Model_Train
choose_model_class
2,078,637
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
7
A
7,616
best_tree.fit(train,target)
No
5
7
Model_Train
train_model
2,078,637
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"]
7
B
7,617
tree_pred = best_tree.predict(test) tree_pred
No
5
48
Model_Evaluation
predict_on_test
2,078,637
1
A
0
0
0
1
0
2
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"]
7
A
7,618
lcv = LassoCV().fit(train, target) lcv.score(train, target)
Yes
4
7
Model_Train
train_model
2,078,637
1
A
0
0
0
0
0
2
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, Cross-validation not detected=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}]
["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
7
B
7,619
lasso = Lasso(max_iter = 100000, selection = 'random') lasso.fit(train, target) pred_lasso = lasso.predict(test) pred_lasso
Yes
3
7
Model_Train
train_model
2,078,637
1
A
0
0
0
1
0
4
ok
8
7
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear...
B
Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}]
["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"]
7
B
7,620
# 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,621
training_labels[training_labels == 0] = -1 testing_labels[testing_labels == 0] = -1
No
5
8
Data_Transform
feature_engineering
2,083,980
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"]
4
A
7,622
from sklearn.model_selection import cross_val_score, GridSearchCV clf = GridSearchCV(AveragePerceptron(), param_grid={'learning_rate':[1, 0.1, 0.01], 'margin':[ 0, 0.1], 'decay': [False, True], 'epochs':[50], 'avg_decay':[False, True]}, cv=10, scoring='accuracy', n_jobs=-1) clf.fit(testing_data, testing_labels)
No
5
6
Hyperparam_Tuning
train_on_grid
2,083,980
1
A
0
0
0
0
0
3
ok
5
3
[{"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 6"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "...
A
no applicable ML-specific findings
[]
["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
4
A
7,623
clf.best_estimator_.score(testing_data, testing_labels)
No
5
49
Model_Evaluation
compute_test_metric
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,624
with open('submission.csv', 'w') as submission:<br> with open('../input/movie-ratings/movie-ratings/data-splits/data.eval.anon.id', 'r') as example_ids:<br> submission.write('example_id,label\<br>')<br> for example_id, label in zip(example_ids, submission_pred):<br> submission.write('{},{}\<...
No
4
25
Data_Export
save_to_csv
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,625
%matplotlib inline import numpy as np # linear algebra import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) from fastai.structured import * import matplotlib.pyplot as plt from sklearn.metrics import mean_squared_error from math import sqrt from sklearn.ensemble import RandomForestRegressor from IPyth...
No
4
88
Debug
list_files
null
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
0
null
7,626
df_train = pd.read_csv(f'{PATH}train.csv', parse_dates=['Open Date']) df_test = pd.read_csv(f'{PATH}test.csv', parse_dates=['Open Date']) df_joined = pd.concat([df_train.drop('revenue', axis=1), df_test], axis=0)
Yes
4
45
Data_Extraction
load_from_csv
null
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,627
X_train, X_test = prcs(df_joined.copy()) y_train = df_train['revenue'].copy().apply(np.log)
No
5
21
Data_Transform
prepare_x_and_y
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,628
m = RandomForestRegressor(n_jobs=-1, n_estimators=150, oob_score=True, max_features=0.5) m.fit(X_train, y_train) score(m,X_train, y_train)
Yes
4
7
Model_Train
train_model
2,094,493
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,629
df_preds = pd.DataFrame(columns=['Prediction'],index=X_test.index, data=np.exp(predict(m, X_test))) df_preds.to_csv('submission0.csv', index=True, index_label='Id') df_preds.head()
Yes
4
25
Data_Export
save_to_csv
2,094,493
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,630
df_preds = pd.DataFrame(columns=['Prediction'],index=X_test.index, data=np.exp(predict(models, X_test))) df_preds.to_csv('submission1.csv', index=True, index_label='Id') df_preds.head()
Yes
4
25
Data_Export
save_to_csv
2,094,493
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,631
X_train, X_test = prcs(df_joined.copy(), fe=['id'])<br><br># Doble transformacin para que la distribucin sea Normal<br>y_train = df_train['revenue'].copy().apply(np.sqrt).apply(np.log)
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
7,632
df_preds = pd.DataFrame(columns=['Prediction'],index=X_test.index, data=np.square(np.exp(predict(models, X_test)))) df_preds.to_csv('submission2.csv', index=True, index_label='Id') df_preds.head()
Yes
4
25
Data_Export
save_to_csv
2,094,493
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,633
X_train, X_test = prcs(df_joined.copy(), fe=['id', 'dummies'])<br><br># Doble transformacin para que la distribucin sea Normal<br>y_train = df_train['revenue'].copy().apply(np.sqrt).apply(np.log)
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
7,634
df_preds = pd.DataFrame(columns=['Prediction'],index=X_test.index, data=np.square(np.exp(predict(models, X_test)))) df_preds.to_csv('submission3.csv', index=True, index_label='Id') df_preds.head()
Yes
4
25
Data_Export
save_to_csv
2,094,493
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,635
X_train, X_test = prcs(df_joined.copy(), fe=['id', 'dummies', 'city'])<br><br># Doble transformacin para que la distribucin sea Normal<br>y_train = df_train['revenue'].copy().apply(np.sqrt).apply(np.log)
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
7,636
df_preds = pd.DataFrame(columns=['Prediction'],index=X_test.index, data=np.square(np.exp(predict(models, X_test)))) df_preds.to_csv('submission4.csv', index=True, index_label='Id') df_preds.head()
Yes
4
25
Data_Export
save_to_csv
2,094,493
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,637
X_train, X_test = prcs(df_joined.copy(), fe=['id', 'dummies', 'city', 'city_group'])<br><br># Doble transformacin para que la distribucin sea Normal<br>y_train = df_train['revenue'].copy().apply(np.sqrt).apply(np.log)
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
7,638
df_preds = pd.DataFrame(columns=['Prediction'],index=X_test.index, data=np.square(np.exp(predict(models, X_test)))) df_preds.to_csv('submission5.csv', index=True, index_label='Id') df_preds.head()
Yes
4
25
Data_Export
save_to_csv
2,094,493
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,639
import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline import warnings warnings.filterwarnings("ignore")
No
5
23
Environment
set_options
2,102,499
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
0
null
7,640
t = pd.read_csv('../input/training/training.csv') ts = pd.read_csv('../input/test/test.csv')
No
5
45
Data_Extraction
load_from_csv
2,102,499
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,641
t.shape[0]
No
5
58
Debug
show_shape
2,102,499
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,642
Y = np.array(t.drop('Image', axis=1).fillna(method='ffill'),dtype=float)
No
5
21
Data_Transform
prepare_x_and_y
2,102,499
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,643
#import packages from keras.models import Sequential from keras.layers import Dense, Activation, Dropout, Conv2D, MaxPool2D,Flatten, LeakyReLU #from keras.layers import LeakyReLU(alpha=0.3) as activation
No
5
22
Environment
import_modules
2,102,499
2
B
1
0
0
0
5
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,644
# Set the CNN model <br># my CNN architechture is In -> [[Conv2D->relu]*2 -> MaxPool2D -> Dropout]*2 -> Flatten -> Dense -> Dropout -> Out<br><br>model = Sequential()<br><br>model.add(Conv2D(filters = 32, kernel_size = (5,5),padding = \'Same\', <br> activation =\'linear\', input_shape = (96,96,1)))<br>m...
No
5
84
Other
not_enough_vertices
null
1
A
0
0
0
0
0
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,645
model.fit(X, Y, epochs=100, batch_size=128,validation_split = 0.2)
No
5
7
Model_Train
train_model
2,102,499
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,646
Y_ts = model.predict(X_ts)
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
7,647
look_id = pd.read_csv('../input/IdLookupTable.csv') look_id.drop('Location',axis=1,inplace=True)
Yes
4
45
Data_Extraction
load_from_csv
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,648
look_id['location_id'] = look_id.FeatureName.map(maps)
No
5
20
Data_Transform
categorify
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,649
look_id[['RowId','Location']].to_csv('Sub1.csv',index=False)
No
5
25
Data_Export
save_to_csv
2,102,499
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,650
%matplotlib inline import os import pandas as pd, numpy as np import matplotlib.pyplot as plt from skimage.io import imread import seaborn as sns # nice visuals from sklearn.model_selection import train_test_split # splitting data # quantifying models from sklearn.metrics import accuracy_score, classification_report, r...
No
5
77
Other
define_variables
null
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
0
null
7,651
trn_image, vld_image, trn_label , vld_label = train_test_split(full_train_df['image'], full_train_df['opacity'], test_size=0.25, random_state=2018) trn_image = np.stack(trn_image...
Yes
3
13
Data_Transform
split
2,108,474
1
A
0
0
0
0
0
6
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,652
out_model = models.Sequential() out_model.add(layers.Reshape((64, 64, 1), input_shape=trn_image.shape[1:])) out_model.add(layers.Conv2D(16, (3, 3), padding='valid', activation='relu')) out_model.add(layers.MaxPool2D((2, 2))) out_model.add(layers.Conv2D(32, (3, 3), padding='valid', activation='relu')) out_model.add(laye...
Yes
4
4
Model_Train
choose_model_class
2,108,474
1
A
0
0
0
0
0
17
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
7
A
7,653
from IPython.display import clear_output fit_results = out_model.fit(trn_image, trn_label, validation_data=(vld_image, vld_label), epochs=100) clear_output()
No
5
7
Model_Train
train_model
2,108,474
1
A
0
0
0
0
0
5
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"]
7
B
7,654
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(20, 10)) ax1.plot(fit_results.history['loss'], label='Training') ax1.plot(fit_results.history['val_loss'], label='Validation') ax1.legend() ax1.set_title('Loss History') ax2.plot(100*np.array(fit_results.history['binary_accuracy']), label='Training') ax2.plot(100*np.array(f...
No
5
35
Visualization
learning_history
2,108,474
1
A
0
0
0
0
0
9
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
7
A
7,655
# Import the necessary libraries import numpy as np import pandas as pd import os import time import warnings import gc from six.moves import urllib import matplotlib import matplotlib.pyplot as plt warnings.filterwarnings('ignore')
No
5
23
Environment
set_options
2,122,158
1
A
0
0
0
0
0
10
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"]
33
A
7,656
#Add All the Models Libraries # Scalers from sklearn.preprocessing import StandardScaler from sklearn.utils import shuffle from sklearn.pipeline import Pipeline from sklearn.pipeline import FeatureUnion from sklearn.preprocessing import LabelEncoder # Models from sklearn.linear_model import LogisticRegression #logist...
No
5
22
Environment
import_modules
2,122,158
1
A
0
0
0
0
0
34
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"]
33
A
7,657
# to make this notebook's output stable across runs np.random.seed(123) # To plot pretty figures %matplotlib inline plt.rcParams['axes.labelsize'] = 14 plt.rcParams['xtick.labelsize'] = 12 plt.rcParams['ytick.labelsize'] = 12
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,658
train = pd.read_csv("../input/train_users_2.csv")<br>test = pd.read_csv("../input/test_users.csv")<br>id_test = test[\'id\']<br>labels = train[\'country_destination\'].values<br>df_train = train.drop([\'country_destination\'], axis=1)<br>train_flag = df_train.shape[0]
Yes
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
7,659
#We now concat Training and Test set df_total = pd.concat((df_train, test),axis=0, ignore_index = True)
No
5
11
Data_Transform
concatenate
2,122,158
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"]
33
A
7,660
df_total = df_total.drop(['id','date_first_booking'], axis=1)
No
5
10
Data_Transform
drop_column
2,122,158
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"]
33
A
7,661
#Date Account created - Capture Date, month and year seperately. date_ac = np.vstack(df_total.date_account_created.astype(str).apply(lambda x:list(map(int,x.split('-')))).values) df_total['Day'] = date_ac[:,0] df_total['Month']= date_ac[:,1] df_total['year'] = date_ac[:,2] df_total = df_total.drop(['date_account_crea...
Yes
3
11
Data_Transform
concatenate
2,122,158
1
A
0
0
0
0
0
5
ok
3
3
[{"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 36"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column ...
A
no applicable ML-specific findings
[]
["Column Selection Checker", "DataFrame Conversion Checker", "Dependent Threshold Checker"]
33
A
7,662
#Time Stamp first active time_stp = np.vstack(df_total.timestamp_first_active.astype(str) .apply(lambda x: list(map(int,[x[:4],x[4:6],x[6:8],x[8:]]))).values) df_total['tfa_day'] = time_stp[:,0] df_total['tfa_Month'] = time_stp[:,1] df_total['tfa_year'] = time_stp[:,2] df_total = df_total.drop([...
Yes
3
11
Data_Transform
concatenate
2,122,158
1
A
0
0
0
0
0
6
ok
3
3
[{"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 36"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column ...
A
no applicable ML-specific findings
[]
["Column Selection Checker", "DataFrame Conversion Checker", "Dependent Threshold Checker"]
33
A
7,663
forest_class = RandomForestClassifier(random_state = 42) n_estimators = [100, 500] min_samples_split = [10, 20] param_grid_forest = {'n_estimators' : n_estimators, 'min_samples_split' : min_samples_split} rand_search_forest = GridSearchCV(forest_class, param_grid_forest, cv = 4, refit = True, ...
Yes
3
6
Hyperparam_Tuning
train_on_grid
2,122,158
1
A
0
0
0
0
0
7
ok
6
4
[{"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 34"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": ...
A
no applicable ML-specific findings
[]
["Dependent Threshold Checker", "Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
33
A
7,664
df = pd.read_csv('../input/train.csv', parse_dates=[0])
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,665
test = pd.read_csv('../input/test.csv', parse_dates=[0])
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,666
df.rename(columns={'count': 'rentals'}, inplace=True)
No
5
61
Data_Transform
rename_columns
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,667
df['rentals'] = np.log(df['rentals'])
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,668
import math
No
5
22
Environment
import_modules
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,669
pd.concat([df, test])
No
5
11
Data_Transform
concatenate
2,146,505
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
6
A
7,670
df = pd.concat([df, test])
No
5
11
Data_Transform
concatenate
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,671
df['year'] = df.datetime.dt.year df['hour'] = df.datetime.dt.hour df['dayofweek'] = df.datetime.dt.dayofweek
No
5
8
Data_Transform
feature_engineering
null
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,672
train, valid = train_test_split(df, random_state=42)
No
5
13
Data_Transform
split
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,673
removed_cols = ['rentals', 'casual', 'registered', 'datetime']
No
5
77
Other
define_variables
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,674
feats = [c for c in df.columns if c not in removed_cols]
No
5
77
Other
define_variables
null
1
A
0
1
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,675
from sklearn.tree import DecisionTreeRegressor
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,676
dt = DecisionTreeRegressor(random_state=42, max_depth=2)
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,677
dt.fit(train[feats], train['rentals'])
No
5
7
Model_Train
train_model
1,788,208
1
A
0
0
0
0
0
1
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
[{"type": "Cross Validation Checker", "severity": "low"}]
["Column Selection Checker", "Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
7
B
7,678
from fastai.structured import draw_tree
No
5
22
Environment
import_modules
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
7,679
from sklearn.metrics import mean_squared_error
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,680
mean_squared_error(train['rentals'], train['preds'])
No
5
28
Model_Train
compute_train_metric
2,146,505
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