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,365 | fig, ax = plt.subplots (1,5, figsize=(25,4))
sns.boxplot('StoreType', 'Sales','Promo', data=data, ax=ax[0])
sns.boxplot('StoreType', 'Sales', 'SchoolHoliday', data=data, ax=ax[1])
sns.boxplot('StoreType','Sales','Assortment', data=data, ax=ax[2])
sns.boxplot('StoreType', 'Sales', 'StateHoliday', data=data, ax=ax[3])
... | No | 5 | 33 | Visualization | distribution | 2,095,107 | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | 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,366 | grid = sns.FacetGrid(data, col="StoreType", row="Promo", palette="tab10", col_order="abcd")
grid.map(sns.pointplot, "Month", "Sales")
plt.show() | No | 5 | 33 | Visualization | distribution | 2,095,107 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
2,367 | all_data['SalesPerCustomer'] = data['Sales']/data['Customers'] | No | 5 | 8 | Data_Transform | feature_engineering | 2,095,107 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 6 | A |
2,368 | grid = sns.FacetGrid(all_data, col="StoreType", row="Promo", palette="tab10", col_order="abcd")
grid.map(sns.pointplot, "Month", "SalesPerCustomer")
plt.show() | No | 5 | 33 | Visualization | distribution | 2,095,107 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
2,369 | mappings = {'0':0, 'a':1, 'b':2, 'c':3, 'd':4}
all_data.StoreType.replace(mappings, inplace=True)
all_data.Assortment.replace(mappings, inplace=True)
all_data.StateHoliday.replace(mappings, inplace=True) | No | 5 | 20 | Data_Transform | categorify | 2,095,107 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 3 | 1 | [{"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 8"}, {"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "... | A | no applicable ML-specific findings | [] | ["InPlace Checker"] | 6 | A |
2,370 | def prepareDf (df, submission=False):
tests_date = "2015-06-12"
tmp_data = all_data[all_data['part']=='train'] .copy()
if not submission:
tmp_data = tmp_data[tmp_data['Date']<tests_date]
shift = 48
cols = ['isBeforeCompetition', 'IsPromoMonth', 'PromoOpen', 'DayOfWeek', 'Promo... | No | 5 | 53 | Other | something_strange | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,371 | df = prepareDf(all_data) | No | 2 | 13 | Data_Transform | split | 2,095,107 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
2,372 | df[df['Store']== 696 ].sort_values('Date') | No | 5 | 9 | Data_Transform | sort_values | 2,095,107 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 6 | A |
2,373 | fig, ax = plt.subplots(5, 1, figsize=(15,10))
for p in range (5):
i = np.random.choice(data['Store'].unique())
df[df['Store']== i ].plot('Date', 'Sales', ax=ax[p])
df[df['Store']== i ].plot('Date', 'shift_sales', ax=ax[p])
ax[p] .set_title("Store %d" %i)
ax[p].legend(bbox_to_anchor=(1,.5))
plt.tight... | 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,374 | fig, ax = plt.subplots(5, 1, figsize=(15,10))
for p in range (5):
i = np.random.choice(data['Store'].unique())
df[df['Store']== i ].plot('Date', 'Sales', ax=ax[p])
df[df['Store']== i ].plot('Date', 'shift_t7_sales', ax=ax[p])
ax[p] .set_title("Store %d" %i)
ax[p].legend(bbox_to_anchor=(1,.5))
plt.ti... | 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,375 | fig, ax = plt.subplots(5, 1, figsize=(15,10))
for p in range (5):
i = np.random.choice(data['Store'].unique())
df[df['Store']== i ].plot('Date', 'Sales', ax=ax[p])
df[df['Store']== i ].plot('Date', 'rolling_mean_t7_sales', ax=ax[p])
ax[p] .set_title("Store %d" %i)
ax[p].legend(bbox_to_anchor=(1,.5))... | 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,376 | fig, ax = plt.subplots(5, 1, figsize=(15,10))
for p in range (5):
i = np.random.choice(data['Store'].unique())
df[df['Store']== i ].plot('Date', 'Customers', ax=ax[p])
df[df['Store']== i ].plot('Date', 'shift_t30_customer', ax=ax[p])
ax[p] .set_title("Store %d" %i)
ax[p].legend(bbox_to_anchor=(1,.5)... | 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,377 | fig, ax = plt.subplots(5, 1, figsize=(15,10))
for p in range (5):
i = np.random.choice(data['Store'].unique())
df[df['Store']== i ].plot('Date', 'Customers', ax=ax[p])
df[df['Store']== i ].plot('Date', 'rolling_mean_t7_customer', ax=ax[p])
ax[p] .set_title("Store %d" %i)
ax[p].legend(bbox_to_anchor=... | No | 5 | 33 | Visualization | distribution | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,378 | #
train = pd.read_csv("/kaggle/input/rossmann-store-sales/train.csv")
test = pd.read_csv("/kaggle/input/rossmann-store-sales/test.csv")
store = pd.read_csv("/kaggle/input/rossmann-store-sales/store.csv")
state = pd.read_csv("/kaggle/input/rossmann-store-extra/store_states.csv")
state_name = pd.read_csv("/kaggle/input/r... | 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 |
2,379 | b"def rmspe(y_pred, y_test):\n return np.sqrt(np.mean(((y_pred - y_test) / y_test)**2))\n\n#Date\n#Month, DayEmbedding0\ndef date(data):\n data['Date'] = pd.to_datetime(data['Date'])\n data['Year'] = data['Date'].dt.year\n data['Year'] = data['Year'] - data['Year'].min()\n data['Month'] = data['Date'].dt... | Yes | 3 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,380 | class EntitiyEmbedding:
def __init__(self):
self.input_model = []
self.output_model = []
self.features = []
self.embeddings = []
def add(self, feature, input_shape, output_shape):
self.features.append(feature)
self.embeddings.append(feature)
input_model =... | No | 2 | 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,381 | b"#\nstore = pre_store(store, state)\ndata = preprocess(train, test, store)\ndata = pre_weather(data, weathers)\n\nsmax = data['SalesLog'].max()\ncmax = data['CustomersLog'].max()" | No | 3 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,382 | b"#EntitiyEmbedding\n# model.add(())\n#0, 1 model.dense()\n\nmodel = EntitiyEmbedding()\nmodel.add('Store', input_shape=1115, output_shape=10)\nmodel.add('DayOfWeek', input_shape=7, output_shape=6)\nmodel.add('Year', input_shape=3, output_shape=2)\nmodel.add('Day', input_shape=31, output_shape=10)\nmodel.add('Month', i... | No | 3 | 4 | Model_Train | choose_model_class | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,383 | b"#traintest\ntrain = data[data['Id']==0]\ntrain = train.sample(frac=1, random_state=22)\n\ntest = data[data['Id']!=0]\nId = test['Id']\n33\nX = train.copy()\ny = train[['CustomersLog', 'SalesLog']]\n\n#20\n#\nX_train, X_ee, y_train, y_ee = train_test_split(X, y, test_size=200000, random_state=44)" | No | 4 | 21 | Data_Transform | prepare_x_and_y | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,384 | b"#\nmodel.fit(X_ee, y_ee['CustomersLog']/cmax, X_train, y_train['CustomersLog']/cmax, epochs=12)" | No | 5 | 7 | Model_Train | train_model | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,385 | b"#\nweights = model.get_weight()\n\n#\nX_train = replace(X_train, weights, model.embeddings)\ntest = replace(test, weights, model.embeddings)\n\n#\nX_train = X_train.drop(['Sales', 'Id', 'SalesLog', 'CustomersLog', \n 'Dew_PointC', 'MeanDew_PointC', 'Min_DewpointC', 'Max_Sea_Level_PressurehPa', ... | No | 2 | 21 | Data_Transform | prepare_x_and_y | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,386 | #LightGBM
params = {"objective" : "rmse",
"boosting" : "gbdt",
"metric" : "rmse",
"num_iterations" : 7500,
"top_k" : 30,
"max_depth" : 8,
"num_leaves" : 800,
"min_data_in_leaf" : 20,
"learning_rate" : 0.02,
"bagging_fraction... | No | 3 | 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,387 | pred = model.predict(test)
pred = np.exp(pred)
pred = pd.DataFrame(pred.T, index=Id, columns=['Sales'])
df = pd.DataFrame(range(1, L+1), columns=['Id'])
df = df.merge(pred, how='left', on=['Id'])
df.fillna(0, inplace=True)
df.to_csv("/kaggle/working/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,388 | data = pd.read_csv('/kaggle/input/rossmann-store-sales/train.csv')
store = pd.read_csv('/kaggle/input/rossmann-store-sales/store.csv')
test = pd.read_csv('/kaggle/input/rossmann-store-sales/test.csv')
print(data.shape)
print(store.shape)
print(test.shape) | No | 4 | 45 | Data_Extraction | load_from_csv | 6,511,394 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 4 | 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."] | 5 | A |
2,389 | store.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,390 | data['Date']=pd.to_datetime(data['Date'],format='%Y-%m-%d')
#store_id=data.Store.unique()[0]
#print(store_id)
store_rows=data[data['Store']==1]
print(store_rows.shape)
store_rows.resample('1D',on='Date')['Sales'].sum().plot.line(figsize=(14,4)) | No | 3 | 16 | Data_Transform | data_type_conversions | 6,511,394 | 1 | A | 1 | 0 | 0 | 0 | 5 | 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"] | 5 | A |
2,391 | #CHECKING THE STARTING AND END DATE
print(data['Date'].min())
print(data['Date'].max()) | No | 5 | 40 | Debug | show_table_attributes | 6,511,394 | 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"] | 5 | A |
2,392 | data['Sales'].plot.hist() #right skewed | No | 5 | 33 | Visualization | distribution | 6,511,394 | 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"] | 5 | A |
2,393 | # CHECKING MISSING VALUES
store.isna().sum() | No | 5 | 39 | EDA | count_missing_values | 6,511,394 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
2,394 | store = pd.read_csv('/kaggle/input/rossmann-store-sales/store.csv')
store['Promo2SinceWeek'] = store['Promo2SinceWeek'].fillna(0)
store['Promo2SinceYear'] = store['Promo2SinceYear'].fillna(store['Promo2SinceYear'].mode().iloc[0])
store['PromoInterval'] = store['PromoInterval'].fillna(store['PromoInterval'].mode().iloc... | Yes | 2 | 45 | Data_Extraction | load_from_csv | 6,511,394 | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path d... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Hardcoded file path"] | 5 | A |
2,395 | store['Promo2SinceYear'].mode().iloc[0] | No | 5 | 40 | Debug | show_table_attributes | 6,511,394 | 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"] | 5 | A |
2,396 | data_merged = data.merge(store,on='Store',how='left')
data_merged.head() | No | 5 | 32 | Data_Transform | merge | 6,511,394 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
2,397 | #partitioning the date into day,month,year
data_merged['day'] = data_merged['Date'].dt.day
data_merged['month'] = data_merged['Date'].dt.month
data_merged['year'] = data_merged['Date'].dt.year
#data_merged['Date'].dt.strftime('%a')- | No | 5 | 8 | Data_Transform | feature_engineering | 6,511,394 | 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"] | 5 | A |
2,398 | #CATEGORICAL-stateholiday,storetype,assortment,promointerval
data_merged['StateHoliday'] = data_merged['StateHoliday'].map({'0':0,0:0,'a':1,'b':2,'c':3})
data_merged['StateHoliday'] = data_merged['StateHoliday'].astype(int) | No | 4 | 20 | Data_Transform | categorify | 6,511,394 | 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"] | 5 | A |
2,399 | data_merged['Assortment'] = data_merged['Assortment'].map({'a':1,'b':2,'c':3})
data_merged['Assortment'] = data_merged['Assortment'].astype(int) | No | 4 | 20 | Data_Transform | categorify | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,400 | data_merged['StoreType'] = data_merged['StoreType'].map({'a':1,'b':2,'c':3,'d':4})
data_merged['StoreType'] = data_merged['StoreType'].astype(int) | No | 4 | 20 | Data_Transform | categorify | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,401 | map_promo={'Jan,Apr,Jul,Oct':1,'Feb,May,Aug,Nov':2,'Mar,Jun,Sept,Dec':3}
data_merged['PromoInterval']=data_merged['PromoInterval'].map(map_promo)
data_merged['PromoInterval'] = data_merged['PromoInterval'].astype(int) | No | 4 | 20 | Data_Transform | categorify | 6,511,394 | 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"] | 5 | A |
2,402 | # Train & Test split
from sklearn.model_selection import train_test_split
X=data_merged.drop(['Date','Sales'],axis=1)
y=np.log(data_merged['Sales']+1)
train_x,validate_x,train_y,validate_y = train_test_split(X,y,test_size=0.20,random_state=1)
train_x.shape,validate_x.shape,train_y.shape,validate_y.shape | Yes | 4 | 21 | Data_Transform | prepare_x_and_y | 6,511,394 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | 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"] | 5 | B |
2,403 | from sklearn.tree import DecisionTreeRegressor
model_dt=DecisionTreeRegressor(max_depth=10,random_state=1)
model_dt.fit(train_x,train_y) | Yes | 4 | 7 | Model_Train | train_model | 6,511,394 | 2 | B | 1 | 0 | 0 | 0 | 5 | 3 | 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 |
2,404 | #Code for RMSPE Value
def ToWeight(y):
w = np.zeros(y.shape, dtype=float)
ind = y != 0
w[ind] = 1./(y[ind]**2)
return w
def rmspe(y, yhat):
w = ToWeight(y)
rmspe = np.sqrt(np.mean( w * (y - yhat)**2 ))
return rmspe | No | 3 | 28 | Model_Train | compute_train_metric | null | 1 | A | 1 | 2 | 0 | 0 | 10 | 9 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,405 | from sklearn.metrics import r2_score, mean_squared_error
y_pred=model_dt.predict(validate_x)
y_pred_exp=np.exp(y_pred)-1
validate_y_exp=np.exp(validate_y)-1
print("R-squared:", r2_score(validate_y_exp, y_pred_exp))
print("RMSE:", np.sqrt(mean_squared_error(validate_y_exp, y_pred_exp)))
print('RMSPE',rmspe(validate_y_ex... | No | 4 | 27 | Model_Train | predict_on_train | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
2,406 | #checking the feature which has most importance
import matplotlib.pyplot as plt
plt.figure(figsize=(20,5))
plt.bar(X.columns,model_dt.feature_importances_) | No | 5 | 79 | Visualization | model_coefficients | 6,511,394 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
2,407 | stores_avg_cust=data.groupby(['Store'])['Customers'].mean().reset_index().astype(int)
stores_avg_cust
test_1=test.merge(stores_avg_cust,on='Store',how='left')
test_merg=test_1.merge(store,on='Store',how='left')
test_merg['Open']=test_merg['Open'].fillna(1)
test_merg['Date']=pd.to_datetime(test_merg['Date'],format='%Y-%... | No | 3 | 8 | Data_Transform | feature_engineering | 6,511,394 | 1 | A | 0 | 0 | 0 | 1 | 0 | 9 | 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"] | 5 | A |
2,408 | test_merg.describe() | No | 5 | 40 | Debug | show_table_attributes | 6,511,394 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
2,409 | #CATEGORICAL-stateholiday,storetype,assortment,promointerval
test_merg['StateHoliday'] = test_merg['StateHoliday'].map({'0':0,0:0,'a':1,'b':2,'c':3})
test_merg['StateHoliday'] = test_merg['StateHoliday'].astype(int)
test_merg['Assortment'] = test_merg['Assortment'].map({'a':1,'b':2,'c':3})
test_merg['Assortment'] = te... | No | 3 | 20 | Data_Transform | categorify | 6,511,394 | 1 | A | 0 | 0 | 0 | 0 | 0 | 9 | 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"] | 5 | A |
2,410 | test_merged=test_merg.drop(['Id','Date'],axis=1)
test_merged.describe() | No | 4 | 40 | Debug | show_table_attributes | 6,511,394 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
2,411 | test_pred=model_dt.predict(test_merg[X.columns])
test_pred_inv=np.exp(test_pred)-1
submission_predict = pd.DataFrame({'ID':test['Id'],'Sales':test_pred_inv}) | No | 5 | 48 | Model_Evaluation | predict_on_test | 6,511,394 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Exception Handling Checker", "Unit Testing Checker"] | 5 | A |
2,412 | submission_predict | No | 5 | 41 | Debug | show_table | 6,511,394 | 1 | A | 0 | 0 | 0 | 1 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
2,413 | submission_predict.to_csv('submission.csv',index=False) | No | 5 | 25 | Data_Export | save_to_csv | 6,511,394 | 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 |
2,414 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns | No | 5 | 22 | Environment | import_modules | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 0 | A |
2,415 | data = pd.read_csv('/kaggle/input/rossmann-store-sales/train.csv')
store= pd.read_csv('/kaggle/input/rossmann-store-sales/store.csv')
test= pd.read_csv('/kaggle/input/rossmann-store-sales/test.csv') | No | 5 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,416 | print(data.shape)
print(store.shape) | No | 5 | 58 | Debug | show_shape | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,417 | data.info()
# data.dtypes | 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,418 | data.describe(include='object') | 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,419 | data.describe()[['Sales','Customers']] | 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,420 | data.describe()[['Sales','Customers']].loc['mean'] | 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,421 | data.describe()[['Sales','Customers']].loc['min'] | 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,422 | data.describe()[['Sales','Customers']].loc['max'] | 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,423 | data.Store.nunique() | No | 5 | 54 | EDA | count_unique_values | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,424 | data.head()
data.Store.value_counts().head(50).plot.bar() | 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,425 | data.Store.value_counts().tail(50).plot.bar() | 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,426 | data.Store.value_counts() | No | 5 | 72 | EDA | count_values | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,427 | data.DayOfWeek.value_counts() | No | 5 | 72 | EDA | count_values | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,428 | data.Open.value_counts() | No | 5 | 72 | EDA | count_values | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,429 | data.Promo.value_counts() | No | 5 | 72 | EDA | count_values | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,430 | data['Date']=pd.to_datetime(data['Date'],format='%Y-%m-%d')
store_id= data.Store.unique()[0]
print(store_id)
store_rows=data[data['Store']==store_id]
print(store_rows.shape)
# store_rows.resample('1D',on='Date')['Sales'].sum().plot.line(figsize=(14,4)) | No | 3 | 57 | Debug | show_unique_values | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,432 | test['Date']=pd.to_datetime(test['Date'],format='%Y-%m-%d')
store_test_rows = test[test['Store']==store_id]
store_test_rows['Date'].min(),store_test_rows['Date'].max() | No | 4 | 40 | Debug | show_table_attributes | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,433 | store_rows['Sales'].plot.hist()
# it is slightly skewed. | 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,434 | data['Sales'].plot.hist()
# it is slightly skewed. | 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,436 | store_id=store[store['Store']==1].T | No | 5 | 14 | Data_Transform | filter | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,437 | store[~store['Promo2SinceYear'].isna()].iloc[0] | No | 3 | 17 | Data_Transform | correct_missing_values | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,438 | # Method1
store = pd.read_csv('/kaggle/input/rossmann-store-sales/store.csv')
store['Promo2SinceWeek']= store['Promo2SinceWeek'].fillna(0)
store['Promo2SinceYear']= store['Promo2SinceYear'].fillna(store['Promo2SinceYear'].mode().iloc[0])
store['PromoInterval']= store['PromoInterval'].fillna(store['PromoInterval'].mode(... | Yes | 3 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 8 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,439 | data_merged = data.merge(store, on='Store',how='left')
print(data.shape)
print(data_merged.shape)
print(data_merged.isna().sum().sum()) #to cross check if there are any missing values | No | 4 | 32 | Data_Transform | merge | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,440 | # encoding
# 3 categorical column,1 date column, rest are numerical
# data_merged.dtypes
data_merged['day']=data_merged['Date'].dt.day
data_merged['month']=data_merged['Date'].dt.month
data_merged['year']=data_merged['Date'].dt.year
#data_merged['dayofweek']=data_merged['Date'].dt.strftime('%a')
| No | 5 | 8 | Data_Transform | feature_engineering | null | 2 | B | 1 | 0 | 0 | 0 | 5 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,442 | # data_merged.dtypes
# StateHoliday,StoreType,Assortment,PromoInterval
data_merged['StateHoliday'].unique()
# for creating dummy variables - label encoding is used
data_merged['StateHoliday']=data_merged['StateHoliday'].map({'0':0,0:0,'a':1,'b':2,'c':3})
data_merged['StateHoliday']=data_merged['StateHoliday'].astype(in... | No | 3 | 20 | Data_Transform | categorify | null | 1 | A | 1 | 0 | 0 | 1 | 5 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,443 | # encoding assorted
data_merged['Assortment']
# for creating dummy variables - label encoding is used
data_merged['Assortment']=data_merged['Assortment'].map({'a':1,'b':2,'c':3})
data_merged['Assortment']=data_merged['Assortment'].astype(int)
data_merged | No | 4 | 20 | Data_Transform | categorify | null | 1 | A | 0 | 0 | 0 | 1 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,444 | data_merged['StoreType'].unique()
data_merged['StoreType']=data_merged['StoreType'].map({'a':1,'b':2,'c':3,'d':4})
data_merged['StoreType']=data_merged['StoreType'].astype(int)
data_merged | No | 3 | 20 | Data_Transform | categorify | null | 1 | A | 0 | 0 | 0 | 1 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,445 | data_merged['PromoInterval'].unique()
map_promo = {'Jan,Apr,Jul,Oct':1,'Feb,May,Aug,Nov':2,'Mar,Jun,Sept,Dec':3}
data_merged['PromoInterval']=data_merged['PromoInterval'].map(map_promo)
data_merged | No | 4 | 20 | Data_Transform | categorify | null | 1 | A | 0 | 0 | 0 | 1 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,446 | # Train and validate Split
features= data_merged.columns.drop(['Sales','Date'])
from sklearn.model_selection import train_test_split
train_x,validate_x,train_y,validate_y = train_test_split(data_merged[features],np.log(data_merged['Sales']+1),test_size=0.2,random_state=1)
train_x.shape,validate_x.shape,train_y.shape,va... | No | 3 | 13 | Data_Transform | split | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | 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"}] | [] | 0 | B |
2,447 | # from sklearn.tree import DecisionTreeRegressor
# model_dt = DecisionTreeRegressor(max_depth=20,random_state=1).fit(train_x,train_y)
# validate_y_pred = model_dt.predict(validate_x)
from sklearn.tree import DecisionTreeRegressor
model_dt=DecisionTreeRegressor(max_depth=10,random_state=1).fit(train_x,train_y)
validat... | Yes | 3 | 7 | Model_Train | train_model | null | 3 | C | 3 | 0 | 0 | 0 | 15 | 3 | ok | 7 | 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, Randomness Control Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Randomness Control 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 | C |
2,448 | !pip install pydotplus | No | 5 | 87 | Environment | install_modules | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,449 | def draw_tree(model, columns):
import pydotplus
from sklearn.externals.six import StringIO
from IPython.display import Image
import os
from sklearn import tree
graphviz_path = 'C:\\Program Files (x86)\\Graphviz2.38/bin/'
os.environ["PATH"] += os.pathsep + graphviz_path
dot_data = S... | No | 5 | 84 | Other | not_enough_vertices | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
2,450 | draw_tree(model_dt,features) | 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,451 | validate_y_pred = model_dt.predict(validate_x)
from sklearn.metrics import mean_squared_error
validate_y_inv = np.exp(validate_y) - 1
validate_y_pred_inv = np.exp(validate_y_pred) - 1
np.sqrt(mean_squared_error(validate_y_inv , validate_y_pred_inv)) | No | 4 | 49 | Model_Evaluation | compute_test_metric | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | 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"] | 0 | A |
2,453 | model_dt.feature_importances_ | No | 5 | 79 | Visualization | model_coefficients | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,454 | import matplotlib.pyplot as plt
plt.figure(figsize=(10,5))
plt.barh(features,model_dt.feature_importances_)
pd.Series(model_dt.feature_importances_,index=features) | No | 5 | 79 | Visualization | model_coefficients | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,455 | # hyperparameter tuning
from sklearn.model_selection import GridSearchCV
parameters = {'max_depth': list(range(5,15))}
base_model= DecisionTreeRegressor()
cv_model = GridSearchCV(base_model, param_grid = parameters).fit(train_x, train_y)
parameters | Yes | 3 | 7 | Model_Train | train_model | 6,511,397 | 1 | A | 0 | 0 | 0 | 1 | 0 | 5 | 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"] | 6 | A |
2,456 | cv_model.best_params_ | No | 5 | 2 | Hyperparam_Tuning | find_best_params | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,457 | pd.DataFrame(cv_model.cv_results_) | No | 5 | 41 | Debug | show_table | 6,511,397 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
2,458 | pd.DataFrame(cv_model.cv_results_).sort_values(by='mean_test_score',ascending=False) #[['param_max_depth','mean_test_score']]
#differnt types tried with different max depth | No | 5 | 9 | Data_Transform | sort_values | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,459 | df_cv_results=pd.DataFrame(cv_model.cv_results_).sort_values(by='mean_test_score',ascending=False)
df_cv_results.set_index('param_max_depth')['mean_test_score'].plot.line()
df_cv_results.set_index('param_max_depth')['mean_train_score'].plot.line() | No | 5 | 35 | Visualization | learning_history | 6,511,397 | 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": "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"}] | ["Unit Testing Checker"] | 6 | B |
2,460 | stores_avg_cust = data.groupby(['Store'])[['Customers']].mean().reset_index().astype(int)
test_1 = test.merge(stores_avg_cust,on='Store',how='left')
test.shape,test_1.shape
test_merged = test_1.merge(store,on='Store',how='inner')
test_merged['Open']=test_merged['Open'].fillna(1)
test_merged['Date']=pd.to_datetime(test_... | Yes | 2 | 32 | Data_Transform | merge | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,461 | test_merged | 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,462 | test_pred = model_dt.predict(test_merged[features])
test_pred_inv = np.exp(test_pred) - 1 | No | 5 | 48 | Model_Evaluation | predict_on_test | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,463 | submission = pd.read_csv('/kaggle/input/rossmann-store-sales/sample_submission.csv')
submission_predicted = pd.DataFrame({'Id':test['Id'],'Sales':test_pred_inv})
submission_predicted.to_csv('submission.csv',index=False)
submission_predicted.head() | No | 4 | 25 | Data_Export | save_to_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
2,464 | def ToWeight(y):
w = np.zeros(y.shape, dtype=float)
ind = y != 0
w[ind] = 1./(y[ind]**2)
return w
def rmspe(y, yhat):
w = ToWeight(y)
rmspe = np.sqrt(np.mean( w * (y - yhat)**2 ))
return rmspe
# rmspe(validate_y_inv,validate_y_pred_inv)
validate_y_inv=np.exp(validate_y)-1 #becaused we added... | No | 5 | 49 | Model_Evaluation | compute_test_metric | 6,511,397 | 1 | A | 1 | 2 | 0 | 0 | 10 | 14 | ok | 4 | 3 | [{"detector": "framework_specific", "framework": "NumPy", "name": "Missing Axis Specification", "fix": "Specify axis in array operations.", "benefits": "Improves performance and avoids unexpected behaviour.", "location": "Line 15"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Che... | C | Missing Axis Specification=medium | [{"type": "Missing Axis Specification", "severity": "medium"}] | ["Column Selection Checker", "Missing function docstring"] | 6 | C |
2,465 | data=pd.read_csv('/kaggle/input/rossmann-store-sales/train.csv')
store=pd.read_csv('/kaggle/input/rossmann-store-sales/store.csv') | No | 5 | 45 | Data_Extraction | load_from_csv | 6,511,403 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | 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."] | 9 | A |
2,466 | 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 |
2,467 | import seaborn as sns
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import r2_score,mean_squared_error
import matplotlib.pyplot as plt | No | 5 | 22 | Environment | import_modules | 6,511,403 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
2,468 | data['Date']=pd.to_datetime(data['Date'],format='%Y-%m-%d')
store1 = data[data['Store']==1]
store1.head()
store1.resample('1D',on='Date')['Sales'].sum().plot.line(figsize=(14,4))
plt.show() | No | 4 | 16 | Data_Transform | data_type_conversions | 6,511,403 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | 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"] | 9 | A |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.