id
int64
0
7.95k
code_block
stringlengths
1
52.9k
too_long
stringclasses
2 values
marks
int64
1
5
graph_vertex_id
float64
1
88
graph_vertex_class
stringclasses
12 values
graph_vertex_subclass
stringclasses
70 values
kernel_id
float64
25.8k
14.7M
⌀
sqale_rating
float64
1
4
maintainability_rating
stringclasses
4 values
code_smells
int64
0
36
complexity
float64
0
15
⌀
cognitive_complexity
int64
0
33
bugs
int64
0
7
sqale_index
int64
0
125
ncloc
float64
0
101
⌀
mlscent_analysis_status
stringclasses
3 values
mlscent_smell_count
int64
0
31
mlscent_unique_smell_count
int64
0
12
mlscent_findings_json
stringlengths
2
7.76k
mlscent_ml_rating
stringclasses
5 values
mlscent_ml_rating_basis
stringclasses
52 values
mlscent_ml_findings_json
stringclasses
50 values
mlscent_ignored_findings_json
stringclasses
199 values
context_line_count
int64
0
33
combined_rating
stringclasses
5 values
2,259
sum(train_data['Sales'] < 0 )
No
5
72
EDA
count_values
3,237,641
1
A
0
0
0
1
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"]
2
A
2,260
train_data.head(100)
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
2,261
categorical_train = train_data.columns.tolist() print(categorical_train) train_data[categorical_train].corr(method='pearson')
No
3
80
Visualization
heatmap
3,237,641
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"]
2
A
2,262
train_features = train_data.drop(['Open'],axis = 1) categorical_train = train_features.columns.tolist() print(categorical_train) train_data[categorical_train].corr(method='pearson') train_features = train_data.drop(['Sales'],axis = 1) full_features = pd.concat([train_features,test_data],ignore_index= True) print(train_...
No
2
80
Visualization
heatmap
3,237,641
1
A
0
0
0
0
0
8
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"]
2
A
2,263
full_features.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
2,264
full_features.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
2,265
full_features = pd.get_dummies(full_features,columns= ['HolidayBin','Assortment','StoreType'])
No
5
20
Data_Transform
categorify
3,237,641
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
2,266
full_features = full_features.drop('PromoInterval',axis = 1)
No
5
10
Data_Transform
drop_column
3,237,641
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
2,267
train_features = full_features.iloc[:844392,:].values test_data = full_features.iloc[844392:,:].values train_sales = train_data['Sales'].values
No
5
13
Data_Transform
split
3,237,641
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"]
2
A
2,268
print(train_features.shape) print(train_sales.shape) print(test_data.shape)
No
5
58
Debug
show_shape
3,237,641
1
A
0
0
0
0
0
3
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
2,270
xgboost = XGBRegressor(learning_rate=0.009, n_estimators=500, max_depth=10, min_child_weight=0, gamma=0, subsample=0.7, colsample_bytree=0.7, objective='reg:linear', nthrea...
No
5
4
Model_Train
choose_model_class
3,237,641
1
A
0
0
0
0
0
7
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
2,271
xgboost.fit(train_features,train_sales)
No
5
7
Model_Train
train_model
3,237,641
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
2,272
predictions = xgboost.predict(test_data)
No
5
48
Model_Evaluation
predict_on_test
3,237,641
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
2,274
pred_df = pd.DataFrame({"Id": test_copy["Id"], 'Sales': predictions}) pred_df.to_csv("xgboost_4_submission.csv", index=False)'
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
2,275
import os import string import numpy as np import pandas as pd from pandasql import sqldf import matplotlib.pyplot as plt from keras.utils.np_utils import to_categorical from keras.models import Model, Sequential, model_from_json from keras.optimizers import SGD, Adam, RMSprop from keras.layers import Input, Dense, D...
No
5
23
Environment
set_options
null
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
0
null
2,276
b"def concat_data():\n df_train = pd.read_csv('../input/train.csv')\n df_test = pd.read_csv('../input/test.csv')\n df_extra = pd.read_csv('../input/store.csv')\n df_test['Sales'] = -1\n df_full = pd.concat([df_train, df_test]).reset_index(drop=True)\n\n #Merge extra information about stores\n df_fu...
Yes
2
45
Data_Extraction
load_from_csv
null
1
A
0
0
0
0
0
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,277
def extrat_test_data(df_full): df_train = df_full.loc[df_full['Sales'] != -1] df_test = df_full.loc[df_full['Sales'] == -1] return df_train, df_test df_train, df_test = extrat_test_data(df_full)
No
4
13
Data_Transform
split
3,674,829
1
A
0
1
0
0
0
5
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,278
df_full.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
2,279
# Function to calculate missing values by column (By DSA) def missing_values_table(df): # Total missing values mis_val = df.isnull().sum() # Percentage of missing values mis_val_percent = 100 * df.isnull().sum() / len(df) # Make a table with the results mis_val_table = pd.concat([mis_val, mis_...
No
4
39
EDA
count_missing_values
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,281
df_train_store.dtypes
No
5
70
Debug
show_data_types
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,282
df_full.groupby('StoreType')['Sales'].describe()
No
5
40
Debug
show_table_attributes
3,674,829
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,283
df_full.groupby('StoreType')['Customers', 'Sales'].sum()
No
5
60
Data_Transform
groupby
3,674,829
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,284
# Plotting correlations num_feat=df_full.columns[df_full.dtypes!=object] num_feat=num_feat[1:-1] labels = [] values = [] for col in num_feat: labels.append(col) values.append(np.corrcoef(df_full[col].values, df_full['Sales'].values)[0,1]) ind = np.arange(len(labels)) width = 0.9 fig, ax = plt.subplots(fig...
No
3
80
Visualization
heatmap
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,285
# Heatmap of correlations features corrMatrix=df_full[["Sales", "DayOfWeek", "Open", "Promo", "SchoolHoliday", "CompetitionDistance", "CompetitionOpenSinceMonth", "CompetitionOpenSinceYear", "Promo2", "Promo2SinceWeek", "Promo2SinceYear", "Year", "Month", "Day", ...
No
4
80
Visualization
heatmap
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,286
def clean_data(use_text_columns = True): ''' Function that clean data and create a new features to enrich the model ''' cols_num = ["Sales", "DayOfWeek", "Open", "Promo", "SchoolHoliday", "CompetitionDistance", "CompetitionOpenSinceMonth", "CompetitionOpenSinceYear", "Promo2", ...
Yes
3
43
Data_Extraction
load_from_sql
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,287
def load_train_data(scaler_x, scaler_y): ''' Transform train data set and separate a test dataset to validate the model in the end of training and normalize data ''' X_train = train.drop(["Sales"], axis=1) # Features y_train = np.array(train["Sales"]).reshape((len(X_train), 1)) # Targets X_train...
No
3
13
Data_Transform
split
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,288
def load_test_data(): ''' Remove column of predictions and normalize data of submission test data set. ''' X_test = test.drop(["Sales"], axis=1) # Features X_test = StandardScaler().fit_transform(X_test) return X_test'
No
4
20
Data_Transform
categorify
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,289
b"# Show info of model\ndef show_info(model, X, y, log, weights = None):\n '''\n Show metrics about the evaluation model and plots about loss, rmse and rmspe\n '''\n if (log != None):\n # summarize history for loss\n plt.figure(figsize=(14,10))\n plt.plot(log.history['loss'])\n p...
Yes
3
28
Model_Train
compute_train_metric
null
1
A
0
0
0
0
0
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,290
def rmspe_val(y_true, y_pred): ''' RMSPE calculus to validate evaluation metric about the model ''' return np.sqrt(np.mean(np.square((y_true - y_pred) / y_true), axis=0))[0]
No
5
84
Other
not_enough_vertices
3,674,829
1
A
0
1
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,291
def rmspe(y_true, y_pred): ''' RMSPE calculus to use during training phase ''' return K.sqrt(K.mean(K.square((y_true - y_pred) / y_true), axis=-1))
No
5
84
Other
not_enough_vertices
3,674,829
1
A
0
1
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,292
def rmse(y_true, y_pred): ''' RMSE calculus to use during training phase ''' return K.sqrt(K.mean(K.square(y_pred - y_true)))
No
5
84
Other
not_enough_vertices
3,674,829
1
A
0
1
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,293
def create_model(): ''' Create a neural network ''' initializer = RandomNormal(mean=0.0, stddev=0.05, seed=None) model = Sequential() model.add(Dense(512, input_dim=X_train.shape[1], activation="relu", kernel_initializer=initializer)) model.add(Dropout(0.4)) model.add(Dense(512, input_d...
No
3
4
Model_Train
choose_model_class
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,294
train, test = clean_data(use_text_columns = True)
No
3
13
Data_Transform
split
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,295
# Hyperparameters and load data to train the model batch_size = 512 nb_epoch = 300 scaler_x = StandardScaler() scaler_y = StandardScaler() print('Loading data...') (X_train, y_train), (X_test, y_test) = load_train_data(scaler_x, scaler_y) print('Build model...') model = create_model() model.summary()
Yes
3
4
Model_Train
choose_model_class
3,674,829
1
A
0
0
0
0
0
9
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,296
print('Fit model...') filepath="weights_rossmann.best.hdf5" checkpoint = ModelCheckpoint(filepath, monitor='val_loss', verbose=1, save_best_only=True, mode='min') early_stopping = EarlyStopping(monitor='val_loss', patience=10, verbose=1, mode='min') callbacks_list = [checkpoint, early_stopping] log = model.fit(X_train...
No
4
7
Model_Train
train_model
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,297
show_info(model, X_test, y_test, log, weights='weights_rossmann.best.hdf5')
No
4
35
Visualization
learning_history
3,674,829
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,298
test_data = load_test_data() df_teste = pd.read_csv('../input/test.csv')
No
5
45
Data_Extraction
load_from_csv
3,674,829
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,299
predict = model.predict(test_data) predict = scaler_y.inverse_transform(predict)
No
4
48
Model_Evaluation
predict_on_test
3,674,829
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,300
submission = pd.DataFrame() submission['Id'] = df_teste["Id"] submission['Sales'] = predict submission.to_csv('submission.csv', index=False)'
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
2,301
df_correlation=df_train_store[['Store', 'DayOfWeek', 'Sales', 'Customers', 'Open', 'Promo', 'SchoolHoliday', 'CompetitionDistance', 'CompetitionOpenSinceMonth', 'CompetitionOpenSinceYear', 'Promo2', 'Promo2SinceWeek', 'Promo2SinceYear', 'SalesperCustomer', 'Month', 'Year', 'Day', 'St...
No
5
77
Other
define_variables
null
1
A
0
0
0
0
0
7
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,302
df_correlation=df_correlation.drop('Open', axis = 1)
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
2,303
upper_triangle = np.zeros_like(df_correlation.corr(), dtype = np.bool) upper_triangle[np.triu_indices_from(upper_triangle)] = True #make sure we don't show half of the other triangle f, ax = plt.subplots(figsize = (15, 10)) sns.heatmap(df_correlation.corr(),ax=ax,mask=upper_triangle,annot=True, fmt='.2f',linewidths=0.5...
No
3
80
Visualization
heatmap
null
1
A
0
0
0
0
0
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,304
df_train_store.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
2,305
df_train_store['CompetitionOpenSince'] = np.where((df_train_store['CompetitionOpenSinceMonth']==0) & (df_train_store['CompetitionOpenSinceYear']==0) , 0,(df_train_store.Month - df_train_store.CompetitionOpenSinceMonth) + (12 * (df_train_store.Year - df_train_store.CompetitionOpen...
No
4
8
Data_Transform
feature_engineering
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,306
#now that CompetitionOpenSince is created #we can get rid of `CompetitionOpenSinceYear` and `CompeitionOpenSinceMonth` del df_train_store['CompetitionOpenSinceYear'] del df_train_store['CompetitionOpenSinceMonth']
No
5
10
Data_Transform
drop_column
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,307
df_train_store["is_holiday_state"] = df_train_store['StateHoliday'].map({"0": 0, "a": 1, "b": 1, "c": 1})'
No
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
2,308
del df_train_store['StateHoliday_cat']
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
2,309
df_train_store=pd.get_dummies(df_train_store, columns=["Assortment", "StoreType","PromoInterval"], prefix=["is_Assortment", "is_StoreType","is_PromoInteval"])
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
2,310
del df_train_store['Assortment_cat'] del df_train_store['StoreType_cat']
No
5
10
Data_Transform
drop_column
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,311
del df_train_store['PromoInterval_cat']
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
2,312
df_test = pd.read_csv("../input/test.csv",sep=',', parse_dates=['Date'] , date_parser=str_to_date, low_memory = False) print ("The Test dataset has {} Rows and {} Variables".format(str(df_test.shape[0]),str(df_test.shape[1])))'
No
3
45
Data_Extraction
load_from_csv
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,313
df_test.fillna(1, inplace = True) #11rows with Nans decided to leave them open since its one store 622 which is #usually open #Left-join the train to the store dataset since .Why? #Because you want to make sure you have all events even if some of them don't have their store information ( which shouldn't happen) df_tes...
Yes
3
16
Data_Transform
data_type_conversions
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,314
del df_test_store["Date"] del df_test_store['CompetitionOpenSinceYear'] del df_test_store['CompetitionOpenSinceMonth'] '
No
5
10
Data_Transform
drop_column
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,315
del df_test_store['StateHoliday_cat']
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
2,316
del df_test_store['Assortment_cat'] del df_test_store['StoreType_cat'] del df_test_store['PromoInterval_cat']
No
5
10
Data_Transform
drop_column
null
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,317
del df_test_store['StateHoliday']
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
2,318
del df_train_store['StateHoliday']
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
2,319
def rmspe(y, yhat): rmspe = np.sqrt(np.mean( (y - yhat)**2 )) return rmspe
No
4
49
Model_Evaluation
compute_test_metric
null
1
A
0
1
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,320
features = df_train_store.drop(['Customers', 'Sales', 'SalesperCustomer'], axis = 1) #a rule of thumb is to transform my target value to log if i see the values are very dispersed which is the case #and then of course revert them with np.exp to their real values targets=np.log(df_train_store.Sales)
Yes
3
10
Data_Transform
drop_column
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,321
X_train, X_train_test, y_train, y_train_test = model_selection.train_test_split(features, targets, test_size=0.20, random_state=15) print ("Training and testing split was successful.")
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
2,322
rfr = RandomForestRegressor(n_estimators=10, criterion='mse', max_depth=5, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, ...
No
3
7
Model_Train
train_model
null
1
A
0
0
0
0
0
17
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,323
''' params = {'max_depth':(4,6,8,10,12,14,16,20), 'n_estimators':(4,8,16,24,48,72,96,128), 'min_samples_split':(2,4,6,8,10)} #scoring_fnc = metrics.make_scorer(rmspe) #the dimensionality is high, the number of combinations we have to search is enormous, using RandomizedSearchCV # is a better option ...
No
3
6
Hyperparam_Tuning
train_on_grid
null
1
A
1
0
0
0
5
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,325
#with the optimal parameters i got let's see how it behaves with the validation set rfr_val=RandomForestRegressor(n_estimators=128, criterion='mse', max_depth=20, min_samples_split=10, min_samples_lea...
No
3
7
Model_Train
train_model
null
1
A
0
0
0
0
0
17
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,326
yhat=model_RF_test.predict(X_train_test)
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
2,327
plt.hist(yhat)
No
5
33
Visualization
distribution
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,328
error=rmspe(y_train_test,yhat) error
No
5
49
Model_Evaluation
compute_test_metric
null
1
A
0
0
0
1
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,329
importances = rfr_val.feature_importances_ std = np.std([rfr_val.feature_importances_ for tree in rfr_val.estimators_], axis=0) indices = np.argsort(importances) palette1 = itertools.cycle(sns.color_palette()) # Store the feature ranking features_ranked=[] for f in range(X_train.shape[1]): features_ran...
Yes
2
33
Visualization
distribution
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,330
df_test_store1=df_test_store.drop(['Id'],axis=1) kaggle_yhat= model_RF_test.predict(df_test_store1) kaggle_preds= pd.DataFrame({'Id': df_test_store['Id'], 'Sales': np.exp(kaggle_yhat)}) kaggle_preds.to_csv("Stefano_Zakher_RF_Rossman_Kaggle_submission.csv", index = False) '
Yes
3
55
Data_Export
prepare_output
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,331
import os import pandas as pd import numpy as np import scipy import warnings warnings.filterwarnings(action='ignore') # Plotting Library import seaborn as sns import matplotlib.pyplot as plt plt.style.use('Solarize_Light2') # Other Libraries from sklearn.linear_model import LinearRegression from sklearn.metrics i...
No
4
88
Debug
list_files
null
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
0
null
2,332
def ispromomonth(rows): # if not rows[0].isnull(): months = {} months = str(rows['PromoInterval']).split(',') if str(rows['month_str']) in months: return 1 else: return 0 def rmspe(y, yhat): return np.sqrt(np.mean((yhat/y-1) ** 2)) def rmspe_xg(yhat, y): y = np.expm1(y.get_lab...
Yes
1
7
Model_Train
train_model
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,333
ross = Rossmann_()
No
5
77
Other
define_variables
4,029,935
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
16
A
2,334
ross.prepare_sample_data(limit =200 , testing_limit = 40) ross.Linear_Regression()
No
4
7
Model_Train
train_model
4,029,935
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
16
A
2,335
ross.prepare_sample_data(limit =2000 , testing_limit = 400) ross.Mulitple_Linear_Regression()
No
4
7
Model_Train
train_model
4,029,935
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
16
A
2,336
ross.prepare_sample_data(limit =10000 , testing_limit = 4000) ross.Polynomial_Regression(degrees = 3)
No
4
7
Model_Train
train_model
4,029,935
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
16
A
2,337
ross.prepare_sample_data(limit =10000 , testing_limit = 4000) ross.Polynomial_Regression(degrees = 2)
No
4
7
Model_Train
train_model
4,029,935
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
16
A
2,338
ross.prepare_sample_data(limit =1000 , testing_limit = 400) ross.Other_Regression(reg = 'Ridge')
No
4
7
Model_Train
train_model
4,029,935
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
16
A
2,339
ross.prepare_sample_data(limit =1000 , testing_limit = 400) ross.Other_Regression(reg = 'Lasso')
No
4
7
Model_Train
train_model
4,029,935
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
16
A
2,340
ross.prepare_sample_data(limit =1000 , testing_limit = 400) ross.Other_Regression(reg = 'Elastic')
No
4
7
Model_Train
train_model
4,029,935
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
16
A
2,341
ross.prepare_sample_data(limit =1000 , testing_limit = 400) ross.Other_Regression(reg = 'Bridge')
No
4
7
Model_Train
train_model
4,029,935
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
16
A
2,343
# Get list of categorical variables new= data[data.columns[~data.columns.isin(['Open Date','days','year','month'])]] numerical_features = new.select_dtypes([np.number]).columns.tolist() categorical_features = new.select_dtypes(exclude = [np.number,np.datetime64]).columns.tolist() categorical_features
No
4
8
Data_Transform
feature_engineering
5,729,566
1
A
0
0
0
1
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"]
10
A
2,344
from sklearn import preprocessing from sklearn.model_selection import train_test_split
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
2,345
#data = data.drop('Id', axis=1) #test_data = test_data.drop('Id', axis=1) y= data.revenue x_train = data[data.columns[~data.columns.isin(['Open Date','revenue'])]] #train features to be fit in model x_test = test_data[test_data.columns[~test_data.columns.isin(['Open Date'])]] #test features
No
5
21
Data_Transform
prepare_x_and_y
5,729,566
2
B
1
0
0
0
5
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"]
10
B
2,346
from sklearn.preprocessing import LabelEncoder # Processing the categorical columns to provide vector form of feature class DataFrameProcess: def __init__(self,df,col): self.df =df self.col=col def dataEncoding(self): if self.df[self.col].dtype.name == 'object' or self.df[self.col].dtype...
Yes
4
8
Data_Transform
feature_engineering
null
1
A
1
6
3
0
5
15
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", "Missing class docstring", "Unit Testing Checker", "Verbose Mode Checker"]
0
D
2,347
x_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
2,349
from xgboost import XGBRegressor from sklearn.ensemble import GradientBoostingRegressor gbRegr = GradientBoostingRegressor(max_depth=3, random_state=42) gbRegr.fit(x_train, y) prediction_rr = gbRegr.predict(x_test)
Yes
4
7
Model_Train
train_model
5,729,566
1
A
1
0
0
0
5
5
ok
8
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...
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", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"]
10
B
2,350
test_label=pd.read_csv('../input/restaurant-revenue-prediction/sampleSubmission.csv') # test target test_label.head(10)
No
4
45
Data_Extraction
load_from_csv
5,729,566
1
A
0
0
0
0
0
2
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/restaurant-revenue-prediction/sampleSubmission.csv. 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"]
10
A
2,351
from sklearn.metrics import mean_squared_error from math import sqrt label_list=test_label['Prediction'].tolist()
Yes
5
16
Data_Transform
data_type_conversions
5,729,566
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"]
10
A
2,352
print('Root Mean squared error {}'.format(sqrt(mean_squared_error(label_list, prediction_rr))))
No
5
49
Model_Evaluation
compute_test_metric
5,729,566
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
10
A
2,353
from sklearn import ensemble params = {'n_estimators': 100, 'max_depth': 4, 'min_samples_split': 2, 'learning_rate': 0.05, 'loss': 'ls'} GBR = ensemble.GradientBoostingRegressor(**params) GBR.fit(x_train, y) preds_GBR = GBR.predict(x_test) GradientBoostingRegressor_RMSE= sqrt(mean_squared_error(label_list,...
Yes
3
48
Model_Evaluation
predict_on_test
5,729,566
1
A
0
0
0
0
0
8
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"]
10
B
2,354
parameters = [{'n_estimators': [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], 'learning_rate': [0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0] }] from sklearn.model_sele...
Yes
4
7
Model_Train
train_model
5,729,566
1
A
0
0
0
0
0
11
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 16"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": ...
A
no applicable ML-specific findings
[]
["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
10
A
2,355
final_model = XGBRegressor(n_estimators=gsearch.best_params_.get('n_estimators'), learning_rate=gsearch.best_params_.get('learning_rate'), n_jobs=4)
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
2,356
final_model.fit(x_train, y)
No
5
7
Model_Train
train_model
5,729,566
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"]
10
B
2,357
preds_test = final_model.predict(x_test)
No
5
48
Model_Evaluation
predict_on_test
5,729,566
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"]
10
A
2,358
from sklearn.ensemble import RandomForestRegressor from sklearn.metrics import mean_squared_error from math import sqrt rf_model = RandomForestRegressor(random_state=1) rf_model.fit(x_train, y) rf_val_predictions = rf_model.predict(x_test) RMSE = sqrt(mean_squared_error(label_list,rf_val_predictions)) print(RMSE)
Yes
4
7
Model_Train
train_model
5,729,566
1
A
1
0
0
0
5
8
ok
9
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
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not 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"]
10
B
2,359
submission = pd.DataFrame({ "Id": test_data["Id"], "Prediction": rf_val_predictions }) submission.to_csv('submission.csv',header=True, index=False) print('done')'
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
2,360
b"month2str = {1:'Jan', 2:'Feb', 3:'Mar', 4:'Apr', 5:'May', 6:'Jun', \\\n 7:'Jul', 8:'Aug', 9:'Sept', 10:'Oct', 11:'Nov', 12:'Dec'}\nall_data['month_str'] = all_data.Month.map(month2str)\n\ndef check(row):\n if isinstance(row['PromoInterval'],str) and row['month_str'] in row['PromoInterval']:\n return...
No
5
20
Data_Transform
categorify
null
1
A
0
0
0
0
0
0
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
2,361
tmp = all_data[all_data['part']=='train'] sns.boxplot('IsPromoMonth', 'Sales', data=tmp)
No
5
33
Visualization
distribution
2,095,107
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"]
6
A
2,362
all_data ['isBeforeCompetition'] = all_data.apply(lambda x: 1 if x['Year'] < x['CompetitionOpenSinceYear'] else 0, 1)
No
5
14
Data_Transform
filter
2,095,107
1
A
0
1
1
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
2,363
tmp = all_data[all_data['part']=='train'] sns.boxplot('isBeforeCompetition', 'Sales', data=tmp)
No
5
33
Visualization
distribution
2,095,107
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"]
6
A
2,364
fig, ax = plt.subplots(5, 1, figsize=(15,10)) for p in range (5): i = np.random.choice(data['Store'].unique()) data[data['Store']== i ].plot('Date', 'Sales', ax=ax[p]) ax[p] .set_title("Store %d" %i) plt.tight_layout() plt.show()'
No
5
75
Visualization
time_series
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null