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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
5,268 | # Classifier
params = {'eta': 0.1,
'max_depth': 8,
'nround': 100,
'subsample': 0.7,
'colsample_bytree': 0.8,
'seed': 1,
'objective': 'multi:softprob',
'eval_metric':'ndcg',
'num_class': 12,
'nthread':3}
num_boost_round = 10
dtrain... | No | 5 | 7 | Model_Train | train_model | 68,482 | 1 | A | 0 | 0 | 0 | 0 | 0 | 13 | 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"}] | [] | 3 | B |
5,269 | # Get feature scores and store in DataFrame
importance = clf1.get_fscore()
importance_df = pd.DataFrame(
sorted(importance.items(), key=operator.itemgetter(1)),
columns=['feature','fscore']
) | No | 5 | 86 | Model_Interpretation | features_selection | 68,482 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | 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"] | 3 | A |
5,270 | # Plot feature importance of top 20
importance_df.iloc[-20:,:].plot(x='feature',y='fscore',kind='barh')
# Only select features w/ a feature score (can also specify min fscore)
# Retrain model with reduced feature set
df_all = df_all[importance_df.feature.values]
X = df_all.iloc[:piv_train,:]
X_test = df_all.iloc[piv_t... | Yes | 4 | 48 | Model_Evaluation | predict_on_test | 68,482 | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | ok | 7 | 6 | [{"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, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Column Selection Checker", "Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker"] | 3 | B |
5,271 | # Taking the 5 classes with highest probabilities
ids = [] #list of ids
cts = [] #list of countries
for i in range(len(id_test)):
idx = id_test[i]
ids += [idx] * 5
cts += le.inverse_transform(np.argsort(y_pred[i])[::-1])[:5].tolist()
# Generate submission
sub = pd.DataFrame(np.column_stack((ids, cts)), c... | Yes | 4 | 25 | Data_Export | save_to_csv | 68,482 | 1 | A | 0 | 1 | 1 | 0 | 0 | 8 | ok | 6 | 5 | [{"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... | B | No random seed setting detected=low | [{"type": "No random seed setting detected", "severity": "low"}] | ["Column Selection Checker", "Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker"] | 3 | B |
5,272 | # 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 | 4 | 88 | Debug | list_files | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 15"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 0 | A |
5,273 | data_train = pd.read_csv('../input/train_users_2.csv',parse_dates=['timestamp_first_active','date_account_created','date_first_booking'])
data_test = pd.read_csv('../input/test_users.csv',parse_dates=['timestamp_first_active','date_account_created','date_first_booking'])
data_train.head() | No | 4 | 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 |
5,274 | data_test.head()
# Note that 'date_first_booking' is completely missing in test data | 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 |
5,275 | # Note incorrect minimum and maximum age values
data_train.describe() | No | 5 | 40 | Debug | show_table_attributes | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,276 | print ('Number of lines in the training data are,',data_train.shape[0]) | 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 |
5,277 | countries = pd.read_csv('../input/countries.csv')
countries.head(10) | 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 |
5,278 | data_all.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 |
5,279 | print(data_all.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 |
5,280 | # Splitting date time data for date account created
data_all['dac_year'] = data_all.date_account_created.dt.year
data_all['dac_month'] = data_all.date_account_created.dt.month
data_all['dac_day'] = data_all.date_account_created.dt.day
# Splitting date time data for time first active
data_all['tfa_year'] = data_all.tim... | No | 4 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 8 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,281 | data_all.describe() | No | 5 | 40 | Debug | show_table_attributes | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,282 | data_all.gender.value_counts(dropna=False).plot(kind='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 |
5,283 | data_all.dac_year.value_counts(sort=False).plot(kind='bar', title='Number of User Accounts Created in a Year') | 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 |
5,284 | data_all.tfa_year.value_counts(sort=False).plot(kind='bar', title = 'Number of Users by First Active Year') | 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 |
5,285 | data_train.country_destination.value_counts(normalize=True).plot(kind='bar',title='Countries Visited by AirBNB Users') | 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 |
5,286 | data_all.language.value_counts(sort=True) | 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 |
5,287 | #Note no null data now left
print(data_all.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 |
5,288 | b"# Import sklearn.preprocessing.StandardScaler\n#from sklearn.preprocessing import MinMaxScaler\n\n# Initialize a MinMax scaler, then apply it to the numerical features\n#scaler = MinMaxScaler()\n#numerical = ['age','dac_year','dac_month','dac_day','tfa_year','tfa_month','tfa_day']\n#data_all[numerical] = scaler.fit_t... | No | 5 | 20 | Data_Transform | categorify | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,289 | #Taking the 5 classes with highest probabilities
ids = [] #list of ids
cts = [] #list of countries
for i in range(len(test_ids)):
idx = test_ids[i]
ids += [idx] * 5
cts += labler.inverse_transform(np.argsort(y_pred[i])[::-1])[:5].tolist()
#Generate submission
sub = pd.DataFrame(np.column_stack((ids, cts)... | No | 5 | 25 | Data_Export | save_to_csv | null | 1 | A | 0 | 1 | 1 | 0 | 0 | 8 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,290 | import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import matplotlib.pyplot as plt
import seaborn as sns
import os
for dirname, _, filenames in os.walk('/kaggle/input'):
for filename in filenames:
print(os.path.join(dirname, filename)) | No | 5 | 88 | Debug | list_files | null | 1 | A | 0 | 2 | 3 | 0 | 0 | 8 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: /kaggle/input. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 7"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 0 | A |
5,291 | # Load the data into DataFrames
train_users = pd.read_csv('../input/airbnb-recruiting-new-user-bookings/train_users_2.csv')
test_users = pd.read_csv('../input/airbnb-recruiting-new-user-bookings/test_users.csv') | No | 5 | 45 | Data_Extraction | load_from_csv | 5,553,433 | 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."] | 4 | A |
5,292 | print("Number of users in training set =", train_users.shape[0] )
print("Number of users in test set =",test_users.shape[0]) | No | 5 | 58 | Debug | show_shape | 5,553,433 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 4 | A |
5,293 | train_users.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 |
5,294 | train_users.describe(include = 'all') | No | 5 | 40 | Debug | show_table_attributes | 5,553,433 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}] | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | [] | 4 | B |
5,295 | test_users.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 |
5,296 | test_users.describe(include = 'all') | No | 5 | 40 | Debug | show_table_attributes | 5,553,433 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 4 | A |
5,297 | labels = train_users['country_destination'].values
train_users = train_users.drop(['country_destination', 'date_first_booking'], axis=1)
test_users = test_users.drop(['date_first_booking'], axis=1)
id_test = test_users['id']
# Merge train and test users
all_users = pd.concat((train_users, test_users), axis=0, ignore_i... | No | 4 | 10 | Data_Transform | drop_column | 5,553,433 | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "Assign operations to a new DataFrame variable.", "benefits": "Prevents data loss and improves code clarity.", "location": "Line 14"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker"... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Column Selection Checker", "InPlace Checker"] | 4 | B |
5,298 | from datetime import datetime
all_users['date_account_created'] = pd.to_datetime(all_users['date_account_created'])
all_users['timestamp_first_active'] = pd.to_datetime((all_users.timestamp_first_active // 1000000), format='%Y%m%d')
all_users['date_account_created'] = [datetime.timestamp(d) for d in all_users['date_ac... | No | 5 | 16 | Data_Transform | data_type_conversions | 5,553,433 | 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"] | 4 | A |
5,299 | all_users.age.describe() | No | 5 | 40 | Debug | show_table_attributes | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,300 | sns.distplot(all_users.age.dropna())
plt.xlabel('Age') | No | 5 | 33 | Visualization | distribution | 5,553,433 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 4 | A |
5,301 | sns.distplot(all_users.age.loc[all_users['age'] < 70].dropna())
plt.xlabel('Age') | No | 5 | 33 | Visualization | distribution | 5,553,433 | 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"] | 4 | A |
5,302 | all_users['age'] = np.where(all_users['age']<=14, 14, all_users['age'])
all_users['age'] = np.where(all_users['age']>=70, 70, all_users['age'])
all_users['age'] = all_users['age'].fillna(all_users['age'].dropna().values.mean())
all_users['age'].describe() | No | 4 | 8 | Data_Transform | feature_engineering | 5,553,433 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 4 | A |
5,303 | all_users['age'].values.mean() | No | 5 | 40 | Debug | show_table_attributes | 5,553,433 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 4 | A |
5,304 | categorical_features = [
'affiliate_channel',
'affiliate_provider',
'first_affiliate_tracked',
'first_browser',
'first_device_type',
'gender',
'language',
'signup_app',
'signup_method'
]
# one-hot-encoding
for categorical_feature in categorical_features:
all_users_dummies = pd.g... | No | 4 | 20 | Data_Transform | categorify | 5,553,433 | 1 | A | 0 | 1 | 1 | 0 | 0 | 15 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 4 | A |
5,305 | all_users.head() | No | 5 | 41 | Debug | show_table | 5,553,433 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 4 | A |
5,306 | from sklearn.preprocessing import LabelEncoder
train_users_n = train_users.shape[0]
X_train = all_users.values[:train_users_n]
le = LabelEncoder()
y_train = le.fit_transform(labels)
X_test = all_users.values[train_users_n:] | No | 5 | 20 | Data_Transform | categorify | 5,553,433 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 6 | 6 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Pipeline Checker", "fix": "Use Pipelines for all scikit-learn estimators.", "benefits": "Prevents data leakage and ensures correct model evaluation.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross V... | D | Cross Validation Checker=low, Data Leakage Checker=high, Pipeline Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "Pipeline Checker", "severity": "low"}] | ["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 4 | D |
5,307 | # 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 | 4 | 88 | Debug | list_files | 5,936,225 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 6 | null |
5,308 | # Read The Files
train = pd.read_csv('/kaggle/input/airbnb-recruiting-new-user-bookings/train_users_2.csv')
age = pd.read_csv('/kaggle/input/airbnb-recruiting-new-user-bookings/age_gender_bkts.csv')
countries = pd.read_csv('/kaggle/input/airbnb-recruiting-new-user-bookings/countries.csv')
sessions = pd.read_csv('/kaggl... | No | 5 | 45 | Data_Extraction | load_from_csv | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 6 | 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."] | 6 | A |
5,309 | print(train.describe())
print(train.info()) | No | 5 | 40 | Debug | show_table_attributes | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | [] | 6 | B |
5,310 | print(test.describe())
print(test.info()) | No | 5 | 40 | Debug | show_table_attributes | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,311 | #Join the test & train data to fix them both at the same time
df = train.append(test, ignore_index = True, sort = True)
print(df.info())
| No | 4 | 11 | Data_Transform | concatenate | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}] | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | [] | 6 | B |
5,312 | #Plotting distribution of the data
for x in cat:
sns.countplot(x=x, data=df,palette='RdBu')
plt.ylabel('Number of users')
plt.title('Users '+ x + ' Distribution')
plt.xticks(rotation='vertical')
plt.show()
plt.savefig('plot'+str(x)+'.png')
| No | 5 | 33 | Visualization | distribution | 5,936,225 | 1 | A | 0 | 1 | 1 | 0 | 0 | 7 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,314 | # Investigate The Time Users Spend Between Being First Active and Actually Making A reservation
df['timestamp_first_active'] = pd.to_datetime((df.timestamp_first_active // 1000000), format='%Y%m%d')
df['date_first_booking'] = pd.to_datetime(df['date_first_booking'])
df['time_to_booking']= df['date_first_booking'] - df... | No | 4 | 16 | Data_Transform | data_type_conversions | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,315 | # Investigate Month and Year Of Users Bookings And Signing up to see most active years/months
df['month_booking']= df.date_first_booking.dt.month
df['year_booking']= df.date_first_booking.dt.year
df['date_account_created'] = pd.to_datetime(df['date_account_created'])
df['month_create']=df.date_account_created.dt.month... | No | 4 | 16 | Data_Transform | data_type_conversions | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,316 | for x in ['month_booking','year_booking','month_create','year_create'] :
sns.countplot(x=x,data=df)
plt.xticks(rotation='vertical')
plt.show()
plt.savefig('plot'+str(x)+'.png')
| No | 5 | 33 | Visualization | distribution | 5,936,225 | 1 | A | 0 | 1 | 1 | 0 | 0 | 5 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,317 | df.date_account_created.value_counts().plot(kind='line')
plt.xlabel('Date')
plt.title('New Accounts Created Over Time')
plt.xticks(rotation='vertical')
plt.show()
plt.savefig('plot New Accounts Created Over Time.png')
| No | 5 | 75 | Visualization | time_series | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,318 | new2 = sessions.groupby('user_id').count()
print(new2.describe()) | No | 4 | 60 | Data_Transform | groupby | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,319 | #Drop Year Column because it's the same for all entries (2015)
age = age.drop('year',axis = 1) | No | 5 | 10 | Data_Transform | drop_column | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,320 | # Group and Plot Age Data
g = age.groupby(['age_bucket','gender']).sum().reset_index().sort_values('population_in_thousands')
sns.set_context('talk')
sns.barplot(x='age_bucket',y = 'population_in_thousands',data=g)
plt.xticks(rotation='vertical')
plt.title('Different Age Groups')
plt.show()
plt.savefig('plot Different... | No | 5 | 33 | Visualization | distribution | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,321 | # The Age Data
#set any value bigger than 130 or lower than 18 to be nan
df.age[df.age > 110] = np.nan
df.age[df.age < 18] = np.nan
#Replace Missing age data with the mean
df.loc[df['age'].isnull(),'age'] = df.age.median() | No | 5 | 17 | Data_Transform | correct_missing_values | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,322 | #look at age distribution
sns.distplot(df.age)
plt.title('Age Distribution Of Users')
plt.show() | No | 5 | 33 | Visualization | distribution | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,323 | #Extract the remaining date information
df['month_active']= df.timestamp_first_active.dt.month
df['year_active']= df.timestamp_first_active.dt.year | No | 5 | 8 | Data_Transform | feature_engineering | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,324 | #Drop unnecessary columns after the extraction of useful data
df1 = df.drop(['date_first_booking','time_to_booking','month_booking','year_booking','date_account_created',
'timestamp_first_active','timestamp_first_active','country_destination','id'],axis=1) | No | 5 | 10 | Data_Transform | drop_column | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,325 | # Handle categorical Columns
ndf = pd.get_dummies(df1,columns=['affiliate_channel','affiliate_provider','first_affiliate_tracked',
'first_browser','first_device_type','language','signup_app','year_active'
,'signup_flow','signup_method','month_create','year... | No | 5 | 20 | Data_Transform | categorify | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,326 | ndf.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 |
5,327 | from sklearn.neighbors import KNeighborsClassifier
neigh = KNeighborsClassifier(n_neighbors=5)
neigh.fit(xtrn1,ytrn1) | No | 5 | 7 | Model_Train | train_model | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 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"] | 6 | B |
5,328 | yprd = neigh.predict(xtst1) | No | 5 | 48 | Model_Evaluation | predict_on_test | 5,936,225 | 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"] | 6 | A |
5,329 | yprd1 = pd.DataFrame(yprd)
yprd1.index = ytst1.index
xtfinal = pd.concat([yprd1,xtst1],axis=1) | Yes | 5 | 11 | Data_Transform | concatenate | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,330 | xtfinal.rename(columns={0:'gender'},inplace = True ) | No | 5 | 61 | Data_Transform | rename_columns | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,331 | xtrain_final = pd.concat([ytrn1,xtrn1],axis=1) | No | 5 | 11 | Data_Transform | concatenate | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,332 | xfinal = xtrain_final.append(xtfinal)
xfinal = pd.concat([xfinal,df.country_destination],axis=1) | No | 5 | 11 | Data_Transform | concatenate | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}] | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | [] | 6 | B |
5,333 | xfinal.head() | No | 5 | 41 | Debug | show_table | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,334 | xy = pd.get_dummies(xfinal,columns=['gender'],drop_first =True,dtype='float16')
| No | 5 | 20 | Data_Transform | categorify | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,336 | from sklearn.preprocessing import StandardScaler
from sklearn.utils.class_weight import compute_class_weight
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import GridSearchCV
from sklearn.naive_bayes import BernoulliNB | No | 5 | 22 | Environment | import_modules | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,337 | sc = StandardScaler()
x_train = sc.fit_transform(x_train)
x_test = sc.transform(x_test) | No | 5 | 18 | Data_Transform | normalization | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,338 | from xgboost.sklearn import XGBClassifier
clf = XGBClassifier(max_depth=6, learning_rate=0.3, n_estimators=25,
objective='multi:softprob', subsample=0.5, colsample_bytree=0.5, seed=0)
clf.fit(x_train,y_train) | No | 5 | 7 | Model_Train | train_model | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | 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"] | 6 | B |
5,339 | y_pred = clf.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 |
5,341 | submission = pd.DataFrame({'id':test['id'],'country':y_pred})
submission.head()
filename = 'Airbnb Predictions 1_1.csv'
submission.to_csv(filename,index=False) | No | 4 | 25 | Data_Export | save_to_csv | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,342 | df = train.append(test, ignore_index = True, sort = True)
| No | 5 | 11 | Data_Transform | concatenate | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}] | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | [] | 6 | B |
5,343 | df.age[df.age > 110] = np.nan
df.age[df.age < 18] = np.nan
#Replace Missing age data with the mean
df.loc[df['age'].isnull(),'age'] = -1 | No | 5 | 17 | Data_Transform | correct_missing_values | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,344 | # Extracting Age Data As before
df['timestamp_first_active'] = pd.to_datetime((df.timestamp_first_active // 1000000), format='%Y%m%d')
df['day_active'] = df.timestamp_first_active.dt.day
df['month_active']= df.timestamp_first_active.dt.month
df['year_active']= df.timestamp_first_active.dt.year
df['date_account_create... | No | 5 | 8 | Data_Transform | feature_engineering | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 8 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,345 | ndf2 = df.drop(['date_first_booking','date_account_created',
'timestamp_first_active','timestamp_first_active','id'],axis = 1 ) | No | 5 | 10 | Data_Transform | drop_column | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,346 | xy2 = pd.get_dummies(ndf2,columns=['affiliate_channel','affiliate_provider','first_affiliate_tracked',
'first_browser','first_device_type','gender','language','signup_app','signup_flow'
,'signup_method']) | No | 5 | 20 | Data_Transform | categorify | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,347 | from xgboost.sklearn import XGBClassifier
clf = XGBClassifier(max_depth=6, learning_rate=0.2, n_estimators=50,class_weight=class_weight ,
objective='multi:softprob', subsample=0.5, colsample_bytree=0.5, seed=0)
clf.fit(x_train,y_train) | No | 5 | 7 | Model_Train | train_model | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | 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"] | 6 | B |
5,348 | submission = pd.DataFrame({'id':test['id'],'country':y_pred})
submission.head()
filename = 'Airbnb Predictions 1_2.csv'
submission.to_csv(filename,index=False) | No | 4 | 25 | Data_Export | save_to_csv | 5,936,225 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
5,349 | train = pd.merge(train, countries, how="left", left_on=["country_destination"], right_on=["country_destination"]) | No | 5 | 32 | Data_Transform | merge | 25,814 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
5,350 | x_train = train.drop("country_destination", axis=1)
y_train = train["country_destination"]
x_test = test.copy() | Yes | 5 | 21 | Data_Transform | prepare_x_and_y | 25,814 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | 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 |
5,351 | import numpy as np
from sklearn import preprocessing
for f in x_train.columns:
if x_train[f].dtype=='object':
lbl = preprocessing.LabelEncoder()
if f not in x_test.columns:
lbl.fit(np.unique(list(x_train[f].values)))
x_train[f] = lbl.transform(list(x_train[f].values))
... | Yes | 5 | 20 | Data_Transform | categorify | 25,814 | 1 | A | 0 | 3 | 7 | 0 | 0 | 12 | ok | 17 | 9 | [{"detector": "framework_specific", "framework": "Pandas", "name": "DataFrame Conversion Checker", "fix": "Use .to_numpy() instead of .values.", "benefits": "Ensures future compatibility and avoids unexpected behaviour.", "location": "Line 14"}, {"detector": "framework_specific", "framework": "Pandas", "name": "DataFra... | D | Cross Validation Checker=low, Data Leakage Checker=high, No random seed setting detected=low, Pipeline Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Pipeline Checker", "severity": "low"}] | ["Column Selection Checker", "DataFrame Conversion Checker", "Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 5 | D |
5,352 | for col in countries.columns:
if col == 'country_destination':
continue
del(x_train[col]) | No | 4 | 10 | Data_Transform | drop_column | 25,814 | 1 | A | 0 | 2 | 3 | 0 | 0 | 4 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 5 | A |
5,353 | from sklearn.preprocessing import Imputer
imp = Imputer(missing_values='NaN', strategy='mean', axis=0)
x_train_nonan = imp.fit_transform(x_train)
x_test_nonan = imp.fit_transform(x_test) | Yes | 5 | 17 | Data_Transform | correct_missing_values | 25,814 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 9 | 7 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | D | Cross Validation Checker=low, Data Leakage Checker=high, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 5 | D |
5,354 | from sklearn.tree import DecisionTreeClassifier
model = DecisionTreeClassifier()
model.fit(x_train_nonan, y_train) | Yes | 5 | 7 | Model_Train | train_model | 25,814 | 3 | C | 2 | 0 | 0 | 0 | 10 | 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 | C |
5,355 | y_test = model.predict(x_test_nonan) | No | 5 | 48 | Model_Evaluation | predict_on_test | 25,814 | 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 |
5,356 | submission = pd.DataFrame()
submission["id"] = test["id"]
submission["country"] = y_test
submission.to_csv('airbnb.csv', index=False)' | Yes | 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 |
5,357 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.metrics import accuracy_score
from sklearn.naive_bayes import GaussianNB
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder | No | 5 | 22 | Environment | import_modules | 7,972,348 | 1 | A | 0 | 0 | 0 | 0 | 0 | 8 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker"] | 9 | A |
5,358 | train = pd.read_csv('/kaggle/input/airbnb-recruiting-new-user-bookings/train_users_2.csv.zip')
test = pd.read_csv('/kaggle/input/airbnb-recruiting-new-user-bookings/test_users.csv.zip')
age_gender = pd.read_csv('/kaggle/input/airbnb-recruiting-new-user-bookings/age_gender_bkts.csv.zip')
sessions = pd.read_csv('/kaggle/... | No | 5 | 45 | Data_Extraction | load_from_csv | 7,972,348 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 6 | 3 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}, {"detector": "general_ml", "framework": "Genera... | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker", "Hardcoded file path", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness."] | 9 | A |
5,359 | X_train = train.drop(['date_first_booking', 'country_destination'], axis=1)
X_test = test.drop(['date_first_booking'], axis=1) | No | 5 | 10 | Data_Transform | drop_column | 7,972,348 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | 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": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Dependent Threshold Checker"] | 9 | B |
5,360 | y_des = train['country_destination'].values
X=pd.concat((X_train, X_test), axis=0, ignore_index=True)
X.shape | Yes | 4 | 11 | Data_Transform | concatenate | 7,972,348 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | 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": "Dependent Th... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Dependent Threshold Checker"] | 9 | A |
5,361 | X.fillna(method='pad').head() | No | 4 | 17 | Data_Transform | correct_missing_values | 7,972,348 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker"] | 9 | A |
5,362 | X.loc[X.age > 90, 'age'] = -1
X.loc[X.age < 13, 'age'] = -1
X['age'].describe() | Yes | 4 | 8 | Data_Transform | feature_engineering | 7,972,348 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | 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": "Dependent Th... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Dependent Threshold Checker"] | 9 | A |
5,363 | X.loc[X.age.isnull(), 'age']=X.age.mean() | No | 5 | 17 | Data_Transform | correct_missing_values | 7,972,348 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker"] | 9 | A |
5,364 | dac = np.vstack(
X.date_account_created.astype(str).apply(
lambda x: list(map(int, x.split('-')))
).values
)
X['dac_year'] = dac[:, 0]
X['dac_month'] = dac[:, 1]
X['dac_day'] = dac[:, 2]
X = X.drop(['date_account_created'], axis=1)
X.head() | Yes | 4 | 8 | Data_Transform | feature_engineering | 7,972,348 | 1 | A | 0 | 0 | 0 | 0 | 0 | 10 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "Pandas", "name": "DataFrame Conversion Checker", "fix": "Use .to_numpy() instead of .values.", "benefits": "Ensures future compatibility and avoids unexpected behaviour.", "location": "Line 10"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column ... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "DataFrame Conversion Checker", "Dependent Threshold Checker"] | 9 | A |
5,365 | df = sessions.user_id.value_counts()
print(df.shape)
print(df.head()) | Yes | 3 | 72 | EDA | count_values | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,366 | df = df.to_frame()
df = df.rename(columns = {'user_id' : 'session_count'})
df['id'] = df.index
df.head() | Yes | 4 | 61 | Data_Transform | rename_columns | 7,972,348 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | 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": "Dependent Th... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Dependent Threshold Checker"] | 9 | A |
5,367 | X = pd.merge(X, df, how = 'left', on = ['id'])
X.session_count.fillna(-1, inplace = True)
X.session_count = X.session_count.astype(int) | Yes | 3 | 32 | Data_Transform | merge | 7,972,348 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "Assign operations to a new DataFrame variable.", "benefits": "Prevents data loss and improves code clarity.", "location": "Line 11"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold ... | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker", "InPlace Checker"] | 9 | A |
5,368 | tfa = np.vstack(
X.timestamp_first_active.astype(str).apply(
lambda x: list(map(int, [x[:4], x[4:6], x[6:8],
x[8:10], x[10:12],
x[12:14]]))
).values
)
X['tfa_year'] = tfa[:, 0]
X['tfa_month'] = tfa[:, 1]
X['tfa_day'] = tfa[:, 2]
X = X.dro... | Yes | 4 | 8 | Data_Transform | feature_engineering | 7,972,348 | 1 | A | 0 | 0 | 0 | 0 | 0 | 11 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "Pandas", "name": "DataFrame Conversion Checker", "fix": "Use .to_numpy() instead of .values.", "benefits": "Ensures future compatibility and avoids unexpected behaviour.", "location": "Line 10"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column ... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "DataFrame Conversion Checker", "Dependent Threshold Checker"] | 9 | A |
5,369 | # age distributions
train['corrected_age']=train['age'].apply(lambda x : 36 if x>90 or x<10 else x)
sns.distplot(train.corrected_age.dropna()) | Yes | 5 | 33 | Visualization | distribution | 7,972,348 | 1 | A | 0 | 2 | 2 | 0 | 0 | 2 | ok | 5 | 5 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Column Selection Checker", "Dependent Threshold Checker"] | 9 | B |
5,370 | # percentage of users using different signup_method
signup_method = X.signup_method.value_counts(dropna = False) / len(X) * 100
signup_method.plot('bar', rot = 0)
plt.xlabel('Sign up method')
plt.ylabel('Percentage of signup_method') | Yes | 5 | 33 | Visualization | distribution | 7,972,348 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker"] | 9 | A |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.