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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4,952 | train_df = pd.read_csv('../input/bike-sharing-demand/train.csv')
test_df = pd.read_csv('../input/bike-sharing-demand/test.csv') | No | 5 | 45 | Data_Extraction | load_from_csv | 14,071,625 | 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."] | 5 | A |
4,953 | print(train_df.shape)
print(test_df.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 |
4,954 | train_df['datetime'] = pd.to_datetime(train_df['datetime'])
test_df['datetime'] = pd.to_datetime(test_df['datetime']) | No | 5 | 16 | Data_Transform | data_type_conversions | 14,071,625 | 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 |
4,955 | train_df['year'] = train_df['datetime'].apply(lambda x: x.year)
train_df['month'] = train_df['datetime'].apply(lambda x: x.month)
train_df['day'] = train_df['datetime'].apply(lambda x: x.day)
train_df['hour'] = train_df['datetime'].apply(lambda x: x.hour)
test_df['year'] = test_df['datetime'].apply(lambda x: x.year)
t... | No | 5 | 8 | Data_Transform | feature_engineering | 14,071,625 | 1 | A | 0 | 0 | 0 | 0 | 0 | 8 | ok | 4 | 4 | [{"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"] | 5 | B |
4,956 | train_df = train_df.drop(['datetime', 'casual', 'registered'], axis=1)
test_df = test_df.drop(['datetime'], axis=1) | No | 5 | 10 | Data_Transform | drop_column | 14,071,625 | 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"}] | [] | 5 | B |
4,957 | def rmsle(y, pred):
log_y = np.log1p(y)
log_pred = np.log1p(pred)
squared_error = (log_y - log_pred)**2
rmsle = np.sqrt(np.mean(squared_error))
return rmsle | No | 5 | 84 | Other | not_enough_vertices | null | 1 | A | 0 | 1 | 0 | 0 | 0 | 6 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,958 | sns.distplot(train_df['count']) | 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 |
4,959 | sns.distplot(np.log1p(train_df['count'])) | 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 |
4,960 | train_df['count'] = np.log1p(train_df['count']) | No | 5 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,961 | from sklearn.model_selection import train_test_split, GridSearchCV
from sklearn.linear_model import LinearRegression, Ridge, Lasso
X_train, X_test, y_train, y_test = train_test_split(train_df.drop(['count'], axis=1), train_df['count'], test_size=0.3) | Yes | 4 | 13 | Data_Transform | split | 14,071,625 | 2 | B | 1 | 0 | 0 | 0 | 5 | 3 | 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, Randomness Control Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Randomness Control Checker", "severity": "low"}] | ["Column Selection Checker"] | 5 | B |
4,962 | lr_reg = LinearRegression()
lr_reg.fit(X_train, y_train)
pred = lr_reg.predict(X_test)
y_test_exp = np.expm1(y_test)
pred_exp = np.expm1(pred)
print('RMSLE:', rmsle(y_test_exp, pred_exp)) | Yes | 4 | 28 | Model_Train | compute_train_metric | 14,071,625 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 8 | 7 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 5 | B |
4,963 | coef = pd.Series(lr_reg.coef_, index=X_train.columns)
coef_sort = coef.sort_values(ascending=False)
sns.barplot(x=coef_sort.values, y=coef_sort.index) | No | 5 | 79 | Visualization | model_coefficients | 14,071,625 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
4,964 | train_df = pd.get_dummies(train_df, columns=['year', 'month', 'day', 'hour', 'holiday', 'workingday', 'season', 'weather'])
test_df = pd.get_dummies(test_df, columns=['year', 'month', 'day', 'hour', 'holiday', 'workingday', 'season', 'weather']) | No | 5 | 20 | Data_Transform | categorify | 14,071,625 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
4,965 | train_df, test_df = train_df.align(test_df, join='left', axis=1)
test_df = test_df.drop(['count'], axis=1) | Yes | 4 | 10 | Data_Transform | drop_column | 14,071,625 | 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"}] | [] | 5 | B |
4,966 | X_train, X_test, y_train, y_test = train_test_split(train_df.drop(['count'], axis=1), train_df['count'], test_size=0.3) | No | 5 | 13 | Data_Transform | split | 14,071,625 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | 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, Randomness Control Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Randomness Control Checker", "severity": "low"}] | ["Column Selection Checker"] | 5 | B |
4,967 | lr_reg = LinearRegression()
lr_reg.fit(X_train, y_train)
pred = lr_reg.predict(X_test)
y_test_exp = np.expm1(y_test)
pred_exp = np.expm1(pred)
print('LinearRegression RMSLE:', rmsle(y_test_exp, pred_exp)) | No | 3 | 28 | Model_Train | compute_train_metric | 14,071,625 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 8 | 7 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 5 | B |
4,968 | ridge_reg = Ridge(alpha=10)
ridge_reg.fit(X_train, y_train)
pred = ridge_reg.predict(X_test)
y_test_exp = np.expm1(y_test)
pred_exp = np.expm1(pred)
print('Ridge RMSLE:', rmsle(y_test_exp, pred_exp)) | No | 4 | 4 | Model_Train | choose_model_class | 14,071,625 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 8 | 7 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 5 | B |
4,969 | lasso_reg = Lasso(alpha=0.01)
lasso_reg.fit(X_train, y_train)
pred = lasso_reg.predict(X_test)
y_test_exp = np.expm1(y_test)
pred_exp = np.expm1(pred)
print('Lasso RMSLE:', rmsle(y_test_exp, pred_exp)) | No | 3 | 28 | Model_Train | compute_train_metric | 14,071,625 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 8 | 7 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 5 | B |
4,970 | coef = pd.Series(lr_reg.coef_, index=X_train.columns)
coef_sort = coef.sort_values(ascending=False)[:25]
sns.barplot(x=coef_sort.values, y=coef_sort.index) | No | 5 | 79 | Visualization | model_coefficients | 14,071,625 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
4,971 | from sklearn.ensemble import RandomForestRegressor, GradientBoostingRegressor
from xgboost import XGBRegressor
from lightgbm import LGBMRegressor | No | 5 | 22 | Environment | import_modules | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 0 | A |
4,972 | rf_reg = RandomForestRegressor(n_estimators=500)
rf_reg.fit(X_train, y_train)
pred = rf_reg.predict(X_test)
y_test_exp = np.expm1(y_test)
pred_exp = np.expm1(pred)
print('RandomForestRegressor RMSLE:', rmsle(y_test_exp, pred_exp)) | Yes | 3 | 49 | Model_Evaluation | compute_test_metric | 14,071,625 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 10 | 8 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low, Randomness Control Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Randomness Control Checker", "severity": "low"}] | ["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 | B |
4,973 | gbm_reg = GradientBoostingRegressor(n_estimators=500)
gbm_reg.fit(X_train, y_train)
pred = gbm_reg.predict(X_test)
y_test_exp = np.expm1(y_test)
pred_exp = np.expm1(pred)
print('GradientBoostingRegressor RMSLE:', rmsle(y_test_exp, pred_exp)) | Yes | 3 | 49 | Model_Evaluation | compute_test_metric | 14,071,625 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 9 | 7 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 5 | B |
4,974 | xgb_reg = XGBRegressor(n_estimators=500)
xgb_reg.fit(X_train, y_train)
pred = xgb_reg.predict(X_test)
y_test_exp = np.expm1(y_test)
pred_exp = np.expm1(pred)
print('XGBRegressor RMSLE:', rmsle(y_test_exp, pred_exp)) | Yes | 3 | 49 | Model_Evaluation | compute_test_metric | 14,071,625 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 8 | 7 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 5 | B |
4,975 | lgbm_reg = LGBMRegressor(n_estimators=500)
lgbm_reg.fit(X_train, y_train)
pred = lgbm_reg.predict(X_test)
y_test_exp = np.expm1(y_test)
pred_exp = np.expm1(pred)
print('LGBMRegressor RMSLE:', rmsle(y_test_exp, pred_exp)) | No | 4 | 7 | Model_Train | train_model | 14,071,625 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 8 | 7 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 5 | B |
4,976 | X_train = train_df.drop(['count'], axis=1)
y_train = train_df['count']
X_test = test_df | No | 5 | 21 | Data_Transform | prepare_x_and_y | 14,071,625 | 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 |
4,977 | print(X_train.shape)
print(y_train.shape)
print(X_test.shape) | No | 5 | 58 | Debug | show_shape | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,978 | lgbm_reg = LGBMRegressor(n_estimators=500)
lgbm_reg.fit(X_train, y_train)
pred = lgbm_reg.predict(X_test)
pred_exp = np.expm1(pred) | Yes | 4 | 48 | Model_Evaluation | predict_on_test | 14,071,625 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 8 | 7 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 5 | B |
4,979 | submission = pd.read_csv('../input/bike-sharing-demand/sampleSubmission.csv')
submission | No | 5 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | 0 | 0 | 1 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,980 | submission.loc[:, 'count'] = pred_exp
submission | No | 5 | 55 | Data_Export | prepare_output | null | 1 | A | 0 | 0 | 0 | 1 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,981 | b"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport os\n\ndef nl():\n print('\\n')\n\nfor f in os.listdir('../input'):\n print(f.ljust(30) + str(round(os.path.getsize('../input/' + f) / 1000000, 2)) + 'MB')" | No | 5 | 88 | Debug | list_files | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,982 | target = df_train['Demanda_uni_equil'].tolist()
def label_plot(title, x, y):
plt.title(title)
plt.xlabel(x)
plt.ylabel(y)
plt.hist(target, bins=200, color='blue')
label_plot('Distribution of target values', 'Demanda_uni_equil', 'Count')
plt.show()
print("Looks like we have some pretty big outliers, let's... | Yes | 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 |
4,983 | import numpy as np
import pandas as pd
import math
colum_target=pd.read_csv("../input/train.csv",usecols=['Demanda_uni_equil'])
m=colum_target['Demanda_uni_equil'].tolist()
#print(m)
#m=np.mean(np.linalg.logm(colum_target['Demanda_uni_equil'].value+1))
#m=np.exp(math.log(+1).mean())
#mm=colum_target['m'].mean()
#print(... | Yes | 4 | 22 | Environment | import_modules | null | 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": "general_ml", "framework": "General ML", "name": "Hardcoded file path d... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Hardcoded file path"] | 0 | A |
4,984 | x=np.exp(np.mean(np.log(np.array(m)+1)))-1
print (x)
result_logmean=pd.read_csv("../input/test.csv",usecols=['id'])
result_logmean['Demanda_uni_equil']=x
result_logmean.to_csv('result_logmean.csv',index=False)' | Yes | 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 |
4,985 | import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
train_data=pd.read_csv("../input/train.csv",usecols=['Producto_ID','Demanda_uni_equil'])
' | Yes | 5 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
4,986 | train_data['log_Dem']=np.log(np.array(train_data['Demanda_uni_equil'].tolist())+1)
#print(train_data) | No | 5 | 8 | Data_Transform | feature_engineering | 83,893 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "NumPy", "name": "Array Creation Efficiency", "fix": "Specify dtype when creating arrays.", "benefits": "Improves memory efficiency and avoids unnecessary conversions.", "location": "Line 3"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Sele... | A | no applicable ML-specific findings | [] | ["Array Creation Efficiency", "Column Selection Checker"] | 2 | A |
4,987 | test_data['Demanda_uni_equil']=np.exp(log_target)-1
print(test_data)
test_data.to_csv('result_groupmean_log.csv',index=False,columns=['id','Demanda_uni_equil']) | Yes | 5 | 25 | Data_Export | save_to_csv | 83,893 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 2 | A |
4,988 | test_data[test_data['Producto_ID']==41]['id'] | No | 3 | 41 | Debug | show_table | 83,893 | 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"] | 2 | A |
4,989 | #mean_data.index
#mean_data.ix[41]
test_data.shape | No | 5 | 58 | Debug | show_shape | 83,893 | 3 | C | 1 | 0 | 0 | 0 | 5 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | C |
4,990 | import numpy as np
import pandas as pd
from subprocess import check_output
#types={'Semana':np.uint8,'Agencia_ID':np.uint16,'Canal_ID':np.uint8,
# 'Ruta_SAK':np.uint16,'Cliente_ID':np.uint32,'Producto_ID':np.uint16,
# 'Demanda_uni_equil':np.uint32}
types = {'Semana':np.uint8, 'Agencia_ID':np.uint16, 'Canal_... | No | 3 | 45 | Data_Extraction | load_from_csv | 213,985 | 1 | A | 2 | 0 | 0 | 0 | 10 | 9 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Hardcoded file path"] | 3 | B |
4,991 | import numpy as np
import pandas as pd
from subprocess import check_output
#types={'Semana':np.uint8,'Agencia_ID':np.uint16,'Canal_ID':np.uint8,
# 'Ruta_SAK':np.uint16,'Cliente_ID':np.uint32,'Producto_ID':np.uint16,
# 'Demanda_uni_equil':np.uint32}
types = {'Semana':np.uint8, 'Agencia_ID':np.uint16, 'Canal_... | Yes | 3 | 45 | Data_Extraction | load_from_csv | 213,985 | 1 | A | 2 | 0 | 0 | 0 | 10 | 9 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Hardcoded file path"] | 3 | B |
4,992 | from subprocess import check_output
import pandas as pd
print(check_output(['ls','.']).decode('utf8'))
submission=pd.read_csv('../input/sample_submission.csv')
print(submission.shape)
print(submission.columns)
print(submission.head(20)) | Yes | 3 | 45 | Data_Extraction | load_from_csv | 213,985 | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/sample_submission.csv. 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"] | 3 | A |
4,993 | import numpy as np
import pandas as pd
import gc
import xgboost as xgb
import math
from sklearn.cross_validation import train_test_split
from ml_metrics import rmsle
def evalerror(preds, dtrain):
labels = dtrain.get_label()
assert len(preds) == len(labels)
labels = labels.tolist()
preds = preds.tolist(... | Yes | 3 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
4,994 | test['count'] = (np.exp(rf.predict(test[feats])) - 1) | No | 5 | 8 | Data_Transform | feature_engineering | 1,758,085 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | 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"] | 4 | A |
4,995 | test[['datetime', 'count']].to_csv('submission.csv', index=False) | No | 5 | 25 | Data_Export | save_to_csv | 1,758,085 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 4 | A |
4,996 | __author__ = 'ZFTurbo: https://kaggle.com/zfturbo'
import datetime
import pandas as pd
import numpy as np
from sklearn.cross_validation import train_test_split
import xgboost as xgb
import random
import zipfile
import time
import shutil
from sklearn.metrics import log_loss
random.seed(2016)
def run_xgb(train, test, ... | No | 2 | 22 | Environment | import_modules | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
4,997 | import random
import datetime
import numpy as np
import pandas as pd
import xgboost as xgb
from scipy.sparse import csr_matrix, hstack
from sklearn.preprocessing import LabelEncoder
from sklearn.cross_validation import train_test_split
from subprocess import check_output
random.seed(2010)
print(check_output(['ls', '.... | No | 4 | 88 | Debug | list_files | 81,167 | 1 | A | 0 | 0 | 0 | 0 | 0 | 11 | 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 17"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 4 | A |
4,998 | def read(file_name):
return pd.read_csv('../input/{}.csv'.format(file_name))
app_events = read('app_events')
app_labels = read('app_labels')
events = read('events')
gender_age_test = read('gender_age_test')
gender_age_train = read('gender_age_train')
label_categories = read('label_categories')
phone_brand_device_m... | Yes | 4 | 45 | Data_Extraction | load_from_csv | 81,167 | 1 | A | 0 | 1 | 0 | 0 | 0 | 14 | ok | 11 | 9 | [{"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": "Pipeline Che... | B | Cross Validation Checker=low, No random seed setting detected=low, Pipeline Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Pipeline Checker", "severity": "low"}] | ["Column Selection Checker", "Exception Handling Checker", "Hardcoded file path", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 4 | B |
4,999 | import pandas as pd
import numpy as np
%matplotlib inline
import seaborn as sns
import matplotlib.pyplot as plt
import os
from sklearn.preprocessing import LabelEncoder
from scipy.sparse import csr_matrix, hstack
from sklearn.linear_model import LogisticRegression
from sklearn.cross_validation import StratifiedKFold
fr... | No | 5 | 23 | Environment | set_options | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
5,000 | datadir = '../input'
gatrain = pd.read_csv(os.path.join(datadir,'gender_age_train.csv'),
index_col='device_id')
gatest = pd.read_csv(os.path.join(datadir,'gender_age_test.csv'),
index_col = 'device_id')
phone = pd.read_csv(os.path.join(datadir,'phone_brand_device_model.csv'))
... | No | 4 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 13 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,001 | gatrain['trainrow'] = np.arange(gatrain.shape[0])
gatest['testrow'] = np.arange(gatest.shape[0]) | No | 5 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,002 | m = phone.phone_brand.str.cat(phone.device_model)
modelencoder = LabelEncoder().fit(m)
phone['model'] = modelencoder.transform(m)
gatrain['model'] = phone['model']
gatest['model'] = phone['model']
Xtr_model = csr_matrix((np.ones(gatrain.shape[0]),
(gatrain.trainrow, gatrain.model)))
Xte_model = ... | Yes | 4 | 20 | Data_Transform | categorify | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 10 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,003 | applabels = applabels.loc[applabels.app_id.isin(appevents.app_id.unique())]
applabels['app'] = appencoder.transform(applabels.app_id)
labelencoder = LabelEncoder().fit(applabels.label_id)
applabels['label'] = labelencoder.transform(applabels.label_id)
nlabels = len(labelencoder.classes_) | No | 4 | 20 | Data_Transform | categorify | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,004 | devicelabels = (deviceapps[['device_id','app']]
.merge(applabels[['app','label']])
.groupby(['device_id','label'])['app'].agg(['size'])
.merge(gatrain[['trainrow']], how='left', left_index=True, right_index=True)
.merge(gatest[['testrow']], how='left', lef... | No | 3 | 32 | Data_Transform | merge | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,005 | d = devicelabels.dropna(subset=['trainrow'])
Xtr_label = csr_matrix((np.ones(d.shape[0]), (d.trainrow, d.label)),
shape=(gatrain.shape[0],nlabels))
d = devicelabels.dropna(subset=['testrow'])
Xte_label = csr_matrix((np.ones(d.shape[0]), (d.testrow, d.label)),
shape=(gatest.... | Yes | 4 | 58 | Debug | show_shape | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,006 | Xtrain = hstack((Xtr_brand, Xtr_model, Xtr_app, Xtr_label), format='csr')
Xtest = hstack((Xte_brand, Xte_model, Xte_app, Xte_label), format='csr')
print('All features: train shape {}, test shape {}'.format(Xtrain.shape, Xtest.shape)) | No | 4 | 12 | Data_Transform | create_dataframe | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,007 | Xtrain | 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 |
5,008 | targetencoder = LabelEncoder().fit(gatrain.group)
y = targetencoder.transform(gatrain.group)
nclasses = len(targetencoder.classes_) | No | 5 | 20 | Data_Transform | categorify | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,009 | dtrain = xgb.DMatrix(Xtrain, y) | No | 2 | 7 | Model_Train | train_model | 86,315 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 1 | A |
5,010 | params = {
"eta": 0.1,
"booster": "gblinear",
"objective": "multi:softprob",
"alpha": 4,
"lambda": 0,
"silent": 1,
"seed": 1233,
"num_class": 12,
"eval_metric": "mlogloss"
} | No | 5 | 59 | Model_Train | init_hyperparams | 86,315 | 1 | A | 0 | 0 | 0 | 0 | 0 | 11 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 1 | A |
5,011 | xgb.cv(params, dtrain,
num_boost_round=50,
#early_stopping_rounds = 5,
maximize = False) | No | 5 | 28 | Model_Train | compute_train_metric | 86,315 | 2 | B | 1 | 0 | 0 | 0 | 5 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 1 | B |
5,012 | from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier()
#model.fit(Xtrain, y) hmm this is going to take too long. | No | 5 | 4 | Model_Train | choose_model_class | 86,315 | 3 | C | 2 | 0 | 0 | 0 | 10 | 2 | ok | 2 | 2 | [{"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 3"}, {"detector": "framework_specific", "framework": "ScikitLe... | B | Randomness Control Checker=low | [{"type": "Randomness Control Checker", "severity": "low"}] | ["Verbose Mode Checker"] | 1 | C |
5,013 | model = xgb.train(params, dtrain, num_boost_round=25) | No | 5 | 7 | Model_Train | train_model | 86,315 | 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"}] | [] | 1 | B |
5,014 | model.predict(dtest)
pred = pd.DataFrame(model.predict(dtest), index = gatest.index, columns=targetencoder.classes_) | No | 5 | 48 | Model_Evaluation | predict_on_test | 86,315 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 5 | 4 | [{"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... | B | No random seed setting detected=low | [{"type": "No random seed setting detected", "severity": "low"}] | ["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker"] | 1 | B |
5,015 | pred.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,016 | pred.to_csv('xgb_subm.csv',index=True) | No | 5 | 25 | Data_Export | save_to_csv | 86,315 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 1 | A |
5,017 | brandencoder = LabelEncoder().fit(phone.phone_brand)
phone['brand'] = brandencoder.transform(phone['phone_brand'])
gatrain['brand'] = phone['brand']
gatest['brand'] = phone['brand']
Xtr_brand = csr_matrix((np.ones(gatrain.shape[0]),
(gatrain.trainrow, gatrain.brand)))
Xte_brand = csr_matrix((np.... | No | 4 | 20 | Data_Transform | categorify | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 9 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,018 | appencoder = LabelEncoder().fit(appevents.app_id)
appevents['app'] = appencoder.transform(appevents.app_id)
napps = len(appencoder.classes_)
deviceapps = (appevents.merge(events[['device_id']], how='left',left_on='event_id',right_index=True)
.groupby(['device_id','app'])['app'].agg(['size'])
... | No | 4 | 12 | Data_Transform | create_dataframe | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 9 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,019 | clf = LogisticRegression(C=0.02, multi_class='multinomial',solver='lbfgs')
clf.fit(Xtrain, y)
pred = pd.DataFrame(clf.predict_proba(Xtest), index = gatest.index, columns=targetencoder.classes_)
pred.head() | No | 4 | 49 | Model_Evaluation | compute_test_metric | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,020 | pred.to_csv('logreg_subm.csv',index=True) | No | 5 | 25 | Data_Export | save_to_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,021 | import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import os
from sklearn.preprocessing import LabelEncoder
from scipy.sparse import csr_matrix, hstack
import xgboost as xgb
from sklearn.cross_validation import StratifiedKFold
from sklearn.metrics import log_loss | No | 5 | 22 | Environment | import_modules | 93,236 | 1 | A | 0 | 0 | 0 | 0 | 0 | 10 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
5,022 | # function to bin the timestamp in time of day
def bintod(x):
if x < 3:
return 0
elif x < 8:
return 1
elif x < 20:
return 2
elif x < 23:
return 3
else:
return 0
# functions to assign region based on latitude and longitude
def lngregion(x):
if x < 80:
... | No | 5 | 20 | Data_Transform | categorify | 93,236 | 1 | A | 0 | 6 | 22 | 0 | 0 | 49 | ok | 2 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Magic number detected: 8", "fix": "Not specified", "benefits": "Not specified", "location": "Line 37"}, {"detector": "general_ml", "framework": "General ML", "name": "Magic number detected: 9", "fix": "Not specified", "benefits": "Not specified", "location... | A | no applicable ML-specific findings | [] | ["Magic number"] | 5 | A |
5,023 | datadir = '../input'
gatrain = pd.read_csv(os.path.join(datadir,'gender_age_train.csv'),
index_col='device_id')
gatest = pd.read_csv(os.path.join(datadir,'gender_age_test.csv'),
index_col = 'device_id')
phone = pd.read_csv(os.path.join(datadir,'phone_brand_device_model.csv'))
... | No | 4 | 45 | Data_Extraction | load_from_csv | 93,236 | 1 | A | 0 | 0 | 0 | 0 | 0 | 16 | ok | 8 | 4 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Datatype Checker", "fix": "Set data types explicitly when importing data.", "benefits": "Ensures correct data format and reduces memory usage.", "location": "Line 7"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Datatype Checker"... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Datatype Checker", "Hardcoded file path", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness."] | 5 | A |
5,024 | # clean lat, long info, 0s are missing, also set out of china to missing
events['longitude'] = events['longitude'].round(0)
events['latitude'] = events['latitude'].round(0)
#set out of China to missing along with 0s
events['longitude'] = events['longitude'].clip_lower(73.0).replace(73.0, np.NaN)
events['longitude'] =... | No | 3 | 17 | Data_Transform | correct_missing_values | 93,236 | 1 | A | 0 | 0 | 0 | 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"] | 5 | B |
5,025 | # lat long location for each device
events_latlng = events[['device_id', 'latitude2','longitude2']].drop_duplicates('device_id', keep='first')
events_latlng = events_latlng.set_index('device_id')
print('Number of devices with some lat long info',len(events_latlng['latitude2']))
print('out of that missing longitude: ', ... | No | 4 | 20 | Data_Transform | categorify | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,026 | appencoder = LabelEncoder().fit(appevents.app_id)
appevents['app'] = appencoder.transform(appevents.app_id)
napps = len(appencoder.classes_)
deviceapps = (appevents.merge(events[['device_id']], how='left',left_on='event_id',right_index=True)
.groupby(['device_id','app'])['app'].agg(['size'])
... | No | 4 | 20 | Data_Transform | categorify | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 8 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,027 | applabels = applabels.loc[applabels.app_id.isin(appevents.app_id.unique())]
applabels['app'] = appencoder.transform(applabels.app_id)
labelcat = labelcat.loc[labelcat.label_id.isin(applabels.label_id.unique())]
labelencoder = LabelEncoder().fit(labelcat.category)
labelcat['label'] = labelencoder.transform(labelcat.cat... | Yes | 4 | 20 | Data_Transform | categorify | 93,236 | 1 | A | 0 | 0 | 0 | 0 | 0 | 17 | ok | 11 | 9 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Pipeline Checker", "fix": "Use Pipelines for all scikit-learn estimators.", "benefits": "Prevents data leakage and ensures correct model evaluation.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross V... | D | Cross Validation Checker=low, Data Leakage Checker=high, No random seed setting detected=low, Pipeline Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Pipeline Checker", "severity": "low"}] | ["Exception Handling Checker", "Hardcoded file path", "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,028 | Xtrain = hstack((Xtr_brand, Xtr_model, Xtr_app, Xtr_label,
Xtr_tod, Xtr_dow, Xtr_lat, Xtr_lng), format='csr')
Xtest = hstack((Xte_brand, Xte_model, Xte_app, Xte_label,
Xte_tod, Xte_dow, Xte_lat, Xte_lng), format='csr')
print('All features: train shape {}, test shape {}'.format(Xtrain.... | No | 4 | 11 | Data_Transform | concatenate | 93,236 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}] | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | [] | 5 | B |
5,029 | targetencoder = LabelEncoder().fit(gatrain.group)
y = targetencoder.transform(gatrain.group) | No | 5 | 20 | Data_Transform | categorify | 93,236 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 9 | 8 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Pipeline Checker", "fix": "Use Pipelines for all scikit-learn estimators.", "benefits": "Prevents data leakage and ensures correct model evaluation.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross V... | D | Cross Validation Checker=low, Data Leakage Checker=high, No random seed setting detected=low, Pipeline Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Pipeline Checker", "severity": "low"}] | ["Exception Handling Checker", "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,030 | ########## XGBOOST ##########
params = {}
params['booster'] = 'gblinear'
params['objective'] = "multi:softprob"
params['eval_metric'] = 'mlogloss'
params['eta'] = 0.005
params['num_class'] = 12
params['lambda'] = 3
params['alpha'] = 2' | No | 5 | 59 | Model_Train | init_hyperparams | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,031 | clf = xgb.train(params, d_train, 1000, watchlist, early_stopping_rounds=25)
pred = clf.predict(xgb.DMatrix(Xtest))
pred = pd.DataFrame(pred, index = gatest.index, columns=targetencoder.classes_)
pred.head()
pred.to_csv('sparse_xgb_v11.csv', index=True) | Yes | 4 | 48 | Model_Evaluation | predict_on_test | 93,236 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | 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, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Exception Handling Checker", "Unit Testing Checker"] | 5 | B |
5,032 | # 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 | 88 | Debug | list_files | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
5,033 | b"# device_iddevice\n# ga_trainga_testapp_eventstraintest\nga_train = pd.read_csv('../input/gender_age_train.csv', index_col='device_id')\nga_test = pd.read_csv('../input/gender_age_test.csv', index_col='device_id') \n# event_idapp_eventsappevent_idevent_iddevice_idga_traindevice_idgenderage\nevents = pd.read_csv('../i... | No | 4 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,034 | import numpy as np
import pandas as pd
import os
import gc
nrows=100000
train=pd.read_csv('../input/train.csv',nrows=nrows)
print(train.shape)
print(train.columns)
data=train.copy()
data['target']=data['Demanda_uni_equil']
data.drop(['Demanda_uni_equil'],axis=1,inplace=True)
nCliente_ID = pd.DataFrame(pd.groupby(data,... | Yes | 2 | 22 | Environment | import_modules | 213,985 | 1 | A | 2 | 0 | 0 | 0 | 10 | 43 | ok | 6 | 5 | [{"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": "InPlace Checker", "fix": ... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Column Selection Checker", "Hardcoded file path", "InPlace Checker", "Magic number"] | 3 | B |
5,035 | # 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... | Yes | 5 | 53 | Other | something_strange | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
5,036 | # 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 | 88 | Debug | list_files | 1,086,159 | 1 | A | 0 | 0 | 0 | 0 | 0 | 10 | 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 28"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 9 | A |
5,037 | df_gender_age_test = pd.read_csv('../input/gender_age_test.csv', dtype={'device_id': np.str})
df_gender_age_train = pd.read_csv('../input/gender_age_train.csv', dtype={'device_id': np.str})
df_app_events = pd.read_csv('../input/app_events.csv', dtype={'app_id': np.str})
df_events = pd.read_csv('../input/events.csv', d... | No | 5 | 45 | Data_Extraction | load_from_csv | 1,086,159 | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | ok | 8 | 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 |
5,038 | df_gender_age_test.head() | No | 5 | 41 | Debug | show_table | 1,086,159 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
5,039 | df_gender_age_test.device_id.nunique(), df_gender_age_test.shape[0] | Yes | 5 | 54 | EDA | count_unique_values | 1,086,159 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
5,040 | df_gender_age_train.head() | No | 5 | 41 | Debug | show_table | 1,086,159 | 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"}] | [] | 9 | B |
5,041 | df_gender_age_train.device_id.nunique(), df_gender_age_train.shape[0] | Yes | 5 | 54 | EDA | count_unique_values | 1,086,159 | 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"}] | [] | 9 | B |
5,042 | df_gender_age_train.info() | No | 5 | 40 | Debug | show_table_attributes | 1,086,159 | 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"}] | [] | 9 | B |
5,043 | df_gender_age_train.describe(include='all').T | No | 5 | 40 | Debug | show_table_attributes | 1,086,159 | 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"}] | [] | 9 | B |
5,044 | df_ga_full = pd.concat([df_gender_age_train, df_gender_age_test], axis=0, sort=False) | No | 5 | 11 | Data_Transform | concatenate | 1,086,159 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
5,045 | df_ga_full.device_id.nunique() | No | 5 | 54 | EDA | count_unique_values | 1,086,159 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
5,046 | df_events.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,047 | df_events.event_id.nunique(), df_events.device_id.nunique(), df_events.shape[0] | Yes | 3 | 58 | Debug | show_shape | 1,086,159 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
5,048 | df_app_events.head() | No | 5 | 41 | Debug | show_table | 1,086,159 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
5,049 | df_app_events.event_id.nunique(), df_app_events.shape[0] | Yes | 4 | 54 | EDA | count_unique_values | 1,086,159 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
5,050 | # df_gender_age_train.device_id[]
in_train_events = df_events[df_events.device_id.isin(set(df_gender_age_train.device_id) & set(df_events.device_id))]
in_train_app_events = df_app_events[df_app_events.event_id.isin(in_train_events.event_id)]
in_train_app_events.event_id.nunique(), in_train_app_events.event_id.size, len... | Yes | 3 | 14 | Data_Transform | filter | 1,086,159 | 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"] | 9 | B |
5,051 | in_test_events = df_events[df_events.device_id.isin(set(df_gender_age_test.device_id) & set(df_events.device_id))]
in_test_app_events = df_app_events[df_app_events.event_id.isin(in_test_events.event_id)]
in_train_app_events.event_id.nunique(), in_train_app_events.event_id.size, len(in_train_events) | Yes | 3 | 14 | Data_Transform | filter | 1,086,159 | 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"] | 9 | B |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.