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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1,748 | # StateHoliday
# StateHoliday column has values 0 & "0", So, we need to merge values with 0 to "0"
rossmann_df["StateHoliday"].loc[rossmann_df["StateHoliday"] == 0] = "0"
# test_df["StateHoliday"].loc[test_df["StateHoliday"] == 0] = "0"
# Plot
sns.countplot(x='StateHoliday', data=rossmann_df)
# Before
fig, (axis1,ax... | 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 |
1,749 | # .... continue with StateHoliday
# After
rossmann_df["StateHoliday"] = rossmann_df["StateHoliday"].map({0: 0, "0": 0, "a": 1, "b": 1, "c": 1})
test_df["StateHoliday"] = test_df["StateHoliday"].map({0: 0, "0": 0, "a": 1, "b": 1, "c": 1})
fig, (axis1,axis2) = plt.subplots(1,2,figsize=(15,4))
sns.barplot(x='StateH... | 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 |
1,750 | # SchoolHoliday
# Plot
sns.countplot(x='SchoolHoliday', data=rossmann_df)
fig, (axis1,axis2) = plt.subplots(1,2,figsize=(15,4))
sns.barplot(x='SchoolHoliday', y='Sales', data=rossmann_df, ax=axis1)
sns.barplot(x='SchoolHoliday', y='Customers', data=rossmann_df, ax=axis2) | No | 5 | 33 | Visualization | distribution | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,751 | # Sales
fig, (axis1,axis2) = plt.subplots(2,1,figsize=(15,8))
# Plot max, min values, & 2nd, 3rd quartile
sns.boxplot([rossmann_df["Customers"]], whis=np.inf, ax=axis1)
# Plot sales values
# Notice that values with 0 is mostly because the store was closed
rossmann_df["Sales"].plot(kind='hist',bins=70,xlim=(0,15000)... | 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 |
1,752 | # Using store_df
# Merge store_df with average store sales & customers
average_sales_customers = rossmann_df.groupby('Store')[["Sales", "Customers"]].mean()
sales_customers_df = DataFrame({'Store':average_sales_customers.index,
'Sales':average_sales_customers["Sales"], 'Customers': average_sales_... | No | 3 | 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 |
1,753 | # StoreType
# Plot StoreType, & StoreType Vs average sales and customers
sns.countplot(x='StoreType', data=store_df, order=['a','b','c', 'd'])
fig, (axis1,axis2) = plt.subplots(1,2,figsize=(15,4))
sns.barplot(x='StoreType', y='Sales', data=store_df, order=['a','b','c', 'd'],ax=axis1)
sns.barplot(x='StoreType', y='... | No | 5 | 33 | Visualization | distribution | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,754 | # Assortment
# Plot Assortment, & Assortment Vs average sales and customers
sns.countplot(x='Assortment', data=store_df, order=['a','b','c'])
fig, (axis1,axis2) = plt.subplots(1,2,figsize=(15,4))
sns.barplot(x='Assortment', y='Sales', data=store_df, order=['a','b','c'], ax=axis1)
sns.barplot(x='Assortment', y='Cus... | No | 5 | 33 | Visualization | distribution | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,755 | # Promo2
# Plot Promo2, & Promo2 Vs average sales and customers
sns.countplot(x='Promo2', data=store_df)
fig, (axis1,axis2) = plt.subplots(1,2,figsize=(15,4))
sns.barplot(x='Promo2', y='Sales', data=store_df, ax=axis1)
sns.barplot(x='Promo2', y='Customers', data=store_df, ax=axis2) | No | 5 | 33 | Visualization | distribution | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,756 | # CompetitionDistance
# fill NaN values
store_df["CompetitionDistance"].fillna(store_df["CompetitionDistance"].median())
# Plot CompetitionDistance Vs Sales
store_df.plot(kind='scatter',x='CompetitionDistance',y='Sales',figsize=(15,4))
store_df.plot(kind='kde',x='CompetitionDistance',y='Sales',figsize=(15,4))' | Yes | 3 | 33 | Visualization | distribution | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,757 | # What happened to the average sales of a store over time when competition started?
# Example: the average sales for store_id = 6 has dramatically decreased since the competition started
store_id = 6
store_data = rossmann_df[rossmann_df["Store"] == store_id]
average_store_sales = store_data.groupby('Date')["Sales"].m... | No | 4 | 33 | Visualization | distribution | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,758 | # Risk Analysis
# Analyze the risk of a store; Risk(std) Vs Expected(mean)
# .... countiue using store_data
store_average = store_data["Sales"].mean()
store_std = store_data["Sales"].std()
# Plot
plt.scatter(store_average, store_std,alpha = 0.5,s =np.pi*20)
# Get min & max mean and std of store sales
# Remember ... | No | 4 | 33 | Visualization | distribution | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,759 | # .... continue Correlation
# Plot correlation between range of stores
start_store = 1
end_store = 5
fig, (axis1) = plt.subplots(1,1,figsize=(15,5))
# using summation of sales values for each store
sns.heatmap(store_piv[list(range(start_store, end_store+1))].corr(),annot=True,linewidths=2)
# using percent change... | No | 5 | 80 | Visualization | heatmap | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,760 | # Notice that test_df has only year=2015, and months 8 & 9
# drop Year and Month
rossmann_df.drop(["Year", "Month"], axis=1, inplace=True)
test_df.drop(["Year", "Month"], axis=1, inplace=True)
# Create dummy varibales for DayOfWeek
day_dummies_rossmann = pd.get_dummies(rossmann_df['DayOfWeek'], prefix='Day')
day_dum... | No | 3 | 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 |
1,761 | # remove all rows(store,date) that were closed
rossmann_df = rossmann_df[rossmann_df["Open"] != 0]
# drop unnecessary columns, these columns won't be useful in prediction
rossmann_df.drop(["Open","Customers", "Date"], axis=1, inplace=True)' | No | 3 | 10 | Data_Transform | drop_column | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,762 | # save ids of closed stores, because we will assign their sales value to 0 later(see below)
closed_store_ids = test_df["Id"][test_df["Open"] == 0].values
# remove all rows(store,date) that were closed
test_df = test_df[test_df["Open"] != 0]
# drop unnecessary columns, these columns won't be useful in prediction
test_... | Yes | 2 | 14 | Data_Transform | filter | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,763 | # Loop through each store,
# train the model using the data of current store, and predict it's sales values.
rossmann_dic = dict(list(rossmann_df.groupby('Store')))
test_dic = dict(list(test_df.groupby('Store')))
submission = Series()
scores = []
for i in test_dic:
# current store
store = ro... | Yes | 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 |
1,764 | # This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load in
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O... | No | 5 | 23 | Environment | set_options | 242,408 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 9 | null |
1,765 | df = pd.read_csv("../input/train.csv") | No | 5 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,766 | df.head().T | 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 |
1,767 | df.shape | No | 5 | 58 | Debug | show_shape | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,768 | print (df.Store.unique())
print (df.Store.nunique()) | No | 3 | 54 | EDA | count_unique_values | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,769 | df['Year'] = df.Date.map(lambda x: int(x[:4])) | No | 5 | 16 | Data_Transform | data_type_conversions | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,770 | df['Month'] =df.Date.map(lambda x: int(x[5:7])) | No | 5 | 16 | Data_Transform | data_type_conversions | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,771 | df.Promo.unique() | No | 5 | 57 | Debug | show_unique_values | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,772 | df.StateHoliday.unique() | No | 5 | 57 | Debug | show_unique_values | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,773 | df.groupby(['StateHoliday'])['Open'].agg('mean') | No | 5 | 60 | Data_Transform | groupby | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,774 | df.StateHoliday = df['StateHoliday'].map(lambda x: (int)(x in ['a','b','c'])) | No | 5 | 20 | Data_Transform | categorify | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,775 | df.groupby('StateHoliday')['Open'].mean() | No | 5 | 60 | Data_Transform | groupby | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,776 | df.SchoolHoliday.unique() | No | 5 | 57 | Debug | show_unique_values | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,777 | plt.subplot('121')
df['Sales'].hist(bins=100)
plt.subplot('122')
df['Customers'].hist(bins=100) | No | 5 | 33 | Visualization | distribution | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,778 | df.DayOfWeek.unique() | No | 5 | 57 | Debug | show_unique_values | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,779 | df.DayOfWeek[df.Open == 1].value_counts() | No | 3 | 54 | EDA | count_unique_values | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,780 | y = df.groupby('DayOfWeek')['Sales'].sum() | No | 5 | 60 | Data_Transform | groupby | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,781 | sns.barplot(x=np.arange(7)+1, y=y) | No | 5 | 33 | Visualization | distribution | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,782 | xx = df.groupby(['Promo', 'Month'])['Sales'].sum()
xx | No | 3 | 60 | Data_Transform | groupby | 242,408 | 1 | A | 0 | 0 | 0 | 1 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,783 | plt.plot(xx[0], 'g', label='no promo')
plt.plot(xx[1], 'b', label='promo') | No | 5 | 33 | Visualization | distribution | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,784 | yms = df.groupby(['Year', 'Month'])['Sales'].sum() | No | 5 | 60 | Data_Transform | groupby | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,785 | sns.barplot(x=np.arange(12)+1, y=yms[2013].sort_index()) | No | 5 | 33 | Visualization | distribution | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,786 | sns.barplot(x=np.arange(12)+1, y=yms[2014].sort_index()) | No | 5 | 33 | Visualization | distribution | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,787 | sns.barplot(x=np.arange(12)+1, y=yms[2014].sort_index() + yms[2013].sort_index()) | No | 5 | 33 | Visualization | distribution | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,788 | df_store = pd.read_csv("../input/store.csv") | No | 5 | 45 | Data_Extraction | load_from_csv | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/store.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 10"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 9 | A |
1,789 | df_store.head().T | No | 5 | 41 | Debug | show_table | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,790 | df_store.StoreType.unique() | No | 5 | 57 | Debug | show_unique_values | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,791 | df_store.Assortment.unique() | No | 5 | 57 | Debug | show_unique_values | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,792 | from sklearn.preprocessing import OneHotEncoder
from sklearn.preprocessing import LabelEncoder | No | 5 | 22 | Environment | import_modules | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,793 | df_store.fillna(value=0, inplace=True) | No | 5 | 17 | Data_Transform | correct_missing_values | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,794 | le = LabelEncoder() | No | 2 | 4 | Model_Train | choose_model_class | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,795 | df_store.StoreType = le.fit_transform(df_store.StoreType) | No | 5 | 20 | Data_Transform | categorify | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 5 | 5 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | D | Cross Validation Checker=low, Data Leakage Checker=high | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}] | ["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 9 | D |
1,796 | df_store.Assortment = le.fit_transform(df_store.Assortment) | No | 5 | 20 | Data_Transform | categorify | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 5 | 5 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | D | Cross Validation Checker=low, Data Leakage Checker=high | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}] | ["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 9 | D |
1,797 | df_store.PromoInterval.unique() | No | 5 | 57 | Debug | show_unique_values | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,798 | dict1 = {0: 0, 'Jan,Apr,Jul,Oct': 1, 'Feb,May,Aug,Nov': 2, 'Mar,Jun,Sept,Dec': 3} | No | 2 | 23 | Environment | set_options | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,799 | df_store.PromoInterval = df_store.PromoInterval.apply(lambda x: dict1[x], convert_dtype=False) | No | 4 | 8 | Data_Transform | feature_engineering | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,800 | df_store.drop('Store', axis=1, inplace=True) | No | 5 | 10 | Data_Transform | drop_column | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,801 | df = df.join(df_store, on='Store') | No | 5 | 32 | Data_Transform | merge | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,802 | df.PromoInterval = df.PromoInterval.map(lambda x: int(x)) | No | 5 | 16 | Data_Transform | data_type_conversions | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,803 | print (df['StoreType'].value_counts() / len(df)) | No | 5 | 72 | EDA | count_values | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,804 | print (df['Assortment'].value_counts() / len(df)) | No | 5 | 72 | EDA | count_values | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,805 | sales8 = df.groupby(['Store', 'Year', 'Month'])['Sales'].mean()[8] | No | 5 | 60 | Data_Transform | groupby | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,806 | plt.plot(range(31), sales8.values)
plt.plot([df.loc[7].CompetitionOpenSinceMonth+12, df.loc[7].CompetitionOpenSinceMonth+12], [sales8.min(), sales8.max()]) | No | 5 | 33 | Visualization | distribution | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,807 | df_t = df.drop(['Customers', 'Date', 'Year'], axis=1) | No | 5 | 10 | Data_Transform | drop_column | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,808 | df_t.head(10).T | No | 5 | 41 | Debug | show_table | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,809 | df_t = df_t[df_t.Open == 1] | No | 5 | 14 | Data_Transform | filter | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,810 | df_t.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 |
1,811 | df_t.drop('Open', axis=1, inplace=True) | No | 5 | 10 | Data_Transform | drop_column | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,812 | from sklearn.model_selection import train_test_split
from sklearn.model_selection import cross_val_score
from sklearn.model_selection import GridSearchCV
from sklearn.model_selection import validation_curve | No | 5 | 22 | Environment | import_modules | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,813 | b"X_train, X_test, y_train, y_test = train_test_split(df_t.drop('Sales', axis=1).values, df_t.Sales.values,\\\n test_size = 0.2)" | No | 5 | 13 | Data_Transform | split | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,814 | from sklearn.ensemble import RandomForestRegressor | No | 5 | 22 | Environment | import_modules | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 0 | A |
1,815 | params = range(50, 201, 50) | No | 3 | 5 | Hyperparam_Tuning | define_search_space | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,816 | b"scores, tst_scr = validation_curve(RandomForestRegressor(), X_train[:20000],\\\n y_train[:20000], 'n_estimators', params, \\\n cv=5, scoring='r2', verbose=2)" | No | 4 | 6 | Hyperparam_Tuning | train_on_grid | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,817 | scores_mean = scores.mean(axis=1)
scores_std = scores.std(axis=1)
tst_scr_mean = tst_scr.mean(axis=1)
tst_scr_std = tst_scr.std(axis=1)
plt.plot(params, tst_scr_mean)
plt.fill_between(params, tst_scr_mean + tst_scr_std, tst_scr_mean - tst_scr_std, alpha=0.3)
plt.plot(params, scores_mean)
plt.fill_between(params, scores... | No | 3 | 33 | Visualization | distribution | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 8 | ok | 1 | 1 | [{"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": ""}] | A | no applicable ML-specific findings | [] | ["Unit Testing Checker"] | 9 | A |
1,818 | params = range(3, 9) | No | 5 | 5 | Hyperparam_Tuning | define_search_space | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,819 | b"scores, tst_scr = validation_curve(RandomForestRegressor(n_estimators=100), X_train[:20000], \\\n y_train[:20000], 'max_features', params, \\\n cv=3, scoring='r2', verbose=2)" | No | 5 | 6 | Hyperparam_Tuning | train_on_grid | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,820 | params = range(5, 51, 5) | No | 5 | 5 | Hyperparam_Tuning | define_search_space | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,821 | b"scores, tst_scr = validation_curve(RandomForestRegressor(n_estimators=100), X_train[:20000], \\\n y_train[:20000], 'max_depth', params, \\\n cv=3, scoring='r2', verbose=2)" | No | 4 | 6 | Hyperparam_Tuning | train_on_grid | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,822 | model1 = RandomForestRegressor(n_estimators=100, max_depth=20, n_jobs=4, verbose=2) | No | 5 | 4 | Model_Train | choose_model_class | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Randomness Control Checker", "fix": "Set random_state in estimators for reproducibility.", "benefits": "Ensures reproducible results and consistent model behaviour.", "location": "Line 10"}] | B | Randomness Control Checker=low | [{"type": "Randomness Control Checker", "severity": "low"}] | [] | 9 | B |
1,823 | model1.fit(X_train, y_train) | No | 5 | 7 | Model_Train | train_model | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,824 | idx = model1.feature_importances_.argsort()[::-1] | No | 4 | 79 | Visualization | model_coefficients | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,825 | ax = sns.barplot(x=df_t.drop('Sales', axis=1).columns[idx], y=model1.feature_importances_[idx])
_ = plt.setp(ax.get_xticklabels(), rotation=-90) | No | 5 | 79 | Visualization | model_coefficients | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,826 | y_pred = model1.predict(X_test) | No | 5 | 48 | Model_Evaluation | predict_on_test | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,827 | from sklearn.metrics import mean_absolute_error
from sklearn.metrics import r2_score | No | 5 | 22 | Environment | import_modules | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 0 | A |
1,828 | mean_absolute_error(y_test, y_pred) | No | 5 | 49 | Model_Evaluation | compute_test_metric | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,829 | r2_score(y_test, y_pred) | No | 5 | 49 | Model_Evaluation | compute_test_metric | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,830 | df_test = pd.read_csv('../input/test.csv') | No | 5 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,831 | df_test['Year'] = df_test.Date.map(lambda x: int(x[:4])) | No | 5 | 8 | Data_Transform | feature_engineering | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,832 | df_test['Month'] = df_test.Date.map(lambda x: int(x[5:7])) | No | 5 | 8 | Data_Transform | feature_engineering | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,833 | df_test.StateHoliday = df_test['StateHoliday'].map(lambda x: (int)(x in ['a','b','c'])) | No | 4 | 8 | Data_Transform | feature_engineering | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,834 | df_test = df_test.join(df_store, on='Store') | No | 5 | 32 | Data_Transform | merge | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,835 | df_test.drop(['Id', 'Date', 'Year'], axis=1, inplace=True) | No | 5 | 10 | Data_Transform | drop_column | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,836 | df_test.fillna(0, inplace=True) | No | 5 | 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 |
1,837 | df_test.head().T | 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 |
1,838 | df_test.Open.unique() | No | 5 | 57 | Debug | show_unique_values | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,839 | ind_open = df_test.Open == 1
ind_closed = df_test.Open == 0
df_test2 = df_test[ind_open] | No | 5 | 14 | Data_Transform | filter | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,840 | df_test2.drop('Open', axis=1, inplace=True) | No | 5 | 10 | Data_Transform | drop_column | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,841 | df_test2.head().T | No | 5 | 41 | Debug | show_table | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,842 | X_out = df_test2.values | No | 2 | 16 | Data_Transform | data_type_conversions | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,843 | y_out = model1.predict(X_out) | No | 5 | 48 | Model_Evaluation | predict_on_test | 242,408 | 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"] | 9 | A |
1,844 | df_out = pd.DataFrame(np.zeros(len(df_test)), columns=['Sales']) | No | 5 | 12 | Data_Transform | create_dataframe | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,845 | df_out[ind_open] = y_out.reshape(-1,1) | No | 5 | 84 | Other | not_enough_vertices | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,846 | df_out.set_index(np.arange(len(df_out))+1, inplace=True) | No | 5 | 55 | Data_Export | prepare_output | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
1,847 | df_out.index.name = 'Id' | No | 5 | 55 | Data_Export | prepare_output | 242,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.