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
508
data = pd.read_csv('/kaggle/input/restaurant-revenue-prediction/train.csv.zip') data.head()
No
4
45
Data_Extraction
load_from_csv
9,655,329
1
A
0
0
0
0
0
2
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: /kaggle/input/restaurant-revenue-prediction/train.csv.zip. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 2"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
1
A
509
data.isnull().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
510
y_train = data.pop('revenue')
No
5
10
Data_Transform
drop_column
9,655,329
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
1
A
511
data = data.drop(data.columns[[0, 1,2,3,4]], axis=1) x_train=data[:] data.head()
No
4
10
Data_Transform
drop_column
9,655,329
1
A
0
0
0
0
0
3
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
1
A
512
from sklearn.ensemble import GradientBoostingRegressor model = GradientBoostingRegressor() model.fit(x_train, y_train)
No
5
7
Model_Train
train_model
9,655,329
3
C
2
0
0
0
10
3
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"]
1
C
513
from sklearn.ensemble import GradientBoostingRegressor learning_rates = [1, 0.5, 0.25, 0.1, 0.05, 0.01] #learing_rates=[] train_results = [] test_results = [] #beta=range(.05,1.05,.05) for eta in learning_rates: #learning_rates.append(eta) model = GradientBoostingRegressor(learning_rate=eta) model.fit(x_train,...
No
5
2
Hyperparam_Tuning
find_best_params
9,655,329
1
A
3
1
1
0
15
12
ok
10
8
[{"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.", "Only MSE detected for regression. Consider adding R2 score or MAE for a more comprehensive evaluation.", "Unit Testing Checker", "Verbose Mode Checker"]
1
B
514
from matplotlib.legend_handler import HandlerLine2D line1, = plt.plot(learning_rates, train_results, 'b', label="Training MSE") plt.legend(handler_map={line1: HandlerLine2D(numpoints=2)}) plt.ylabel('Mean Squared Error') plt.xlabel('Learning Rate') plt.show()'
No
5
35
Visualization
learning_history
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
515
from sklearn.ensemble import GradientBoostingRegressor n_estimators = [ 1, 2, 4, 8, 16, 32, 64, 100, 200, 500, 1000, 2000] train_results = [] test_results = [] for estimator in n_estimators: model = GradientBoostingRegressor(n_estimators=estimator) model.fit(x_train, y_train) from sklearn.metrics import mean_s...
No
5
2
Hyperparam_Tuning
find_best_params
9,655,329
1
A
2
1
1
0
10
12
ok
10
8
[{"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.", "Only MSE detected for regression. Consider adding R2 score or MAE for a more comprehensive evaluation.", "Unit Testing Checker", "Verbose Mode Checker"]
1
B
516
from matplotlib.legend_handler import HandlerLine2D line1, = plt.plot(n_estimators, train_results, 'b', label="Training MSE") plt.legend(handler_map={line1: HandlerLine2D(numpoints=2)}) plt.ylabel('Mean Squared Error') plt.xlabel('Number of Estimators') plt.show()'
No
5
35
Visualization
learning_history
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
517
from sklearn.ensemble import GradientBoostingRegressor #min_samples_splits = np.linspace(0.1, 1.0, 10, endpoint=True) min_samples_splits=[2,3,4,5,6,7,8,9,10] train_results = [] test_results = [] for min_samples_split in min_samples_splits: model = GradientBoostingRegressor(min_samples_split=min_samples_split) mod...
No
5
2
Hyperparam_Tuning
find_best_params
9,655,329
1
A
3
1
1
0
15
12
ok
10
8
[{"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.", "Only MSE detected for regression. Consider adding R2 score or MAE for a more comprehensive evaluation.", "Unit Testing Checker", "Verbose Mode Checker"]
1
B
518
from matplotlib.legend_handler import HandlerLine2D line1, = plt.plot(min_samples_splits, train_results, 'b', label="Training MSE") plt.legend(handler_map={line1: HandlerLine2D(numpoints=2)}) plt.ylabel('Mean Squared Error') plt.xlabel('Min Samples Split') plt.show()'
No
5
84
Other
not_enough_vertices
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
519
from sklearn.ensemble import GradientBoostingRegressor max_depths = [1,2,3,4,5,6,7,8,9,10] train_results = [] test_results = [] for max_depth in max_depths: model = GradientBoostingRegressor(max_depth=max_depth) model.fit(x_train, y_train) from sklearn.metrics import mean_squared_error, r2_score model_score...
No
5
2
Hyperparam_Tuning
find_best_params
9,655,329
1
A
2
1
1
0
10
12
ok
10
8
[{"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.", "Only MSE detected for regression. Consider adding R2 score or MAE for a more comprehensive evaluation.", "Unit Testing Checker", "Verbose Mode Checker"]
1
B
520
from matplotlib.legend_handler import HandlerLine2D line1, = plt.plot(max_depths, train_results, 'b', label="Training MSE") plt.legend(handler_map={line1: HandlerLine2D(numpoints=2)}) plt.ylabel('Mean Squared Error') plt.xlabel('No. of Depth') plt.show()'
No
5
35
Visualization
learning_history
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
521
from sklearn.ensemble import GradientBoostingRegressor #min_samples_leafs = np.linspace(0.1, 0.5, 5, endpoint=True) min_samples_leafs = [1,2,3,4,5,6,7,8,9,10] train_results = [] test_results = [] for min_samples_leaf in min_samples_leafs: model = GradientBoostingRegressor(min_samples_leaf=min_samples_leaf) model....
No
5
2
Hyperparam_Tuning
find_best_params
9,655,329
1
A
3
1
1
0
15
12
ok
10
8
[{"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.", "Only MSE detected for regression. Consider adding R2 score or MAE for a more comprehensive evaluation.", "Unit Testing Checker", "Verbose Mode Checker"]
1
B
522
from matplotlib.legend_handler import HandlerLine2D line1, = plt.plot(min_samples_leafs, train_results, 'b', label="Training MSE") plt.legend(handler_map={line1: HandlerLine2D(numpoints=2)}) plt.ylabel('Mean Squared Error') plt.xlabel('No. of Samples Leaf') plt.show()'
No
5
35
Visualization
learning_history
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
523
from sklearn.ensemble import GradientBoostingRegressor max_features = list(range(1,data.shape[1])) train_results = [] test_results = [] for max_feature in max_features: model = GradientBoostingRegressor(max_features=max_feature) model.fit(x_train, y_train) from sklearn.metrics import mean_squared_error, r2_sco...
No
5
2
Hyperparam_Tuning
find_best_params
9,655,329
1
A
2
1
1
0
10
12
ok
10
8
[{"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.", "Only MSE detected for regression. Consider adding R2 score or MAE for a more comprehensive evaluation.", "Unit Testing Checker", "Verbose Mode Checker"]
1
B
524
from matplotlib.legend_handler import HandlerLine2D line1, = plt.plot(max_features, train_results, 'b', label="Training MSE") plt.legend(handler_map={line1: HandlerLine2D(numpoints=2)}) plt.ylabel('Mean Squared Error') plt.xlabel('No. of Feature') plt.show()'
No
5
35
Visualization
learning_history
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
525
data1 = pd.read_csv('/kaggle/input/restaurant-revenue-prediction/test.csv.zip') data1.head()
No
4
45
Data_Extraction
load_from_csv
9,655,329
1
A
0
0
0
0
0
2
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: /kaggle/input/restaurant-revenue-prediction/test.csv.zip. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 2"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
1
A
526
data1=data1.drop(data1.columns[[0, 1,2,3,4]], axis=1)
No
5
10
Data_Transform
drop_column
9,655,329
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
1
A
527
data1.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
528
sample =pd.read_csv('/kaggle/input/restaurant-revenue-prediction/sampleSubmission.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
529
params = {'n_estimators': 225, 'max_depth': 4, 'min_samples_split': 2, 'learning_rate': 0.25, 'loss': 'ls','max_features':10, 'min_samples_leaf':2} model = ensemble.GradientBoostingRegressor(**params) model.fit(x_train, y_train) sample["Prediction"] = model.predict(data1)'
No
3
4
Model_Train
choose_model_class
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
530
sample.to_csv('submission.csv', index = False)
No
5
25
Data_Export
save_to_csv
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
531
# This Python 3 environment comes with many helpful analytics libraries installed # It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python # For example, here's several helpful packages to load import numpy as np # linear algebra import pandas as pd # data processing, CSV file I/O (e....
No
5
88
Debug
list_files
null
1
A
0
2
3
0
0
6
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: /kaggle/input. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 12"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
0
A
532
import pandas as pd import numpy as np
No
5
22
Environment
import_modules
10,424,951
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
8
A
533
import pandas as pd df_train = pd.read_csv('../input/restaurant-revenue-prediction/train.csv.zip') df_test = pd.read_csv('../input/restaurant-revenue-prediction/test.csv.zip')
No
4
45
Data_Extraction
load_from_csv
10,522,332
1
A
0
0
0
0
0
3
ok
3
2
[{"detector": "general_ml", "framework": "General ML", "name": "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "fix": "Not specified", "benefits": "Not specified", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name": "Har...
A
no applicable ML-specific findings
[]
["Hardcoded file path", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness."]
4
A
534
train_corr = df_train.corr() print(train_corr) train_corr.to_csv("corr.csv", index = False)
No
4
25
Data_Export
save_to_csv
10,522,332
1
A
0
0
0
0
0
3
ok
3
3
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name...
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"}]
[]
4
B
535
import datetime from sklearn.preprocessing import LabelEncoder revenue = df_train["revenue"]
No
4
22
Environment
import_modules
10,522,332
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"]
4
A
536
del df_train["revenue"]
No
5
10
Data_Transform
drop_column
10,522,332
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"]
4
A
537
df_whole = pd.concat([df_train, df_test], axis=0)
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
538
df_whole["Open Date"] = pd.to_datetime(df_whole["Open Date"]) df_whole["Year"] = df_whole["Open Date"].apply(lambda x:x.year) df_whole["Month"] = df_whole["Open Date"].apply(lambda x:x.month) df_whole["Day"] = df_whole["Open Date"].apply(lambda x:x.day)
No
4
8
Data_Transform
feature_engineering
10,522,332
2
B
1
0
0
0
10
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"]
4
B
539
le = LabelEncoder() df_whole["City"] = le.fit_transform(df_whole["City"])
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
540
df_whole["City Group"] = df_whole["City Group"].map({"Other":0, "Big Cities":1})
No
5
20
Data_Transform
categorify
10,522,332
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"]
4
A
541
df_whole["Type"] = df_whole["Type"].map({"FC":0, "IL":1, "DT":2, "MB":3})
No
5
20
Data_Transform
categorify
10,522,332
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"]
4
A
542
df_train = df_whole.iloc[:df_train.shape[0]] df_test = df_whole.iloc[df_train.shape[0]:]
No
5
13
Data_Transform
split
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
543
from sklearn.ensemble import RandomForestRegressor # df_train_columns = [col for col in df_train.columns if col not in ["Id", "Open Date"]] #RandomForest rf = RandomForestRegressor( n_estimators=200, max_depth=5, max_features=0.5, random_state=449, n_jobs=-1 ) rf.fit(df_train[df_train_columns],...
No
2
7
Model_Train
train_model
null
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
0
null
544
prediction = rf.predict(df_test[df_train_columns])
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
545
submission = pd.DataFrame({"Id":df_test.Id, "Prediction":prediction}) submission.to_csv("TFI_submission.csv", index=False)
No
4
25
Data_Export
save_to_csv
10,522,332
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
4
A
546
df = pd.read_csv('../input/restaurant-revenue-prediction/train.csv.zip', index_col='Id') df
No
5
45
Data_Extraction
load_from_csv
10,702,707
1
A
0
0
0
1
0
3
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/restaurant-revenue-prediction/train.csv.zip. 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
547
y = df.revenue X = df.drop(columns=['revenue'], axis=1)
No
5
21
Data_Transform
prepare_x_and_y
10,702,707
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
5
A
548
y
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
549
X
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
550
for col in X.columns: print(col, df[col].dtype)
No
5
70
Debug
show_data_types
null
1
A
0
1
1
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
551
y.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
552
X_num = X.select_dtypes(exclude=['object']) X_num
No
5
84
Other
not_enough_vertices
null
1
A
0
0
0
1
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
553
df.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
554
X_num.shape
No
5
58
Debug
show_shape
10,702,707
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
5
A
555
for col in X_num.columns: if X_num[col].isna().sum() > 0: print(col, X_num[col].isna().sum() / len(X_num) )
No
5
39
EDA
count_missing_values
null
1
A
0
2
3
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
556
from sklearn.impute import SimpleImputer imputer = SimpleImputer() X_num_imputed = pd.DataFrame(imputer.fit_transform(X_num))
No
4
17
Data_Transform
correct_missing_values
null
1
A
0
0
0
0
0
3
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"]
0
D
557
parameters = { 'n_estimators': list(range(100, 1001, 100)), 'max_leaf_nodes': list(range(2, 70, 5)), 'max_depth': list(range(6, 70, 5)) } parameters
No
5
5
Hyperparam_Tuning
define_search_space
null
1
A
0
0
0
1
0
6
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
558
my_randome_state=1486
No
5
77
Other
define_variables
10,702,707
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Magic number detected: 1486", "fix": "Not specified", "benefits": "Not specified", "location": "Line 6"}]
A
no applicable ML-specific findings
[]
["Magic number"]
5
A
559
from sklearn.model_selection import GridSearchCV from sklearn.ensemble import RandomForestRegressor gsearch = GridSearchCV(estimator=RandomForestRegressor(random_state=my_randome_state), param_grid = parameters, scoring='neg_mean_absolute_error', n_j...
No
4
5
Hyperparam_Tuning
define_search_space
null
1
A
0
0
0
0
0
6
ok
3
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 3"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "...
A
no applicable ML-specific findings
[]
["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
0
A
560
gsearch.fit(X_num_imputed, y)
No
5
6
Hyperparam_Tuning
train_on_grid
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
561
best_n_estimators = gsearch.best_params_.get('n_estimators') best_n_estimators
No
5
2
Hyperparam_Tuning
find_best_params
null
1
A
0
0
0
1
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
562
best_max_leaf_nodes = gsearch.best_params_.get('max_leaf_nodes') best_max_leaf_nodes
No
5
2
Hyperparam_Tuning
find_best_params
null
1
A
0
0
0
1
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
563
best_max_depth = gsearch.best_params_.get('max_depth') best_max_depth
No
5
2
Hyperparam_Tuning
find_best_params
null
1
A
0
0
0
1
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
564
final_model = RandomForestRegressor(n_estimators=best_n_estimators, random_state=my_randome_state, max_leaf_nodes=best_max_leaf_nodes, max_depth=best_max_depth)
No
5
4
Model_Train
choose_model_class
null
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
565
final_model.fit(X_num_imputed, y)
No
5
7
Model_Train
train_model
10,702,707
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
566
X_test = pd.read_csv('../input/restaurant-revenue-prediction/test.csv.zip', index_col='Id') X_test
No
5
45
Data_Extraction
load_from_csv
null
1
A
0
0
0
1
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
567
X_test_num = X_test.select_dtypes(exclude=['object'])
No
5
14
Data_Transform
filter
10,702,707
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
5
A
568
for col in X_test_num.columns: if X_test_num[col].isna().sum() > 0: print(col, X_test_num[col].isna().sum() / len(X_test_num) )
No
5
39
EDA
count_missing_values
null
1
A
0
2
3
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
569
X_test_num_imputed = pd.DataFrame(imputer.transform(X_test_num)) X_test_num_imputed.columns = X_test_num.columns X_test_num_imputed
No
5
61
Data_Transform
rename_columns
null
1
A
0
0
0
1
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
570
preds_test = final_model.predict(X_test_num_imputed)
No
5
48
Model_Evaluation
predict_on_test
10,702,707
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
571
len(preds_test)
No
5
40
Debug
show_table_attributes
10,702,707
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
5
A
572
# Save test predictions to file output = pd.DataFrame({'Id': X_test.index, 'Prediction': preds_test}) output
No
5
55
Data_Export
prepare_output
null
1
A
0
0
0
1
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
573
output.to_csv('submission.csv', index=False) print('done!')
No
5
25
Data_Export
save_to_csv
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
574
data_train = pd.read_csv('../input/restaurant-revenue-prediction/train.csv.zip',index_col='Id', parse_dates=["Open Date"]) data_test = pd.read_csv('../input/restaurant-revenue-prediction/test.csv.zip',index_col='Id', parse_dates=["Open Date"]) data_train'
No
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
575
data_train.describe()
No
5
40
Debug
show_table_attributes
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
576
data_train.isnull().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
577
for i in data_train.columns: print(i ,': ',len(data_train[i].unique()))
No
5
54
EDA
count_unique_values
null
1
A
0
1
1
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
578
columnsForDrop = ['Open Date'] data_train.drop(columns=columnsForDrop, inplace=True) ################################ data_test.drop(columns=columnsForDrop, inplace=True) data_train
No
4
10
Data_Transform
drop_column
null
1
A
0
0
0
1
0
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
579
s = (data_train.dtypes == 'object') object_cols = list(s[s].index) print("Categorical variables:") print(object_cols)'
No
4
37
EDA
count_data_types
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
580
from sklearn.preprocessing import LabelEncoder # Make copy to avoid changing original data label_X_train = data_train.copy() label_X_test = data_test.copy() # Apply label encoder to each column with categorical data label_encoder = LabelEncoder() for col in object_cols: label_encoder.fit(pd.concat([data_train[co...
No
5
20
Data_Transform
categorify
null
1
A
0
1
1
0
0
8
ok
10
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
581
data_train = label_X_train data_test = label_X_test data_train
No
4
41
Debug
show_table
null
1
A
0
0
0
1
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
582
y = data_train.revenue ############################################ X = data_train.drop(columns=['revenue'])
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
583
from sklearn.tree import DecisionTreeClassifier from sklearn.metrics import accuracy_score, classification_report, f1_score from sklearn.neighbors import KNeighborsClassifier
No
5
22
Environment
import_modules
null
1
A
0
0
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"]
0
A
584
from xgboost import XGBRegressor from sklearn.metrics import mean_absolute_error ,explained_variance_score, mean_squared_error #########################################################################3 from sklearn.ensemble import RandomForestRegressor parameters = {'max_depth': list(range(6, 30, 10)), ...
No
4
6
Hyperparam_Tuning
train_on_grid
null
1
A
1
0
0
0
5
15
ok
6
4
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Randomness Control Checker", "fix": "Set random_state in estimators for reproducibility.", "benefits": "Ensures reproducible results and consistent model behaviour.", "location": "Line 15"}, {"detector": "framework_specific", "framework": "ScikitL...
B
Randomness Control Checker=low
[{"type": "Randomness Control Checker", "severity": "low"}]
["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
0
B
585
print(gsearch.best_params_.get('n_estimators')) print(gsearch.best_params_.get('max_leaf_nodes')) print(gsearch.best_params_.get('max_depth'))
No
5
2
Hyperparam_Tuning
find_best_params
null
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
586
print(data_train.shape) print(data_test.shape) print(X.shape)
No
5
58
Debug
show_shape
null
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
587
final_model = RandomForestRegressor( max_depth = gsearch.best_params_.get('max_depth'), max_leaf_nodes = gsearch.best_params_.get('max_leaf_nodes'), n_estimators = gsearch.best_params_.get('n_estimators'),random_state=1, n_jobs=4) final_model.fit(X, y)
No
4
6
Hyperparam_Tuning
train_on_grid
null
1
A
0
0
0
0
0
5
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
588
preds = final_model.predict(data_test) print(preds.shape) print(data_test.shape)
No
4
48
Model_Evaluation
predict_on_test
null
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
589
testData = pd.read_csv("../input/restaurant-revenue-prediction/test.csv.zip") submission = pd.DataFrame({ "Id": testData["Id"], "Prediction": preds }) submission.to_csv('RandomForestSimple.csv',header=True, index=False) print('Done')'
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
590
df_train=pd.read_csv("/kaggle/input/restaurant-revenue-prediction/train.csv.zip",index_col='Id') X_test = pd.read_csv('../input/restaurant-revenue-prediction/test.csv.zip',index_col='Id') df_train.shape,X_test.shape '
No
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
591
train_with_missing = [col for col in df_train.columns if df_train[col].isnull().any()] test_with_missing = [col for col in X_test.columns if X_test[col].isnull().any()] train_with_missing,test_with_missing
No
3
17
Data_Transform
correct_missing_values
11,097,956
1
A
0
2
0
2
0
3
ok
4
4
[{"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"]
4
B
592
y_train = df_train.revenue X_train = df_train.drop(columns=['revenue'], axis=1)
No
5
21
Data_Transform
prepare_x_and_y
11,097,956
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"}]
[]
4
B
593
X_train.shape,X_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
594
b"import matplotlib.pyplot as plt\n\nd_names = ('train.csv.zip', 'test.csv.zip')\ny_pos = range(len(d_names))\n \nplt.bar(\n y_pos, \n (X_train.shape[0], X_test.shape[0]), \n align='center', \n alpha=0.8\n)\nplt.xticks(y_pos, d_names)\nplt.ylabel('Number of rows') \nplt.title(' Wow!')\nplt.show()"
No
4
33
Visualization
distribution
null
1
A
0
0
0
0
0
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
595
bad_label_cols = list(set(X_train.columns)-set(X_test.columns)) bad_label_cols
No
4
37
EDA
count_data_types
11,097,956
1
A
0
0
0
1
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
4
A
596
X_train['City'].value_counts()
No
5
72
EDA
count_values
11,097,956
1
A
0
0
0
0
0
1
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": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida...
B
Cross Validation Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}]
["Column Selection Checker"]
4
B
597
X_train.Type.value_counts()
No
5
72
EDA
count_values
11,097,956
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}]
B
Cross Validation Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}]
[]
4
B
598
X_train['year'] = pd.DatetimeIndex(X_train['Open Date']).year X_train.drop(columns=['Open Date','City'],inplace=True)
No
4
10
Data_Transform
drop_column
11,097,956
1
A
0
0
0
0
0
2
ok
3
3
[{"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "Assign operations to a new DataFrame variable.", "benefits": "Prevents data loss and improves code clarity.", "location": "Line 6"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker",...
B
Cross Validation Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}]
["Column Selection Checker", "InPlace Checker"]
4
B
599
X_test['year'] = pd.DatetimeIndex(X_test['Open Date']).year X_test.drop(columns=['Open Date','City'],inplace=True)
No
4
10
Data_Transform
drop_column
11,097,956
1
A
0
0
0
0
0
2
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 6"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker",...
A
no applicable ML-specific findings
[]
["Column Selection Checker", "InPlace Checker"]
4
A
600
from sklearn.preprocessing import OneHotEncoder # Apply one-hot encoder to each column with categorical data OH_encoder = OneHotEncoder(handle_unknown='ignore', sparse=False) OH_cols_train = pd.DataFrame(OH_encoder.fit_transform(X_train[object_cols])) OH_cols_test = pd.DataFrame(OH_encoder.transform(X_test[object_cols]...
Yes
3
20
Data_Transform
categorify
11,097,956
1
A
0
0
0
0
0
10
ok
11
10
[{"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": "Pipeline Che...
D
Cross Validation Checker=low, Cross-validation not detected=low, Data Leakage Checker=high, No random seed setting detected=low, Pipeline Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Pipeline Checker", "severity": "low"}]
["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"]
4
D
601
OH_X_train.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
602
OH_X_test.head()
No
5
41
Debug
show_table
11,097,956
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
4
A
603
train_stats=OH_X_train.describe().transpose() train_stats
No
5
40
Debug
show_table_attributes
11,097,956
1
A
0
0
0
1
0
2
ok
3
3
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name...
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"}]
[]
4
B
604
def norm(x): return (x - train_stats['mean']) / train_stats['std'] normed_train_data = norm(OH_X_train) normed_test_data = norm(OH_X_test)
No
5
18
Data_Transform
normalization
11,097,956
1
A
0
1
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"]
4
A
605
normed_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
606
parameters = { 'n_estimators': list(range(10, 300, 20)), 'learning_rate': [l / 100 for l in range(5, 100, 20)], 'max_depth': list(range(1, 20,3)), 'gamma':[2,3], 'eta':[0.8,0.9], 'reg_alpha':[0.5,0.6,0.7,0.8], 'reg_lambda':[0.5,0.6,0.7,0.8] } parameters
No
5
5
Hyperparam_Tuning
define_search_space
11,097,956
1
A
0
0
0
1
0
10
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
4
A
607
my_randome_state=70
No
5
77
Other
define_variables
11,097,956
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Magic number detected: 70", "fix": "Not specified", "benefits": "Not specified", "location": "Line 5"}]
A
no applicable ML-specific findings
[]
["Magic number"]
4
A