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,141 | b"def unique_count(data , columns = []):\n for col in columns :\n print('Unique Data Percentage in ',col)\n print((data[col].value_counts()/data.shape[0])*100)\n print('\\n')\nunique_count(train , columns = ['season','weather','time_year', 'time_dayofweek'])" | No | 4 | 54 | EDA | count_unique_values | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,142 | b"def display_unique_data(data):\n for i in data.columns:\n unique_cols_data = data[i].unique()\n if len(unique_cols_data)<20:\n print('Correct Type on Column -> ',i)\n print('Unique data in this Column is -> ',unique_cols_data)\n print('\\n')\ndisplay_unique_data(train... | No | 5 | 57 | Debug | show_unique_values | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,143 | display(train.corr().style.format("{:.2%}").highlight_min())
# f,ax = plt.subplots(figsize=(15, 15))
# sns.heatmap(train.corr(), annot=True, linewidths=.5, fmt= '.1f',ax=ax)' | No | 4 | 80 | Visualization | heatmap | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,144 | def joint_plots(data , col,columns = []):
plt.figure(figsize=(16,16))
for i in columns:
sns.jointplot( x=col , y=i , data=data , height=10, ratio=3 , color='g')
plt.show()
joint_plots(train , columns = ['temp' , 'atemp' ,'humidity' , 'windspeed' ] , col = 'count') | No | 5 | 33 | Visualization | distribution | 4,823,309 | 1 | A | 0 | 2 | 1 | 0 | 0 | 6 | 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"] | 7 | A |
4,145 | def plot_bar(data, col , feature=[]):
length = len(feature)*4
plt.figure(figsize=(20,length))
for i,j in zip(feature,range(1,len(feature)*2-1,2)):
plt.subplot(10,2,j)
#fig = plt.figure(figsize=(9,8))
sns.barplot(x=i, y=col, data=data, palette='Set2',orient='v')
plt.plot()
... | No | 5 | 33 | Visualization | distribution | 4,823,309 | 1 | A | 1 | 2 | 1 | 0 | 5 | 10 | ok | 2 | 2 | [{"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", "Missing function docstring"] | 7 | A |
4,146 | plot_bar(train, col = 'count',feature =['time_hour','time_month','time_dayofweek','time_year','weather', 'holiday' , 'workingday' , 'season' ]) | No | 5 | 33 | Visualization | distribution | 4,823,309 | 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"] | 7 | A |
4,147 | b"def new_col_categorical(data , columns = [] , remove_original = True):\n for i in columns:\n unique_cols = data[i].unique()\n if len(unique_cols) < 20:\n print('\\nCorrect Type on Column -> ',i)\n print('Unique data in this Column is -> ',unique_cols)\n else:\n ... | No | 3 | 20 | Data_Transform | categorify | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,148 | train = new_col_categorical(train,columns=['season','weather','time_year', 'time_dayofweek' , 'time_month','time_hour_group'] , remove_original = False) | No | 5 | 8 | Data_Transform | feature_engineering | 4,823,309 | 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"] | 7 | A |
4,149 | define_data(train, columns = True )
# train_x_new = train.drop(columns =['datetime','count', 'season_1','casual','registered',
# 'season_2', 'season_3', 'season_4', 'weather_1', 'weather_2',
# 'weather_3', 'weather_4', 'time_year_2011', 'time_year_2012',
# 'time_dayofweek_0', 'time_dayofweek_1', 't... | Yes | 5 | 21 | Data_Transform | prepare_x_and_y | 4,823,309 | 1 | A | 1 | 0 | 0 | 0 | 5 | 6 | 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": "Cross Valida... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Column Selection Checker", "Dependent Threshold Checker"] | 7 | B |
4,150 | # Processing Test Data
test = add_dates(test , column = 'datetime')
test['time_hour_group'] = test['time_hour'].apply(hour_group).astype(str)
test = new_col_categorical(test,columns=['season','weather','time_year', 'time_dayofweek' , 'time_month','time_hour_group'] , remove_original = False)
test['weekend'] = test['ti... | No | 3 | 8 | Data_Transform | feature_engineering | 4,823,309 | 1 | A | 1 | 0 | 0 | 0 | 5 | 7 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Th... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Dependent Threshold Checker"] | 7 | A |
4,151 | print('For Train Data .. ')
define_data(train_x_new, columns = True )
print('For Test Data .. ')
define_data(test_x_new , columns = True ) | No | 5 | 40 | Debug | show_table_attributes | 4,823,309 | 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"] | 7 | A |
4,152 | scaler = MinMaxScaler()
train_x_new = scaler.fit_transform(train_x_new)
train_y_new = np.log1p(train_y_new) | Yes | 5 | 18 | Data_Transform | normalization | 4,823,309 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 7 | 7 | [{"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"}] | ["Dependent Threshold Checker", "Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 7 | D |
4,153 | test_x_new_1 = scaler.transform(test_x_new)
test_x_new_2 = scaler.fit_transform(test_x_new) | No | 5 | 18 | Data_Transform | normalization | 4,823,309 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 9 | 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... | 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"}] | ["Dependent Threshold Checker", "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"] | 7 | D |
4,154 | X_train , X_test , Y_train , Y_test = train_test_split(train_x_new , train_y_new , test_size = .15 , random_state = 65 ) | No | 5 | 13 | Data_Transform | split | 4,823,309 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | 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"] | 7 | B |
4,155 | valid_0_error =0
valid_1_error =0 | No | 5 | 77 | Other | define_variables | 4,823,309 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | 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"] | 7 | A |
4,156 | %%time
params = {
"objective" : "regression",
"metric" : "mae",
"num_leaves" : 60,
"learning_rate" : 0.01,
"bagging_fraction" : 0.9,
"bagging_seed" : 0,
"num_threads" : 4,
"colsample_bytree" : 0.5,
'lambda_l2':9
}
model = lgb.train( params,... | No | 4 | 7 | Model_Train | train_model | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,157 | %%time
lgb_pred_test = model.predict(X_test, num_iteration=model.best_iteration)
lgb_pred_train = model.predict(X_train, num_iteration=model.best_iteration)
lgb_pred_normal = model.predict(test_x_new_1, num_iteration=model.best_iteration)
lgb_pred_fit = model.predict(test_x_new_2, num_iteration=model.best_iteration) | Yes | 5 | 48 | Model_Evaluation | predict_on_test | 4,823,309 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 7 | null |
4,158 | # print(lgb_pred)
# print(np.array(Y_test))
valid_0_error_new = sqrt(mean_squared_error(np.array(Y_train),lgb_pred_train))
valid_1_error_new = sqrt(mean_squared_error(np.array(Y_test),lgb_pred_test))
score_diff(valid_0_error , valid_1_error , valid_0_error_new , valid_1_error_new)
valid_0_error = valid_0_error_new
vali... | No | 3 | 49 | Model_Evaluation | compute_test_metric | 4,823,309 | 1 | A | 1 | 0 | 0 | 0 | 5 | 5 | ok | 4 | 3 | [{"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 10"}, {"detector": "framework_specific", "framework": "NumPy", "name": "Array Creat... | A | no applicable ML-specific findings | [] | ["Array Creation Efficiency", "Dependent Threshold Checker", "Unit Testing Checker"] | 7 | A |
4,159 | lgb.plot_importance(model) | No | 5 | 79 | Visualization | model_coefficients | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,160 | %%time
n_estimators=100
xgb = XGBRegressor(n_estimators=n_estimators,max_depth=4,learning_rate =0.01 , booster = 'gbtree')
xgb.fit(X_train ,Y_train ,eval_set=[(X_train, Y_train), (X_test, Y_test)] , verbose = False)
score = xgb.evals_result()
valid_0_error_new = np.amin(score['validation_0']['rmse'])
valid_1_error_new ... | Yes | 3 | 7 | Model_Train | train_model | 4,823,309 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 7 | null |
4,161 | %%time
model = RandomForestRegressor(random_state=65, n_estimators=200, min_samples_split=4)
result = model.fit(X_train, Y_train) | Yes | 5 | 7 | Model_Train | train_model | 4,823,309 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 7 | null |
4,162 | model.score(X_test, Y_test) | No | 5 | 49 | Model_Evaluation | compute_test_metric | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,163 | %%time
n_estimators=3000
xgb = XGBRegressor(n_estimators=n_estimators,max_depth=4,learning_rate =0.01 , booster = 'gbtree')
xgb.fit(train_x_new , train_y_new ,eval_set=[(X_train, Y_train), (X_test, Y_test)] , verbose = False)
pred_normal = xgb.predict(test_x_new_1)
pred_fit = xgb.predict(test_x_new_2) | Yes | 4 | 7 | Model_Train | train_model | 4,823,309 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 7 | null |
4,164 | %%time
model = RandomForestRegressor(random_state=65, n_estimators=n_estimators-2000)
model.fit(train_x_new , train_y_new)
rfr_pred_normal = model.predict(test_x_new_1)
rfr_pred_fit = model.predict(test_x_new_2) | Yes | 3 | 7 | Model_Train | train_model | 4,823,309 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 7 | null |
4,165 | %%time
NN_model = Sequential()
# The Input Layer :
NN_model.add(Dense(128, kernel_initializer='normal',input_dim = train_x_new.shape[1], activation='relu'))
# The Hidden Layers :
NN_model.add(Dense(256, kernel_initializer='normal',activation='relu'))
NN_model.add(Dropout(0.3))
NN_model.add(Dense(256, kernel_initializ... | Yes | 5 | 84 | Other | not_enough_vertices | 4,823,309 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 7 | null |
4,166 | ANN_pred_normal = NN_model.predict(test_x_new_1)
ANN_pred_fit = NN_model.predict(test_x_new_2)
ANN_pred_normal = np.expm1(ANN_pred_normal)
ANN_pred_fit = np.expm1(ANN_pred_fit)
ANN_pred_fit = ANN_pred_fit.reshape(6493)
ANN_pred_normal = ANN_pred_normal.reshape(6493) | No | 4 | 48 | Model_Evaluation | predict_on_test | 4,823,309 | 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 | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Dependent Threshold Checker", "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"] | 7 | B |
4,167 | output = pd.DataFrame({'datetime': test.datetime,'count': pred_normal})
output.to_csv('xgb_pred_normal.csv', index=False)
output = pd.DataFrame({'datetime': test.datetime,'count': pred_fit})
output.to_csv('xgb_pred_fit.csv', index=False)
output = pd.DataFrame({'datetime': test.datetime,'count': rfr_pred_normal})
output... | No | 5 | 25 | Data_Export | save_to_csv | 4,823,309 | 1 | A | 0 | 0 | 0 | 0 | 0 | 16 | 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"] | 7 | A |
4,168 | train = pd.read_csv("../input/train.csv", parse_dates = ["datetime"])
test = pd.read_csv("../input/test.csv", parse_dates = ["datetime"])
train["year"] = train["datetime"].dt.year
train["hour"] = train["datetime"].dt.hour
train["dayofweek"] = train["datetime"].dt.dayofweek
test["year"] = test["datetime"].dt.year
test... | No | 3 | 45 | Data_Extraction | load_from_csv | 4,946,261 | 1 | A | 0 | 0 | 0 | 0 | 0 | 8 | ok | 3 | 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"] | 2 | A |
4,169 | train.info() # train.shape, train.isnull().sum(), train.dtypes ' | No | 5 | 40 | Debug | show_table_attributes | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,170 | 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 |
4,171 | b"train['temp'].value_counts().sort_index() # (binning)" | No | 5 | 72 | EDA | count_values | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,172 | import seaborn as sns
import matplotlib.pylab as plt
_, axes = plt.subplots(1,1, figsize = (20,12))
sns.boxplot(x=train["hour"], y=train["count"]) | Yes | 5 | 75 | Visualization | time_series | 4,946,261 | 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"] | 2 | A |
4,173 | fig, axes = plt.subplots(3,1, figsize = (20,12))
sns.countplot(train["season"], ax = axes[0], palette="Set1")
sns.countplot(train["weather"], ax = axes[1], palette="Set1")
sns.countplot(train["windspeed"], ax = axes[2]) | No | 5 | 33 | Visualization | distribution | 4,946,261 | 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"] | 2 | A |
4,174 | fig, axes = plt.subplots(3,1, figsize = (20,12))
sns.countplot(train["season"], ax = axes[0], palette="Set1")
sns.countplot(train["weather"], ax = axes[1], palette="Set1")
sns.countplot(train["windspeed"], ax = axes[2])
plt.xticks(rotation = 60, ) | No | 5 | 33 | Visualization | distribution | 4,946,261 | 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"] | 2 | A |
4,175 | y_casual = np.log1p(train.casual)
y_registered = np.log1p(train.registered)
#y_train = np.log1p(train["count"])
train.drop(["datetime", "windspeed", "casual", "registered", "count"], 1, inplace=True)
test.drop(["datetime", "windspeed", ], 1, inplace=True) | Yes | 5 | 21 | Data_Transform | prepare_x_and_y | 4,946,261 | 1 | A | 1 | 0 | 0 | 0 | 5 | 4 | ok | 2 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "Assign operations to a new DataFrame variable.", "benefits": "Prevents data loss and improves code clarity.", "location": "Line 7"}, {"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "... | A | no applicable ML-specific findings | [] | ["InPlace Checker"] | 2 | A |
4,176 | import lightgbm as lgb
hyperparameters = { 'colsample_bytree': 0.725, 'learning_rate': 0.013,
'num_leaves': 56, 'reg_alpha': 0.754, 'reg_lambda': 0.071,
'subsample': 0.523, 'n_estimators': 1093}
model = lgb.LGBMRegressor(**hyperparameters)
model.fit(train, y_casual)
preds1 = mo... | Yes | 3 | 7 | Model_Train | train_model | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 15 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,177 | submission.iloc[6332:6354] | No | 5 | 14 | Data_Transform | filter | 4,946,261 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
4,178 | submission.to_csv("lgb.csv", index=False) | No | 5 | 25 | Data_Export | save_to_csv | 4,946,261 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
4,179 | import pandas as pd
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
import os
from scipy import stats
import missingno as msno
plt.style.use('seaborn')
import warnings
warnings.filterwarnings("ignore")
mpl.rcParams['axes.unicode_minus'] = False
%matplotlib inline
#... | Yes | 5 | 23 | Environment | set_options | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
4,180 | os.listdir('../input/') | No | 4 | 88 | Debug | list_files | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,181 | df_train = pd.read_csv("../input/bike-sharing-demand/train.csv", parse_dates = ["datetime"])
df_test = pd.read_csv("../input/bike-sharing-demand/test.csv", parse_dates = ["datetime"]) | No | 5 | 45 | Data_Extraction | load_from_csv | 5,710,622 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 4 | 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."] | 7 | A |
4,182 | b"for col in df_train.columns:\n msperc = 'column: {:>10}\\t Percent of NaN value: {:.2f}%'.format(col, 100 * (df_train[col].isnull().sum() / df_train[col].shape[0]))\n print(msperc)" | No | 5 | 39 | EDA | count_missing_values | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,183 | b"for col in df_test.columns:\n msperc = 'column: {:>10}\\t Percent of NaN value: {:.2f}%'.format(col, 100 * (df_test[col].isnull().sum() / df_test[col].shape[0]))\n print(msperc)" | No | 5 | 39 | EDA | count_missing_values | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,184 | msno.matrix(df_train, figsize=(12,5)) | No | 5 | 34 | Visualization | missing_values | 5,710,622 | 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"] | 7 | A |
4,185 | df_train["year"] = df_train["datetime"].dt.year
df_train["month"] = df_train["datetime"].dt.month
df_train["day"] = df_train["datetime"].dt.day
df_train["hour"] = df_train["datetime"].dt.hour
df_train["minute"] = df_train["datetime"].dt.minute
df_train["second"] = df_train["datetime"].dt.second
df_test["year"] = df_te... | Yes | 4 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 13 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,186 | figure, ((ax1,ax2,ax3),(ax4,ax5,ax6)) = plt.subplots(nrows = 2, ncols = 3)
figure.set_size_inches(18,10)
sns.barplot(data=df_train, x = "year", y = "count", ax = ax1)
sns.barplot(data=df_train, x = "month", y = "count", ax = ax2)
sns.barplot(data=df_train, x = "day", y = "count", ax = ax3)
sns.barplot(data=df_train, x... | No | 5 | 75 | Visualization | time_series | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 12 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,187 | df_train["dayofweek"] = df_train["datetime"].dt.dayofweek
df_test["dayofweek"] = df_test["datetime"].dt.dayofweek
df_train.shape
# .
# column 19 . | Yes | 4 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,188 | df_train["dayofweek"].value_counts()
# 0~6 .
# 0 = ~ 6 = .
# 5,6(, ) workingday Boxplot . | 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 |
4,189 | fig, (ax1, ax2, ax3, ax4, ax5) = plt.subplots(nrows = 5)
fig.set_size_inches(18,25)
sns.pointplot(data = df_train, x = "hour", y = "count", ax = ax1)
sns.pointplot(data = df_train, x = "hour", y = "count", hue = "workingday", ax = ax2)
sns.pointplot(data = df_train, x = "hour", y = "count", hue = "dayofweek", ax = ax3... | No | 5 | 75 | Visualization | time_series | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,190 | corr_data = df_train[["temp", "atemp", "casual", "registered", "humidity", "windspeed", "count"]]
colormap = plt.cm.PuBu
f , ax = plt.subplots(figsize = (12,10))
plt.title('Correlation of Numeric Features with Rental Count',y=1,size=18)
sns.heatmap(corr_data.corr(), vmax=.8, linewidths=0.1,square=True,annot=True,cma... | No | 5 | 80 | Visualization | heatmap | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,191 | b"fig, (ax1, ax2, ax3) = plt.subplots(ncols = 3, figsize=(12,5))\n\ntemp_scatter_plot = pd.concat([df_train['count'],df_train['temp']],axis = 1)\nsns.regplot(x='temp',y = 'count',data = temp_scatter_plot,scatter= True, fit_reg=True, ax=ax1)\nwindspeed_scatter_plot = pd.concat([df_train['count'],df_train['windspeed']],a... | No | 5 | 33 | Visualization | distribution | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,192 | fig, axes = plt.subplots(nrows = 2, figsize = (18,14))
plt.sca(axes[0])
plt.xticks(rotation = 30, ha = "right")
axes[0].set(ylabel = "count", title = "train windspeed")
sns.countplot(data = df_train, x = "windspeed", ax = axes[0])
plt.sca(axes[1])
plt.xticks(rotation = 30, ha = "right")
axes[1].set(ylabel = "count", ... | No | 5 | 33 | Visualization | distribution | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 9 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,193 | def concatenate_year_month(datetime):
return "{0}-{1}".format(datetime.year, datetime.month)
df_train["year_month"] = df_train["datetime"].apply(concatenate_year_month)
df_test["year_month"] = df_test["datetime"].apply(concatenate_year_month)
print(df_train.shape)
df_train[["datetime", "year_month"]].head()
... | Yes | 4 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 1 | 0 | 0 | 0 | 6 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,194 | fig, ax = plt.subplots(figsize = (18,4))
sns.barplot(data = df_train, y = "count", x = "year_month")
# 2011 2012 , .
# 2012 , .
# . | No | 5 | 75 | Visualization | time_series | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,195 | df_train.loc[Outliers_to_drop] | No | 5 | 14 | Data_Transform | filter | 5,710,622 | 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"] | 7 | A |
4,196 | df_train = df_train.drop(Outliers_to_drop, axis = 0).reset_index(drop=True)
df_train.shape | Yes | 4 | 10 | Data_Transform | drop_column | 5,710,622 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | 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, 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"}] | ["Dependent Threshold Checker"] | 7 | B |
4,197 | df_train_num = df_train[["count", "temp", "atemp", "casual", "registered", "humidity", "windspeed"]]
for col in df_train_num:
print('{:15}'.format(col),
'Skewness: {:05.2f}'.format(df_train[col].skew()) ,
' ' ,
'Kurtosis: {:06.2f}'.format(df_train[col].kurt())
)
# ' | No | 5 | 40 | Debug | show_table_attributes | null | 1 | A | 0 | 1 | 1 | 0 | 0 | 7 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,198 | fig, axes = plt.subplots(nrows = 5, ncols = 2, figsize=(16, 18))
sns.boxplot(data = df_train, y="count", x = "season", orient = "v", ax = axes[0][0])
sns.boxplot(data = df_train, y="count", x = "holiday", orient = "v", ax = axes[0][1])
sns.boxplot(data = df_train, y="count", x = "workingday", orient = "v", ax = axes[1]... | No | 5 | 33 | Visualization | distribution | 5,710,622 | 1 | A | 0 | 0 | 0 | 0 | 0 | 19 | 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"] | 7 | A |
4,199 | f, ax = plt.subplots(1, 1, figsize = (10,6))
g = sns.distplot(df_train["count"], color = "b", label="Skewness: {:2f}".format(df_train["count"].skew()), ax=ax)
g = g.legend(loc = "best")
print("Skewness: %f" % df_train["count"].skew())
print("Kurtosis: %f" % df_train["count"].kurt())
# ' | Yes | 5 | 40 | Debug | show_table_attributes | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,200 | df_train["count_Log"] = df_train["count"].map(lambda i:np.log(i) if i>0 else 0)
f, ax = plt.subplots(1, 1, figsize = (10,6))
g = sns.distplot(df_train["count_Log"], color = "b", label="Skewness: {:2f}".format(df_train["count_Log"].skew()), ax=ax)
g = g.legend(loc = "best")
print("Skewness: %f" % df_train['count_Log']... | Yes | 4 | 20 | Data_Transform | categorify | null | 1 | A | 0 | 1 | 1 | 0 | 0 | 7 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,201 | trainWind0 = df_train.loc[df_train["windspeed"] == 0]
trainWindNot0 = df_train.loc[df_train["windspeed"] != 0]
# 0 0 . | No | 5 | 14 | Data_Transform | filter | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,202 | from sklearn.ensemble import RandomForestClassifier
# RandomForest .
def predict_windspeed(data):
dataWind0 = data.loc[data["windspeed"] == 0]
dataWindNot0 = data.loc[data["windspeed"] != 0]
# 0 .
wcol = ["season", "weather", "humidity", "day", "temp", "atemp"]
# .
dataWindNot0["windsp... | Yes | 2 | 7 | Model_Train | train_model | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
4,203 | df_train = predict_windspeed(df_train)
df_test = predict_windspeed(df_test)
fig, (ax1, ax2) = plt.subplots(nrows = 2, figsize = (18,14))
plt.sca(ax1)
plt.xticks(rotation = 30, ha = "right")
ax1.set(ylabel = "count", title = "train windspeed")
sns.countplot(data = df_train, x = "windspeed", ax = ax1)
plt.sca(ax2)
plt... | Yes | 4 | 33 | Visualization | distribution | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,204 | df_train = pd.get_dummies(df_train, columns = ["weather"], prefix = "weather")
df_test = pd.get_dummies(df_test, columns = ["weather"], prefix = "weather")
df_train = pd.get_dummies(df_train, columns = ["season"], prefix = "season")
df_test = pd.get_dummies(df_test, columns = ["season"], prefix = "season")
#onehotenc... | No | 5 | 20 | Data_Transform | categorify | 5,710,622 | 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"] | 7 | A |
4,205 | corr_data = df_train[["count_Log", "windspeed"]]
corr_data.corr() | No | 5 | 40 | Debug | show_table_attributes | 5,710,622 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | 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"] | 7 | A |
4,206 | datetime_test = df_test['datetime']
df_train.drop(["datetime", "registered","casual","holiday", "year_month", "minute", "second"], axis = 1, inplace = True)
df_test.drop(["datetime","holiday", "year_month", "minute", "second"], axis = 1, inplace = True)
' | No | 5 | 10 | Data_Transform | drop_column | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,207 | df_test.head(20) | 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 |
4,208 | from sklearn.model_selection import train_test_split
from sklearn import metrics
X_train = df_train.drop("count_Log", axis = 1).values
target_label = df_train["count_Log"].values
X_test = df_test.values
X_tr, X_vld, y_tr, y_vld = train_test_split(X_train, target_label, test_size = 0.2, random_state = 2000) | No | 4 | 21 | Data_Transform | prepare_x_and_y | 5,710,622 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Cross-validation not detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}] | ["Dependent Threshold Checker"] | 7 | B |
4,209 | from sklearn.ensemble import GradientBoostingRegressor
regressor = GradientBoostingRegressor(n_estimators=2000, learning_rate=0.05,
max_depth=4,
min_samples_leaf=15, min_samples_split=10, random_state =42)
regressor.fit(X_tr,y_tr) | Yes | 5 | 7 | Model_Train | train_model | 5,710,622 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 6 | 5 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Dependent Threshold Checker", "Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 7 | B |
4,210 | y_hat = regressor.predict(X_tr)
plt.scatter(y_tr, y_hat, alpha = 0.2)
plt.xlabel('Targets (y_tr)',size=18)
plt.ylabel('Predictions (y_hat)',size=18)
plt.show() | Yes | 5 | 56 | Visualization | plot_predictions | 5,710,622 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 3 | 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": "framework_specific", "framework":... | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker", "Exception Handling Checker", "Unit Testing Checker"] | 7 | A |
4,211 | y_hat_test = regressor.predict(X_vld)
plt.scatter(y_vld, y_hat_test, alpha=0.2)
plt.xlabel('Targets (y_vld)',size=18)
plt.ylabel('Predictions (y_hat_test)',size=18)
plt.show() | Yes | 5 | 56 | Visualization | plot_predictions | 5,710,622 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 3 | 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": "framework_specific", "framework":... | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker", "Exception Handling Checker", "Unit Testing Checker"] | 7 | A |
4,212 | from sklearn.metrics import mean_squared_log_error,mean_squared_error, r2_score,mean_absolute_error # for regression
from sklearn.metrics import accuracy_score,precision_score,recall_score,f1_score # for classification
models=[GradientBoostingRegressor()]
model_names=['regressor']
rmsle=[]
d={}
for model in range (le... | Yes | 5 | 4 | Model_Train | choose_model_class | 5,710,622 | 1 | A | 0 | 1 | 1 | 1 | 0 | 13 | 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 | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Dependent Threshold Checker", "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"] | 7 | B |
4,213 | from sklearn.model_selection import cross_val_score
accuracies = cross_val_score(estimator = regressor, X = X_tr, y = y_tr, cv = 8) | Yes | 5 | 84 | Other | not_enough_vertices | 5,710,622 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 3 | 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": "framework_specific", "framework":... | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker", "Exception Handling Checker", "Unit Testing Checker"] | 7 | A |
4,214 | use_logvals = 1
pred_xgb = regressor.predict(X_test)
sub_xgb = pd.DataFrame()
sub_xgb['datetime'] = datetime_test
sub_xgb['count'] = pred_xgb
if use_logvals == 1:
sub_xgb['count'] = np.exp(sub_xgb['count'])
sub_xgb.to_csv('xgb.csv',index=False) | Yes | 4 | 55 | Data_Export | prepare_output | 5,710,622 | 1 | A | 0 | 1 | 1 | 0 | 0 | 8 | ok | 3 | 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": "framework_specific", "framework":... | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker", "Exception Handling Checker", "Unit Testing Checker"] | 7 | A |
4,215 | # read data (train, test) with pd.read_csv(directory)
train = pd.read_csv("/kaggle/input/bike-sharing-demand/train.csv")
train.head(10)
#train.info()
#train.shape | Yes | 4 | 45 | Data_Extraction | load_from_csv | 5,893,705 | 2 | B | 1 | 0 | 0 | 0 | 5 | 2 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: /kaggle/input/bike-sharing-demand/train.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 4"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 2 | B |
4,216 | test = pd.read_csv("/kaggle/input/bike-sharing-demand/test.csv")
test.head(10) | Yes | 4 | 45 | Data_Extraction | load_from_csv | 5,893,705 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: /kaggle/input/bike-sharing-demand/test.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 3"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 2 | A |
4,217 | b"y = train['count']\n# y . log scaling outlier .\n# MSE(Mean Square Error) // 900 100 800^2 = 6400 ..\n# , outlier log sacling .\ny.sort_values()" | No | 3 | 41 | Debug | show_table | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,218 | # y .
import matplotlib.pyplot as plt
import seaborn as sns
#
wg, dh = plt.subplots(2,1, figsize=(20,12))
# log scaling .
sns.distplot(y, ax=dh[0])
# log .
sns.distplot(np.log(y), ax=dh[1])
' | No | 3 | 41 | Debug | show_table | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,219 | b"# , .\n# y x . train test .\n# y = train['count']\n# log scaling y outlier .\ny = np.log(train['count'])\ny # . ." | No | 5 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,220 | ############## .
# 3 .
train['datetime'] = train['datetime'].astype('datetime64')
# train['datetime'] = pd.to_datetime(train['datetime'])
# train = pd.read_csv("/kaggle/input/bike-sharing-demand/train.csv", parse_dates = ['datetime'])
train.dtypes
' | Yes | 4 | 16 | Data_Transform | data_type_conversions | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,221 | test['datetime'] = test['datetime'].astype('datetime64')
# test['datetime'] = pd.to_datetime(test['datetime'])
# train = pd.read_csv("/kaggle/input/bike-sharing-demand/train.csv", parse_dates = ['datetime'])
test.dtypes' | Yes | 4 | 16 | Data_Transform | data_type_conversions | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,222 | train['year'] = train['datetime'].dt.year
train['weekday'] = train['datetime'].dt.weekday
train['hour'] = train['datetime'].dt.hour
train.head() | Yes | 5 | 8 | Data_Transform | feature_engineering | 5,893,705 | 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"] | 2 | A |
4,223 | test['year'] = test['datetime'].dt.year
test['weekday'] = test['datetime'].dt.weekday
test['hour'] = test['datetime'].dt.hour
test.head() | Yes | 4 | 8 | Data_Transform | feature_engineering | 5,893,705 | 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"] | 2 | A |
4,226 | train = train.drop(['datetime', 'casual', 'registered', 'count'], 1)
test = test.drop('datetime', 1)
| No | 5 | 10 | Data_Transform | drop_column | 5,893,705 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
4,231 | from xgboost import XGBRegressor
xgb = XGBRegressor()
xgb.fit(train, y)
preds = predict(test) | Yes | 4 | 7 | Model_Train | train_model | 5,893,705 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Cross-validation not detected in model training code. Consider using cross-validation for more robust evaluation.", "fix": "Not specified", "benefits": "Not specified", "location": ""}] | B | Cross-validation not detected=low | [{"type": "Cross-validation not detected", "severity": "low"}] | [] | 2 | B |
4,232 | sample = pd.read_csv("/kaggle/input/bike-sharing-demand/sampleSubmission.csv")
sample.head() | Yes | 3 | 45 | Data_Extraction | load_from_csv | 5,893,705 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: /kaggle/input/bike-sharing-demand/sampleSubmission.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 3"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 2 | A |
4,233 | b"# np.log train , exp .\nsample['count'] = np.exp(preds)\nsample.head()" | Yes | 4 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,234 | sample.to_csv("sample.csv", index = False)
| No | 5 | 25 | Data_Export | save_to_csv | 5,893,705 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
4,235 | #################################################################################################
############################ EDA INSIGHT ###############################
y.sort_values()' | No | 3 | 41 | Debug | show_table | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,236 | train2 = pd.read_csv("/kaggle/input/bike-sharing-demand/train.csv", parse_dates=['datetime'])
train2['year'] = train2['datetime'].dt.year
train2['month'] = train2['datetime'].dt.month
train2['day'] = train2['datetime'].dt.day
train2['weekday'] = train2['datetime'].dt.weekday
train2['hour'] = train2['datetime'].dt.hour
... | Yes | 3 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,237 | b"a, b = plt.subplots(2,2,figsize=(20,12))\nsns.boxplot(train2['year'], train2['count'], ax=b[0,1])\nsns.boxplot(train2['month'], train2['count'], ax=b[1,1])\n### day 1~19 .!\nsns.boxplot(train2['day'], train2['count'], ax=b[0,0])\n### outlier ? ( 5/ 2) 5 . \n### count outlier .\nsns.boxplot(train2['hour... | No | 5 | 75 | Visualization | time_series | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,238 | b"# class .\ntrain2['datetime'].dt.month.value_counts()" | No | 4 | 72 | EDA | count_values | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,239 | #Let's import the usual suspects
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline | Yes | 5 | 23 | Environment | set_options | 6,062,819 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 7 | null |
4,240 | #Importing the dataset
train = pd.read_csv('/kaggle/input/bike-sharing-demand/train.csv')
test = pd.read_csv('/kaggle/input/bike-sharing-demand/test.csv')
data = train.append(test, sort = False)
data.head() | Yes | 4 | 45 | Data_Extraction | load_from_csv | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 4 | 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 | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Hardcoded file path", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness."] | 7 | B |
4,241 | #Histogram for count
sns.set_style('darkgrid')
sns.distplot(train['count'], bins = 100, color = 'green')
plt.show() | No | 5 | 33 | Visualization | distribution | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,242 | #Boxplot for count
import matplotlib.pyplot as plt
sns.boxplot(x = 'count', data = train, color = 'mediumpurple')
plt.show() | No | 5 | 33 | Visualization | distribution | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,243 | #Data without the outliers in count
data = data[~data.isin(outliers)]
data = data[data['datetime'].notnull()] | No | 5 | 14 | Data_Transform | filter | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,244 | sns.barplot(x = 'season', y = 'count', data = train, estimator = np.average, palette='coolwarm')
plt.ylabel('Average Count')
plt.show() | No | 5 | 33 | Visualization | distribution | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,245 | sns.barplot(x = 'workingday', y = 'count', data = train, estimator = np.average, palette='colorblind')
plt.ylabel('Average Count')
plt.show() | No | 5 | 33 | Visualization | distribution | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,246 | sns.barplot(x = 'weather', y = 'count', data = train, estimator = np.average, palette='deep')
plt.ylabel('Average Count')
plt.show() | No | 5 | 33 | Visualization | distribution | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.