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,682 | import pandas as pd
from pandas import DataFrame as df
import numpy as np
store_data=pd.read_csv(path+"store.csv",parse_dates=[3])
train_data=pd.read_csv(path+"train.csv",parse_dates=[2])
test_data=pd.read_csv(path+"test.csv",parse_dates=[3])
print(store_data.keys(),"\
",train_data.keys())
train = pd.merge(train_data... | Yes | 3 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
2,683 | print(train.Store.isnull().sum(),train.DayOfWeek.isnull().sum(),train.Date.isnull().sum(),train.Open.isnull().sum(),\\
train.Promo.isnull().sum(),train.StateHoliday.isnull().sum(),train.SchoolHoliday.isnull().sum(),train.StoreType.isnull().sum(),\\
train.Assortment.isnull().sum(),train.CompetitionDistance.i... | No | 4 | 17 | Data_Transform | correct_missing_values | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,684 | print(test.Store.isnull().sum(),test.DayOfWeek.isnull().sum(),test.Date.isnull().sum(),test.Open.isnull().sum(),\\
test.Promo.isnull().sum(),test.StateHoliday.isnull().sum(),test.SchoolHoliday.isnull().sum(),test.StoreType.isnull().sum(),\\
test.Assortment.isnull().sum(),test.CompetitionDistance.isnull().su... | No | 4 | 17 | Data_Transform | correct_missing_values | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,685 | mappings = {'0':0, 'a':1, 'b':2, 'c':3, 'd':4}
train.StoreType.replace(mappings, inplace=True)
train.Assortment.replace(mappings, inplace=True)
train.StateHoliday.replace(mappings, inplace=True)
test.StoreType.replace(mappings, inplace=True)
test.Assortment.replace(mappings, inplace=True)
test.StateHoliday.replace(map... | No | 5 | 20 | Data_Transform | categorify | 7,004,483 | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | ok | 10 | 5 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", ... | 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"}] | ["Import Checker", "InPlace Checker"] | 5 | B |
2,686 |
train['Year'] = train.Date.dt.year
train['Month'] = train.Date.dt.month
train['Day'] = train.Date.dt.day
train['DayOfWeek'] = train.Date.dt.dayofweek
train['WeekOfYear'] = train.Date.dt.weekofyear
test['Year'] = test.Date.dt.year
test['Month'] = test.Date.dt.month
test['Day'] = test.Date.dt.day
test['DayOfWeek'] = t... | No | 5 | 8 | Data_Transform | feature_engineering | 7,004,483 | 1 | A | 0 | 0 | 0 | 0 | 0 | 10 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Import Checker"] | 5 | A |
2,687 |
train['CompetitionOpen'] = 12 * (train.Year - train.CompetitionOpenSinceYear) + (train.Month - train.CompetitionOpenSinceMonth)
train['PromoOpen'] = 12 * (train.Year - train.Promo2SinceYear) + (train.WeekOfYear - train.Promo2SinceWeek) / 4.0
train['CompetitionOpen'] = train.CompetitionOpen.apply(lambda... | No | 5 | 8 | Data_Transform | feature_engineering | 7,004,483 | 1 | A | 0 | 4 | 4 | 0 | 0 | 8 | ok | 5 | 5 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C... | 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", "Import Checker"] | 5 | B |
2,688 | month2str = {1:'Jan', 2:'Feb', 3:'Mar', 4:'Apr', 5:'May', 6:'Jun', 7:'Jul', 8:'Aug', 9:'Sept', 10:'Oct', 11:'Nov', 12:'Dec'}
train['monthStr'] = train.Month.map(month2str)
train.loc[train.PromoInterval == 0, 'PromoInterval'] = ''
train['IsPromoMonth'] = 0
for interval in train.PromoInterval.unique():
if interval !=... | No | 4 | 20 | Data_Transform | categorify | 7,004,483 | 1 | A | 0 | 6 | 12 | 0 | 0 | 16 | ok | 5 | 5 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C... | 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", "Import Checker"] | 5 | B |
2,689 | train.keys(),test.keys() | No | 5 | 40 | Debug | show_table_attributes | 7,004,483 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validat... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Import Checker"] | 5 | B |
2,690 | train.drop(['Date','Customers','Open','PromoInterval','monthStr'],axis=1,inplace =True)
test.drop(['Date','Open','PromoInterval','monthStr'],axis=1,inplace =True)
# train = train[train.Sales != 0]
ho_xtrain = train.drop(['Sales'],axis=1 )
ho_ytrain = train.Sales
ho_xtest=test
ho_xtest=ho_xtest.sort_values(by=['Id']... | No | 4 | 10 | Data_Transform | drop_column | 7,004,483 | 2 | B | 2 | 0 | 0 | 0 | 10 | 6 | ok | 6 | 5 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", ... | 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"}] | ["Import Checker", "InPlace Checker"] | 5 | B |
2,691 | ho_xtest
| No | 5 | 41 | Debug | show_table | 7,004,483 | 1 | A | 0 | 0 | 0 | 1 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}] | A | no applicable ML-specific findings | [] | ["Import Checker"] | 5 | A |
2,692 |
ho_xtest.keys() , ho_xtrain.keys() | No | 5 | 40 | Debug | show_table_attributes | 7,004,483 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validat... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Import Checker"] | 5 | B |
2,693 |
preprocessed_dataset=ho_xtrain.to_numpy()
#preprocessed_train_labels=np.log1p(ho_ytrain.to_numpy()+1)
preprocessed_train_labels=(ho_ytrain.to_numpy()+1)/1000
preprocessed_test_dataset=ho_xtest.to_numpy()
# preprocessed_tr_labels=np.log1p(ho_ytest.to_numpy())
# preprocessed_train_labels=ho_ytrain.to_numpy() | No | 5 | 16 | Data_Transform | data_type_conversions | 7,004,483 | 3 | C | 3 | 0 | 0 | 0 | 15 | 3 | ok | 4 | 4 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validat... | 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"}] | ["Import Checker"] | 5 | C |
2,694 |
preprocessed_test_dataset=ho_xtest.to_numpy()
| No | 4 | 21 | Data_Transform | prepare_x_and_y | 7,004,483 | 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"] | 5 | A |
2,695 | from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split( preprocessed_dataset, preprocessed_train_labels, test_size=0.2)
X_train=np.expand_dims(X_train,axis=-1)
X_test=np.expand_dims(X_test,axis=-1)
y_train=np.array(y_train)
y_test=np.array(y_test)
y_train=y_train
y_tes... | No | 4 | 21 | Data_Transform | prepare_x_and_y | 7,004,483 | 1 | A | 1 | 0 | 0 | 2 | 5 | 10 | ok | 7 | 6 | [{"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": "NumPy", "name": "Array Creation Effi... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low, Randomness Control Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Randomness Control Checker", "severity": "low"}] | ["Array Creation Efficiency", "Import Checker"] | 5 | B |
2,696 | 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))
def rmse(y_true, y_pred):
'''
RMSE calculus to use during training phase
'''
return K.sqrt(K.mean(K.square(y_pred - y_true)))
def... | No | 5 | 84 | Other | not_enough_vertices | 7,004,483 | 1 | A | 0 | 3 | 0 | 0 | 0 | 6 | 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"] | 5 | A |
2,697 | 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, Dropout, Flatten, Lambda, Embedding,BatchNormalization,Input,Add,Concatenate
from keras.initializers import RandomNormal, Con... | No | 3 | 4 | Model_Train | choose_model_class | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
2,698 |
batch_size=80000
nb_epoch=400
print('Fit model...')
filepath="weights_rossmann.best.hdf5"
checkpoint = ModelCheckpoint(filepath, monitor='val_rmspe', verbose=1, save_best_only=True, mode='min')
callbacks_list = [checkpoint]
log = model_m.fit(X_train, y_train,
validation_data=(X_test,y_test), batch_size=bat... | 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,699 | model_m.load_weights(filepath)
preprocessed_test_dataset
ypred=model_m.predict(np.expand_dims(preprocessed_test_dataset[:,1:],axis=-1))
# results=np.concatenate([np.expand_dims(preprocessed_test_dataset[:,0],axis=-1),np.expm1(ypred)-1],axis=-1)
results=np.concatenate([np.expand_dims(preprocessed_test_dataset[:,0],ax... | No | 3 | 48 | Model_Evaluation | predict_on_test | 7,004,483 | 1 | A | 1 | 0 | 0 | 1 | 5 | 4 | ok | 6 | 5 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Exception Handling Checker", "Import Checker", "Memory Release Checker", "Unit Testing Checker"] | 5 | A |
2,700 | import csv
with open('submission.csv', mode='w') as csv_file:
fieldnames = ['Id', 'Sales']
writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
writer.writeheader()
for i in results:
print(i)
writer.writerow({'Id':i[0], 'Sales': max(0,i[1])})
#writer.writerow({'emp_name': 'John... | No | 5 | 25 | Data_Export | save_to_csv | 7,004,483 | 1 | A | 1 | 1 | 1 | 0 | 5 | 8 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Import Checker"] | 5 | A |
2,703 | for a,b in zip(y_test,X_test):
if a==0:
print(a,b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7])
#Store, DayOfWeek ,int(Date[0]),int(Date[1]),int(Date[2]), Open, Promo,StateHoliday, SchoolHoliday | No | 5 | 53 | Other | something_strange | 7,004,483 | 1 | A | 0 | 2 | 3 | 0 | 0 | 3 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Import Checker"] | 5 | A |
2,704 | !ls | No | 3 | 88 | Debug | list_files | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,706 | import pandas as pd
from pandas import datetime
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np | No | 5 | 22 | Environment | import_modules | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | 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"] | 0 | A |
2,707 | df = pd.read_csv('../input/rossmann-store-sales/train.csv', parse_dates = ['Date'], low_memory = False)
df.head() | No | 4 | 45 | Data_Extraction | load_from_csv | 7,465,372 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path de... | A | no applicable ML-specific findings | [] | ["Hardcoded file path", "Import Checker"] | 6 | A |
2,708 | df['Date']=pd.to_datetime(df['Date'],format='%Y-%m-%d') | No | 5 | 16 | Data_Transform | data_type_conversions | 7,465,372 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Import Checker"] | 6 | A |
2,709 | df['Hour'] = df['Date'].dt.hour
df['Day_of_Month'] = df['Date'].dt.day
df['Day_of_Week'] = df['Date'].dt.dayofweek
df['Month'] = df['Date'].dt.month | No | 5 | 8 | Data_Transform | feature_engineering | 7,465,372 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Import Checker"] | 6 | A |
2,710 | print(df['Date'].min())
print(df['Date'].max()) | No | 5 | 40 | Debug | show_table_attributes | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,711 | test = pd.read_csv('../input/rossmann-store-sales/test.csv', parse_dates = True, low_memory = False)
test.head() | No | 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 |
2,712 | test['Date']=pd.to_datetime(test['Date'],format='%Y-%m-%d') | No | 5 | 16 | Data_Transform | data_type_conversions | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,713 | test['Hour'] = test['Date'].dt.hour
test['Day_of_Month'] = test['Date'].dt.day
test['Day_of_Week'] = test['Date'].dt.dayofweek
test['Month'] = test['Date'].dt.month | No | 5 | 8 | Data_Transform | feature_engineering | 7,465,372 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Import Checker"] | 6 | A |
2,714 | print(test['Date'].min())
print(test['Date'].max()) | No | 5 | 40 | Debug | show_table_attributes | 7,465,372 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Import Checker"] | 6 | A |
2,715 | sns.pointplot(x='Month', y='Sales', data=df) | No | 5 | 81 | Visualization | relationship | 7,465,372 | 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 |
2,716 | sns.pointplot(x='Day_of_Week', y='Sales', data=df) | No | 5 | 75 | Visualization | time_series | 7,465,372 | 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 |
2,717 | sns.countplot(x = 'Day_of_Week', hue = 'Open', data = df)
plt.title('Store Daily Open Countplot') | No | 5 | 75 | Visualization | time_series | 7,465,372 | 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 |
2,718 | sns.pointplot(x='Day_of_Month', y='Sales', data=df) | No | 5 | 75 | Visualization | time_series | 7,465,372 | 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 |
2,719 | df['SalesPerCustomer'] = df['Sales']/df['Customers']
df['SalesPerCustomer'].describe() | No | 4 | 40 | Debug | show_table_attributes | 7,465,372 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Import Checker"] | 6 | A |
2,720 | df.Open.value_counts() | No | 5 | 72 | EDA | count_values | 7,465,372 | 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 |
2,721 | np.sum([df['Sales'] == 0]) | No | 5 | 72 | EDA | count_values | 7,465,372 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C... | C | Missing Axis Specification=medium | [{"type": "Missing Axis Specification", "severity": "medium"}] | ["Column Selection Checker", "Import Checker"] | 6 | C |
2,722 | #drop closed stores and stores with zero sales
df = df[(df["Open"] != 0) & (df['Sales'] != 0)]' | No | 5 | 14 | Data_Transform | filter | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,723 | store = pd.read_csv('../input/rossmann-store-sales/store.csv')
store.head(30) | No | 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 |
2,724 | store.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 |
2,725 | store['CompetitionDistance'] = store['CompetitionDistance'].fillna(store['CompetitionDistance'].max())
store['CompetitionOpenSinceMonth'] = store['CompetitionOpenSinceMonth'].fillna(store['CompetitionOpenSinceMonth'].mode().iloc[0]) #try 0
store['CompetitionOpenSinceYear'] = store['CompetitionOpenSinceYear'].fillna(sto... | No | 5 | 17 | Data_Transform | correct_missing_values | 7,465,372 | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Import Checker"] | 6 | A |
2,726 | df_store = pd.merge(df, store, how = 'left', on = 'Store')
df_store.head() | No | 4 | 32 | Data_Transform | merge | 7,465,372 | 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 |
2,727 | df_store.groupby('StoreType')['Sales'].describe() | No | 5 | 60 | Data_Transform | groupby | 7,465,372 | 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 |
2,728 | df_store.groupby('StoreType')['Customers', 'Sales'].sum() | No | 5 | 60 | Data_Transform | groupby | 7,465,372 | 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 |
2,729 | #sales trends
sns.catplot(data = df_store, x = 'Month', y = "Sales",
col = 'StoreType', # per store type in cols
palette = 'plasma',
hue = 'StoreType',
row = 'Promo', # per promo in the store in rows
color = 'c') ' | 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 |
2,730 | #customer trends
sns.catplot(data = df_store, x = 'Month', y = "Customers",
col = 'StoreType', # per store type in cols
palette = 'plasma',
hue = 'StoreType',
row = 'Promo', # per promo in the store in rows
color = 'c')' | 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 |
2,731 | #sales per customer
sns.catplot(data = df_store, x = 'Month', y = "SalesPerCustomer",
col = 'StoreType', # per store type in cols
palette = 'plasma',
hue = 'StoreType',
row = 'Promo', # per promo in the store in rows
color = 'c')' | 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 |
2,732 | sns.catplot(data = df_store, x = 'Month', y = "Sales",
col = 'DayOfWeek', # per store type in cols
palette = 'plasma',
hue = 'StoreType',
row = 'StoreType', # per store type in rows
color = 'c') ' | 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 |
2,733 | #stores open on sunday
df_store[(df_store.Open == 1) & (df_store.DayOfWeek == 7)]['Store'].unique() | No | 5 | 57 | Debug | show_unique_values | 7,465,372 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Import Checker"] | 6 | A |
2,734 | sns.catplot(data = df_store, x = 'DayOfWeek', y = "Sales",
col = 'Promo',
row = 'Promo2',
hue = 'Promo2',
palette = 'RdPu') ' | 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 |
2,735 | df_store['StateHoliday'] = df_store['StateHoliday'].map({'0':0 , 0:0 , 'a':1 , 'b':2 , 'c':3})
df_store['StateHoliday'] = df_store['StateHoliday'].astype(int) | No | 4 | 20 | Data_Transform | categorify | 7,465,372 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Import Checker"] | 6 | A |
2,736 | df_store['StoreType'] = df_store['StoreType'].map({'a':1 , 'b':2 , 'c':3 , 'd':4})
df_store['StoreType'] = df_store['StoreType'].astype(int) | No | 4 | 20 | Data_Transform | categorify | 7,465,372 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Import Checker"] | 6 | A |
2,737 | df_store.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 |
2,738 | df_store['Assortment'] = df_store['Assortment'].map({'a':1 , 'b':2 , 'c':3})
df_store['Assortment'] = df_store['Assortment'].astype(int) | No | 4 | 20 | Data_Transform | categorify | 7,465,372 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Import Checker"] | 6 | A |
2,739 | df_store['PromoInterval'] = df_store['PromoInterval'].map({'Jan,Apr,Jul,Oct':1 , 'Feb,May,Aug,Nov':2 , 'Mar,Jun,Sept,Dec':3})
df_store['PromoInterval'] = df_store['PromoInterval'].astype(int) | No | 4 | 20 | Data_Transform | categorify | 7,465,372 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Import Checker"] | 6 | A |
2,740 | df_store.to_csv('df_merged.csv', index=False) | No | 5 | 25 | Data_Export | save_to_csv | 7,465,372 | 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 |
2,741 | len(df_store) | No | 5 | 58 | Debug | show_shape | 7,465,372 | 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 |
2,742 | test = pd.merge(test, store, how = 'left', on = 'Store')
test.head() | No | 4 | 32 | Data_Transform | merge | 7,465,372 | 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 |
2,743 | test.fillna(method='ffill', inplace=True) | No | 5 | 17 | Data_Transform | correct_missing_values | 7,465,372 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", ... | A | no applicable ML-specific findings | [] | ["Import Checker", "InPlace Checker"] | 6 | A |
2,744 | test['StateHoliday'] = test['StateHoliday'].map({'0':0 , 0:0 , 'a':1 , 'b':2 , 'c':3})
test['StateHoliday'] = test['StateHoliday'].astype(int)
test['StoreType'] = test['StoreType'].map({'a':1 , 'b':2 , 'c':3 , 'd':4})
test['StoreType'] = test['StoreType'].astype(int)
test['Assortment'] = test['Assortment'].map({'a':1 ,... | No | 4 | 20 | Data_Transform | categorify | 7,465,372 | 1 | A | 0 | 0 | 0 | 0 | 0 | 8 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Import Checker"] | 6 | A |
2,745 | test.to_csv('test_merged.csv', index=False) | No | 5 | 25 | Data_Export | save_to_csv | 7,465,372 | 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 |
2,746 | test = test.drop(['Id','Date'],axis=1) | No | 5 | 10 | Data_Transform | drop_column | 7,465,372 | 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 |
2,747 | X = df_store.drop(['Date','Sales','Customers', 'SalesPerCustomer'],1)
#Transform Target Variable
y = np.log1p(df_store['Sales'])
from sklearn.model_selection import train_test_split
X_train , X_val , y_train , y_val = train_test_split(X, y , test_size=0.30 , random_state = 1 ) | No | 3 | 21 | Data_Transform | prepare_x_and_y | 7,465,372 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Column Selection Checker", "Import Checker"] | 6 | B |
2,748 | X_train.shape, X_val.shape, y_train.shape, y_val.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,749 | from sklearn.ensemble import GradientBoostingRegressor
gbrt = GradientBoostingRegressor(max_depth=10, n_estimators=200, random_state=42)
gbrt.fit(X_train, y_train)
print(gbrt.score(X_train, y_train)) | Yes | 3 | 7 | Model_Train | train_model | 7,465,372 | 1 | A | 1 | 0 | 0 | 0 | 5 | 4 | ok | 7 | 6 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validat... | 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", "Import Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 6 | B |
2,750 | y_pred = gbrt.predict(X_val) | No | 5 | 48 | Model_Evaluation | predict_on_test | 7,465,372 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing ... | A | no applicable ML-specific findings | [] | ["Exception Handling Checker", "Import Checker", "Unit Testing Checker"] | 6 | A |
2,751 | from sklearn.metrics import r2_score, mean_squared_error
print(r2_score(y_val , y_pred))
print(np.sqrt(mean_squared_error(y_val , y_pred))) | No | 5 | 49 | Model_Evaluation | compute_test_metric | 7,465,372 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing ... | A | no applicable ML-specific findings | [] | ["Import Checker", "Unit Testing Checker"] | 6 | A |
2,752 | df1 = pd.DataFrame({'Actual': y_val, 'Predicted': y_pred})
df1.head(25) | No | 4 | 12 | Data_Transform | create_dataframe | 7,465,372 | 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 |
2,753 | test_pred=gbrt.predict(test[X.columns])
test_pred_inv=np.exp(test_pred)-1 | No | 5 | 48 | Model_Evaluation | predict_on_test | 7,465,372 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 4 | 4 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Exception Handling Checker", "Import Checker", "Unit Testing Checker"] | 6 | A |
2,754 | test_pred_inv | 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 |
2,755 | #make submission df
prediction = pd.DataFrame(test_pred_inv)
submission = pd.read_csv('../input/rossmann-store-sales/sample_submission.csv')
prediction_df = pd.concat([submission['Id'], prediction], axis=1)
prediction_df.columns=['Id','Sales']
prediction_df.to_csv('Sample_Submission.csv', index=False) | No | 3 | 25 | Data_Export | save_to_csv | 7,465,372 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 6 | 6 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 2"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection C... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Exception Handling Checker", "Hardcoded file path", "Import Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker"] | 6 | A |
2,756 | prediction_df.head() | No | 5 | 41 | Debug | show_table | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,757 | #
import pandas as pd
import numpy as np
import xgboost as xgb
import missingno as msno
import seaborn as sns
import matplotlib as mpl
import matplotlib.pyplot as plt
%matplotlib inline' | 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,758 | b"# \ntrain = pd.read_csv('../input/rossmann-store-sales/train.csv')\ntest = pd.read_csv('../input/rossmann-store-sales/test.csv')\nstore = pd.read_csv('../input/rossmann-store-sales/store.csv')" | No | 5 | 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,759 | train.info(), test.info(), store.info() | 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 |
2,760 | fig = plt.figure(figsize=(16,6))
ax1 = fig.add_subplot(121)
ax1.set_xlabel('Sales')
ax1.set_ylabel('Count')
ax1.set_title('Sales of Closed Stores')
plt.xlim(-1,1)
train.loc[train.Open==0].Sales.hist(align='left')
ax2 = fig.add_subplot(122)
ax2.set_xlabel('Sales')
ax2.set_ylabel('PDF')
ax2.set_title('Sales of Open Sto... | No | 5 | 33 | Visualization | distribution | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 13 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,761 | train = train.loc[train.Open != 0]
train = train.loc[train.Sales > 0].reset_index(drop=True) | No | 5 | 14 | Data_Transform | filter | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,762 | # train
train[train.isnull().values==True]' | No | 5 | 14 | Data_Transform | filter | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,763 | # test
test[test.isnull().values==True]' | No | 5 | 14 | Data_Transform | filter | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,764 | # store
msno.matrix(store)' | No | 5 | 34 | Visualization | missing_values | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,765 | # test
test.fillna(1,inplace=True)
# CompetitionDistance
store.CompetitionDistance = store.CompetitionDistance.fillna(store.CompetitionDistance.median())
# 0
store.fillna(0,inplace=True)' | No | 5 | 17 | Data_Transform | correct_missing_values | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,766 | b"# \ntrain = pd.merge(train, store, on='Store')\ntest = pd.merge(test, store, on='Store')" | No | 5 | 32 | Data_Transform | merge | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,767 | import statsmodels.api as sm
from statsmodels.sandbox.regression.predstd import wls_prediction_std
import math
import sklearn.preprocessing as skpe
import sklearn.model_selection as ms
import sklearn.metrics as sklm
import sklearn.ensemble as sken
import sklearn.linear_model as lm
import seaborn as sns
import matplotli... | No | 5 | 22 | Environment | import_modules | 9,904,611 | 1 | A | 0 | 0 | 0 | 0 | 0 | 10 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
2,768 | # Reading files
path="../input/rossmann-store-sales/train.csv"
train=pd.read_csv(path)
print(train.shape)
train.head() | Yes | 4 | 45 | Data_Extraction | load_from_csv | 9,904,611 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Hardcoded file path"] | 7 | B |
2,769 | path1="../input/rossmann-store-sales/test.csv"
test=pd.read_csv(path1)
print(test.shape)
test.head() | Yes | 4 | 45 | Data_Extraction | load_from_csv | 9,904,611 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/rossmann-store-sales/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 |
2,770 | path2="../input/rossmann-store-sales/store.csv"
store_df=pd.read_csv(path2)
print(store_df.shape)
store_df.head() | Yes | 4 | 45 | Data_Extraction | load_from_csv | 9,904,611 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/rossmann-store-sales/store.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 |
2,771 | train.info()
print("----------------------------------------------")
store_df.info()
print("----------------------------------------------")
test.info() | No | 5 | 40 | Debug | show_table_attributes | 9,904,611 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | 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 |
2,772 | # Adding new variable
train['Sales_per_customer']=train['Sales']/train['Customers']
train['Sales_per_customer'].describe() # An average of 9.49$ is earned from a customer at a particular store | No | 4 | 8 | Data_Transform | feature_engineering | 9,904,611 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | 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"] | 7 | B |
2,773 | fig, ax1 = plt.subplots(figsize=(15,4))
sns.countplot(x='Open',hue='DayOfWeek', data=train,palette="husl", ax=ax1) # This indicates that there are some stores which opens mostly on Sundays while some are closed on Sundays ' | No | 5 | 33 | Visualization | distribution | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,774 | # Date
# Create Year and Month columns
train['Year'] = train['Date'].apply(lambda x: int(str(x)[:4]))
train['Month'] = train['Date'].apply(lambda x: int(str(x)[5:7]))
test['Year'] = test['Date'].apply(lambda x: int(str(x)[:4]))
test['Month'] = test['Date'].apply(lambda x: int(str(x)[5:7]))
# Assign Date column to ... | 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 |
2,775 | # Plot average sales and customers over years
fig, (axis1,axis2) = plt.subplots(1,2,figsize=(15,4))
sns.barplot(x='Year', y='Sales', data=train, ax=axis1)
sns.barplot(x='Year', y='Customers', data=train, ax=axis2) | No | 5 | 75 | Visualization | time_series | 9,904,611 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
2,776 | # Plot average sales and customers over days of week
fig, (axis1,axis2) = plt.subplots(1,2,figsize=(15,4))
sns.barplot(x='DayOfWeek', y='Sales', data=train, ax=axis1)
sns.barplot(x='DayOfWeek', y='Customers', data=train, ax=axis2) | No | 5 | 75 | Visualization | time_series | 9,904,611 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
2,777 | # Plot average sales and customers over months
fig, (axis1,axis2) = plt.subplots(1,2,figsize=(15,4))
sns.barplot(x='Month', y='Sales', data=train, ax=axis1)
sns.barplot(x='Month', y='Customers', data=train, ax=axis2) | No | 5 | 75 | Visualization | time_series | 9,904,611 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
2,778 | # Plot average sales and customers with/without promo
fig, (axis1,axis2) = plt.subplots(1,2,figsize=(15,4))
sns.barplot(x='Promo', y='Sales', data=train, ax=axis1)
sns.barplot(x='Promo', y='Customers', data=train, ax=axis2) | No | 5 | 33 | Visualization | distribution | 9,904,611 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
2,779 | b"def build_features(features, data):\n\n # \n features.extend(['Store','CompetitionDistance','CompetitionOpenSinceMonth','StateHoliday','StoreType','Assortment',\n 'SchoolHoliday','CompetitionOpenSinceYear', 'Promo', 'Promo2', 'Promo2SinceWeek', 'Promo2SinceYear'])\n \n # https://blog.c... | No | 3 | 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,780 | b"# Date\ntrain.Date = pd.to_datetime(train.Date, errors='coerce')\ntest.Date = pd.to_datetime(test.Date, errors='coerce')\n\n# features\nfeatures = []\n\n# traintest\nbuild_features(features, train)\nbuild_features([], test)\n\n# \nprint(features)" | No | 3 | 16 | Data_Transform | data_type_conversions | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,781 | # Rmspe
# https://www.kaggle.com/justdoit/xgboost-in-python-with-rmspe
def ToWeight(y):
w = np.zeros(y.shape, dtype=float)
ind = y != 0
w[ind] = 1./(y[ind]**2)
return w
def rmspe(yhat, y):
w = ToWeight(y)
rmspe = np.sqrt(np.mean(w * (y-yhat)**2))
return rmspe
def rmspe_xg(yhat, y):
y ... | 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 |
2,782 | from sklearn.model_selection import GridSearchCV, ShuffleSplit
from sklearn.metrics import make_scorer
from sklearn.tree import DecisionTreeRegressor
regressor = DecisionTreeRegressor(random_state=2)
cv_sets = ShuffleSplit(n_splits=5, test_size=0.2)
params = {'max_depth':range(10,40,2)}
scoring_fnc = make_scorer... | No | 4 | 6 | Hyperparam_Tuning | train_on_grid | null | 1 | A | 1 | 0 | 0 | 0 | 5 | 10 | 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 12"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": ... | A | no applicable ML-specific findings | [] | ["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 0 | A |
2,783 | #
DTR.get_params()' | No | 5 | 79 | Visualization | model_coefficients | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,784 | #
submission = pd.DataFrame({"Id": test["Id"], "Sales": np.expm1(DTR.predict(test[features]))})
submission.to_csv("benchmark.csv", index=False)' | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.