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,451 | sns.pairplot(original_train[feature_columns]) | No | 3 | 33 | Visualization | distribution | 7,854,996 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 11 | A |
4,452 | sns.heatmap(original_train[feature_columns].corr(), annot=True) | No | 5 | 80 | Visualization | heatmap | 7,854,996 | 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": "TensorFlow... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Logging Checker"] | 11 | B |
4,453 | def draw_boxplot(df, x_name, y_name, fig, m, n, idx):
ax = fig.add_subplot(m, n, idx)
ax = sns.boxplot(data=df, x=x_name, y=y_name)
def draw_boxplots(df, x_columns, y_name):
M = round(len(x_columns)/2)
N = 2
fig = plt.figure(figsize=[N*10, M*6])
for idx, name in enumerate(x_columns):
d... | No | 5 | 33 | Visualization | distribution | 7,854,996 | 1 | A | 1 | 3 | 1 | 0 | 5 | 10 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Missing docstring for function: draw_boxplots. Consider adding documentation for parameters and return values.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 16"}] | A | no applicable ML-specific findings | [] | ["Missing function docstring"] | 11 | A |
4,454 | def draw_scatterplot(df, x_name, y_name, fig, m, n, idx):
ax = fig.add_subplot(m, n, idx)
ax = sns.scatterplot(data=df, x=x_name, y=y_name)
def draw_scatterplots(df, x_columns, y_name):
M = round(len(x_columns)/2)
N = 2
fig = plt.figure(figsize=[N*10, M*6])
for idx, name in enumerate(x_columns... | No | 5 | 33 | Visualization | distribution | 7,854,996 | 1 | A | 1 | 3 | 1 | 0 | 5 | 10 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Missing docstring for function: draw_scatterplots. Consider adding documentation for parameters and return values.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 16"}] | A | no applicable ML-specific findings | [] | ["Missing function docstring"] | 11 | A |
4,455 | train_data = original_train.copy()
test_data = original_test.copy() | No | 5 | 12 | Data_Transform | create_dataframe | 7,854,996 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "TensorFlow... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Logging Checker"] | 11 | B |
4,456 | #categorical columns change to one-hot encoding data
def replaced_with_onehot_cols(data: DataFrame, col_names: List[str]) -> DataFrame:
data = data.copy()
for col_name in col_names:
one_hot = pd.get_dummies(data[col_name], prefix=col_name)
data = data.join(one_hot)
# Origi... | No | 5 | 20 | Data_Transform | categorify | 7,854,996 | 1 | A | 0 | 2 | 1 | 0 | 0 | 7 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Missing docstring for function: replaced_with_onehot_cols. Consider adding documentation for parameters and return values.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 14"}] | A | no applicable ML-specific findings | [] | ["Missing function docstring"] | 11 | A |
4,457 | train_data = replaced_with_onehot_cols(data=train_data, col_names=categorical_feature_columns)
test_data = replaced_with_onehot_cols(data=test_data, col_names=categorical_feature_columns) | No | 3 | 20 | Data_Transform | categorify | 7,854,996 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 11 | A |
4,458 | #remove only_train_columns
train_data = train_data.drop(only_train_columns, axis=1)
train_data.head() | Yes | 4 | 10 | Data_Transform | drop_column | 7,854,996 | 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": "TensorFlow... | 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"}] | ["Logging Checker"] | 11 | B |
4,459 | #seperate datetime index
def expanded_index_datetime_col(data: DataFrame) -> DataFrame:
data = data.copy()
data["hour"] = data.index.hour
data["weekday"] = data.index.weekday
data["month"] = data.index.month
data["year"] = data.index.year
return data | No | 5 | 8 | Data_Transform | feature_engineering | 7,854,996 | 1 | A | 0 | 1 | 0 | 0 | 0 | 7 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Missing docstring for function: expanded_index_datetime_col. Consider adding documentation for parameters and return values.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 13"}] | A | no applicable ML-specific findings | [] | ["Missing function docstring"] | 11 | A |
4,460 | train_data = expanded_index_datetime_col(data=train_data)
test_data = expanded_index_datetime_col(data=test_data)
train_data.head() | Yes | 3 | 16 | Data_Transform | data_type_conversions | 7,854,996 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | 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": "TensorFlow... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Logging Checker"] | 11 | B |
4,461 | #change datetime data to one-hot data
datetime_cols = ['hour', 'weekday','month','year']
train_data = replaced_with_onehot_cols(data=train_data, col_names=datetime_cols)
test_data = replaced_with_onehot_cols(data=test_data, col_names=datetime_cols)
train_data.head() | Yes | 4 | 20 | Data_Transform | categorify | 7,854,996 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | 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": "TensorFlow... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Logging Checker"] | 11 | B |
4,462 | from sklearn.preprocessing import MinMaxScaler
def normalize_cols(df: DataFrame, scaler) -> DataFrame:
df = df.copy()
return DataFrame(scaler.fit_transform(df.values), columns=df.columns, index=df.index)
x_scaler = MinMaxScaler()
x = train_data.drop(TARGET_NAME, axis=1)
x = normalize_cols(df=x, scaler=x_scale... | Yes | 5 | 21 | Data_Transform | prepare_x_and_y | 7,854,996 | 1 | A | 0 | 1 | 0 | 0 | 0 | 11 | ok | 10 | 10 | [{"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, Cross-validation not detected=low, Data Leakage Checker=high, No random seed setting detected=low, Pipeline Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Pipeline Checker", "severity": "low"}] | ["Exception Handling Checker", "Logging Checker", "Missing function docstring", "Unit Testing Checker", "Verbose Mode Checker"] | 11 | D |
4,463 | x.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 |
4,464 | y.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 |
4,465 | from sklearn.ensemble import RandomForestRegressor
model = RandomForestRegressor()
result = model.fit(x.values, y.values) | Yes | 5 | 7 | Model_Train | train_model | 7,854,996 | 3 | C | 2 | 0 | 0 | 0 | 10 | 3 | ok | 10 | 9 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Randomness Control Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Randomness Control Checker", "severity": "low"}] | ["Checkpointing Checker", "Exception Handling Checker", "Logging Checker", "Memory Release Checker", "Model Evaluation Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 11 | C |
4,466 | features = pd.DataFrame()
features["features"] = x.columns
features["coefficient"] = model.feature_importances_
features.sort_values(by=["coefficient"], ascending=False, inplace=True)
fig,ax= plt.subplots()
fig.set_size_inches(20,20)
sns.barplot(data=features, x="coefficient", y="features"); | No | 5 | 79 | Visualization | model_coefficients | 7,854,996 | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 11 | A |
4,467 | !pip install livelossplot tensorflow-gpu
import tensorflow.keras.backend as K
import tensorflow as tf | Yes | 5 | 87 | Environment | install_modules | 7,854,996 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 11 | null |
4,468 | #Split train, test data
from sklearn.model_selection import train_test_split
random_seed = 5
x_train, x_validation, y_train, y_validation = train_test_split(x, y, test_size=0.3, shuffle=True, random_state=random_seed)
print('train data count : ' + str(len(x_train)))
print('test data count : ' + str(len(x_validation))... | Yes | 5 | 13 | Data_Transform | split | 7,854,996 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | 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": "TensorFlow... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Logging Checker", "Magic number"] | 11 | B |
4,469 | #make cost function
from sklearn import metrics
def rmsle_K(y, pred):
return K.sqrt(K.mean(K.square(tf.math.log1p(y) - tf.math.log1p(pred))))
def rmsle(y, pred):
return np.sqrt(metrics.mean_squared_error(y, pred)) | Yes | 4 | 49 | Model_Evaluation | compute_test_metric | 7,854,996 | 2 | B | 1 | 2 | 0 | 0 | 10 | 5 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 11 | B |
4,470 | #Make DL Models
from tensorflow.keras.layers import Input, Dense, Dropout
from tensorflow.keras.models import Model
from tensorflow.keras.callbacks import EarlyStopping, ReduceLROnPlateau
_, NUM_FEATURES = x_train.shape
def make_dl_model()-> Model:
input = Input(shape=(NUM_FEATURES, ))
_ = Dense(32, activatio... | Yes | 4 | 4 | Model_Train | choose_model_class | 7,854,996 | 1 | A | 1 | 1 | 0 | 0 | 5 | 15 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "TensorFlow", "name": "Batch Normalisation Checker", "fix": "Include BatchNormalization layers in your model.", "benefits": "Improves training stability and model convergence.", "location": ""}, {"detector": "framework_specific", "framework": "TensorFlow", "name": "Model... | A | no applicable ML-specific findings | [] | ["Batch Normalisation Checker", "Missing function docstring", "Model Evaluation Checker"] | 11 | A |
4,471 | model = make_dl_model()
model.fit(x_train,y_train, validation_data=(x_validation,y_validation),
epochs=200, batch_size=128, verbose=1,
callbacks=[ReduceLROnPlateau(monitor='val_loss', factor=0.4, patience=5, min_lr=0.000001, verbose=1),
EarlyStopping(monitor="val_loss", patience=10... | Yes | 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,472 | #Make ML Models
from sklearn.linear_model import LinearRegression
from sklearn.linear_model import Lasso
from sklearn.linear_model import Ridge
from sklearn.linear_model import ElasticNet
from sklearn.ensemble import RandomForestRegressor
from xgboost import XGBRegressor
ml_models = {
'LinearRegression': LinearReg... | Yes | 5 | 3 | Hyperparam_Tuning | find_best_model_class | 7,854,996 | 1 | A | 3 | 1 | 1 | 0 | 15 | 17 | ok | 13 | 11 | [{"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"}] | ["Checkpointing Checker", "Exception Handling Checker", "Logging Checker", "Memory Release Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 11 | B |
4,473 | best_model = sorted_result[0].model
y_pred = best_model.predict(test_data)
y_pred = y_scaler.inverse_transform(y_pred.reshape(-1, 1)).astype(int) | Yes | 4 | 3 | Hyperparam_Tuning | find_best_model_class | 7,854,996 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 7 | 5 | [{"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", "Memory Release Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker"] | 11 | B |
4,474 | #Save Submission
submission = test_data.copy()
submission["datetime"] = test_data.index
submission["count"] = y_pred.astype(int)
submission = submission[["datetime", "count"]]
submission.to_csv('submission.csv', index=False)
' | Yes | 5 | 25 | Data_Export | save_to_csv | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,475 | #Import libraries
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 | 7,945,399 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 7 | null |
4,476 | from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
| Yes | 5 | 23 | Environment | set_options | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,477 | sns.set(style="dark")
sns.set(style="whitegrid", color_codes=True) | No | 5 | 23 | Environment | set_options | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,478 | train=pd.read_csv('/kaggle/input/bike-sharing-demand/train.csv')
test=pd.read_csv('/kaggle/input/bike-sharing-demand/test.csv')
print('train shape:',train.shape)
print('test shape:',test.shape) | Yes | 4 | 45 | Data_Extraction | load_from_csv | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | 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."] | 7 | A |
4,479 | #check for null data
train.isnull().sum() | No | 5 | 39 | EDA | count_missing_values | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | [] | 7 | B |
4,480 | import missingno as msno
fig,ax=plt.subplots(2,1,figsize=(10,5))
msno.matrix(train,ax=ax[0])
ax[0].set_title('Train Data')
msno.matrix(test,ax=ax[1])
ax[1].set_title('Test Data') | Yes | 5 | 34 | Visualization | missing_values | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,481 | #variable datatype:
train.info() | No | 5 | 40 | Debug | show_table_attributes | 7,945,399 | 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"}] | [] | 7 | B |
4,482 | from datetime import datetime
from dateutil import parser
import calendar
#parse string datetime into datetime format
train['datetime2']=train.datetime.apply(lambda x: parser.parse(x))
#Get some different time variables
train['year']=train.datetime2.apply(lambda x: x.year)
train['month']=train.datetime2.apply(lambda ... | Yes | 5 | 8 | Data_Transform | feature_engineering | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 9 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | [] | 7 | B |
4,483 | #create categorical data
train['season_decode']=train.season.map({1:'spring',2:'summer',3:'fall',4:'winter'})
train['working_decode']=train.workingday.map({1:'work',0:'notwork'})
train['weather_decode']=train.weather.map({1:'Clear',2:'Mist',3:'LightRain',4:'HeavyRain'}) | No | 5 | 20 | Data_Transform | categorify | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | [] | 7 | B |
4,484 | f,ax=plt.subplots(1,2)
sns.distplot(train['count'],bins=30,ax=ax[0])
ax[0].set_title('count distrib')
sns.boxplot(data=train,y=train['count'],ax=ax[1])
ax[1].set_title('count boxplot') | No | 5 | 33 | Visualization | distribution | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,485 | mean_count=train['count'].mean()
std_count=train['count'].std()
print(mean_count-3*std_count)
print(mean_count+3*std_count)
outliers1=train[train['count']>(mean_count+3*std_count)]
len(outliers1['count']) | No | 3 | 40 | Debug | show_table_attributes | 7,945,399 | 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": "general_ml", "framework": "General ML", "name... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | [] | 7 | B |
4,486 | train2=train[train['count']<=(mean_count+3*std_count)]
train2.shape | Yes | 4 | 14 | Data_Transform | filter | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,487 | #Season
sns.boxplot(data=train2,y=train2['count'],x=train['season_decode']).set_title('Demand by season') | No | 5 | 33 | Visualization | distribution | 7,945,399 | 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"}] | [] | 7 | B |
4,488 | #Year
train2.groupby(['year','month'])['count'].mean().plot().set_title('demand by year')
| No | 5 | 75 | Visualization | time_series | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | [] | 7 | B |
4,489 | #WeekDay & Hour:
week_hour=train2.groupby(['weekday_name','hour'])['count'].mean().unstack()
week_hour=week_hour.reindex(index=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'])
plt.figure(figsize=(15,6))
cmap2 = sns.cubehelix_palette(start=2,light=1, as_cmap=True)
sns.heatmap(week_hour,cmap=c... | Yes | 5 | 80 | Visualization | heatmap | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | [] | 7 | B |
4,490 | #Difference between casual and resgitered
train2.groupby(['hour'])['casual','registered','count'].mean().plot().set_title('Demand by hour')
| No | 5 | 33 | Visualization | distribution | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | [] | 7 | B |
4,491 |
train2.groupby(['weekday_name'])['casual','registered','count'].mean().plot(kind='bar').set_title('demand by day of week')
| No | 5 | 33 | Visualization | distribution | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | [] | 7 | B |
4,492 | #Weather
train2.groupby(['weather_decode'])['casual','registered'].mean().plot(kind='bar').set_title('demand by weather') | No | 5 | 33 | Visualization | distribution | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | [] | 7 | B |
4,493 | #Temp
season_temp=train2.groupby(['season_decode','temp'])['count'].mean().unstack()
plt.figure(figsize=(15,8))
cmap3 = sns.cubehelix_palette(start=6,light=1, as_cmap=True)
sns.heatmap(season_temp,cmap=cmap3).set_title('demand by season and temperature') | Yes | 5 | 80 | Visualization | heatmap | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | [] | 7 | B |
4,494 | Correlation_Matrix=train2[['holiday','workingday','weather','temp','atemp','humidity','windspeed','casual','registered','count']].corr()
mask = np.array(Correlation_Matrix)
mask[np.tril_indices_from(mask)] = False
fig,ax= plt.subplots()
fig.set_size_inches(20,10)
sns.heatmap(Correlation_Matrix,mask=mask,vmax=.8,annot=T... | No | 5 | 80 | Visualization | heatmap | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | 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"}] | [] | 7 | B |
4,495 | #preparing data sets for random forest
X=train2[['season','holiday','workingday','weather','temp','atemp','humidity','windspeed','year','month','weekday','hour']]
y_count=train2['count']
y_casual=train2['casual']
y_reg=train2['registered'] | No | 5 | 21 | Data_Transform | prepare_x_and_y | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,496 | from sklearn.preprocessing import StandardScaler
#Scaled all distributions
X_Scaled=StandardScaler().fit_transform(X=X) | Yes | 5 | 18 | Data_Transform | normalization | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | 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... | E | Cross Validation Checker=low, Data Leakage Checker=high, Inconsistent scaling methods=high, Pipeline Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "Inconsistent scaling methods", "severity": "high"}, {"type": "Pipeline Checker", "severity": "low"}] | ["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 7 | E |
4,497 | from sklearn.model_selection import train_test_split
#Split for train-test
X_train, X_test, y_train, y_test = train_test_split(X_Scaled, y_count, test_size=0.25, random_state=42)
| Yes | 5 | 13 | Data_Transform | split | 7,945,399 | 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"}] | [] | 7 | B |
4,498 | from sklearn.ensemble import RandomForestRegressor
rf_count=RandomForestRegressor()
rf_count.fit(X_train,y_train)
importance_count=pd.DataFrame(rf_count.feature_importances_ , index=X.columns, columns=['count']).sort_values(by='count',ascending=False)
| Yes | 4 | 7 | Model_Train | train_model | 7,945,399 | 2 | B | 2 | 0 | 0 | 0 | 10 | 4 | 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, Randomness Control Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Randomness Control Checker", "severity": "low"}] | ["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 7 | B |
4,499 | importance_count.plot(kind='bar',color='r').set_title('Importance of features for total demand') | No | 5 | 79 | Visualization | model_coefficients | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,500 | #repeat for casual demand:
X_train, X_test, y_train, y_test = train_test_split(X_Scaled, y_casual, test_size=0.25, random_state=42)
rf_casual=RandomForestRegressor()
rf_casual.fit(X_train,y_train)
importance_casual=pd.DataFrame(rf_casual.feature_importances_ , index=X.columns, columns=['casual']).sort_values(by='cas... | Yes | 4 | 7 | Model_Train | train_model | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 7 | 6 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Cross-validation not detected=low, Randomness Control Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "Randomness Control Checker", "severity": "low"}] | ["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 7 | B |
4,501 | importance_casual.plot(kind='bar').set_title('Importance of features for casual demand') | No | 5 | 79 | Visualization | model_coefficients | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,502 | #repeat for registered demand:
X_train, X_test, y_train, y_test = train_test_split(X_Scaled, y_reg, test_size=0.25, random_state=42)
rf_reg=RandomForestRegressor()
rf_reg.fit(X_train,y_train)
importance_reg=pd.DataFrame(rf_reg.feature_importances_ , index=X.columns, columns=['reg']).sort_values(by='reg',ascending=Fa... | Yes | 4 | 7 | Model_Train | train_model | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 7 | 6 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Cross-validation not detected=low, Randomness Control Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "Randomness Control Checker", "severity": "low"}] | ["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 7 | B |
4,503 | importance_reg.plot(kind='bar',color='g').set_title('Importance of features for registered demand') | No | 5 | 79 | Visualization | model_coefficients | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,504 | importance_df=pd.concat([importance_count,importance_casual,importance_reg],axis=1)
importance_df.plot(kind='bar').set_title('Feature importance for each kind of demand') | No | 4 | 79 | Visualization | model_coefficients | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,505 | #Prepare Training data
X_train=train2[feature_selection]
print(X_train.shape)
y_train=train2['count']
print(y_train.shape) | No | 4 | 14 | Data_Transform | filter | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,506 | #Prepare Test data
#parse string datetime into datetime format
test['datetime2']=test.datetime.apply(lambda x: parser.parse(x))
#Get some different time variables
test['year']=test.datetime2.apply(lambda x: x.year)
test['month']=test.datetime2.apply(lambda x: x.month)
test['weekday']=test.datetime2.apply(lambda x: x.... | Yes | 4 | 8 | Data_Transform | feature_engineering | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,507 | X_train_scaled=StandardScaler().fit_transform(X=X_train)
X_test_scaled=StandardScaler().fit_transform(X=X_test) | No | 5 | 18 | Data_Transform | normalization | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 12 | 10 | [{"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... | E | Cross Validation Checker=low, Cross-validation not detected=low, Data Leakage Checker=high, Inconsistent scaling methods=high, No random seed setting detected=low, Pipeline Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "Inconsistent scaling methods", "severity": "high"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Pipeline C... | ["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 | E |
4,508 | from sklearn.metrics import mean_squared_log_error
from sklearn.metrics import make_scorer
def rmsle(y,y_pred):
return np.sqrt(mean_squared_log_error(y,y_pred))
rmsle_score=make_scorer(rmsle) | Yes | 4 | 49 | Model_Evaluation | compute_test_metric | 7,945,399 | 1 | A | 0 | 1 | 0 | 0 | 0 | 5 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing Checker", "fix": "Write unit tests for data processing and model components.", "benefits": "Ensures code reliability and prevents bugs.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Unit Testing Checker"] | 7 | A |
4,509 | from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import cross_val_score
rfr=RandomForestRegressor(random_state=42)
score=cross_val_score(rfr,X_train_scaled,y_train,cv=15,scoring=rmsle_score)
print(f'Score rmsle mean: {np.round(score.mean(),4)}')
print(f'Score rmsle std: {np.round(scor... | Yes | 5 | 28 | Model_Train | compute_train_metric | 7,945,399 | 1 | A | 1 | 0 | 0 | 0 | 5 | 6 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Verbose Mode Checker", "fix": "Enable verbose mode for long training processes.", "benefits": "Provides better insights into model training progress.", "location": "Line 11"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": ... | A | no applicable ML-specific findings | [] | ["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 7 | A |
4,510 | rfr.fit(X_train_scaled,y_train)
y_pred=rfr.predict(X_test_scaled) | Yes | 4 | 7 | Model_Train | train_model | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | 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"] | 7 | B |
4,511 | submission=pd.read_csv('/kaggle/input/bike-sharing-demand/sampleSubmission.csv')
submission['count']=y_pred
submission.to_csv('submissionI.csv',index=False) | Yes | 4 | 25 | Data_Export | save_to_csv | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | 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 8"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 7 | A |
4,512 | #Without Scaling Data
rfr.fit(X_train,y_train)
y_pred=rfr.predict(X_test)
submission2=pd.read_csv('/kaggle/input/bike-sharing-demand/sampleSubmission.csv')
submission2['count']=y_pred
submission2.to_csv('submissionII.csv',index=False) | Yes | 4 | 7 | Model_Train | train_model | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | 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... | 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", "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"] | 7 | B |
4,513 | from sklearn.model_selection import GridSearchCV, train_test_split
x_train2,x_test2,y_train2,y_test2=train_test_split(X_train,y_train,test_size=0.25,random_state=42)
params={'n_estimators': [10,50,100,300,500],
'n_jobs':[-1],
'max_features':['auto','sqrt','log2'],
'random_state':[42]}
rfr_tuned... | Yes | 4 | 6 | Hyperparam_Tuning | train_on_grid | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 10 | ok | 6 | 4 | [{"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 18"}, {"detector": "framework_specific", "framework": "ScikitL... | B | Randomness Control Checker=low | [{"type": "Randomness Control Checker", "severity": "low"}] | ["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 7 | B |
4,514 | from sklearn.ensemble import RandomForestRegressor
rfr_final=RandomForestRegressor(bootstrap=True, criterion='mse', max_depth=None,
max_features='auto', max_leaf_nodes=None,
min_impurity_decrease=0.0, min_impurity_split=None,
min_samples_leaf=1, min_sam... | Yes | 3 | 7 | Model_Train | train_model | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 11 | ok | 7 | 6 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Cross-validation not detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not 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"] | 7 | B |
4,515 | rfr_final=RandomForestRegressor(bootstrap=True, criterion='mse', max_depth=None,
max_features='auto', max_leaf_nodes=None,
min_impurity_decrease=0.0, min_impurity_split=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fract... | Yes | 3 | 7 | Model_Train | train_model | 7,945,399 | 1 | A | 0 | 0 | 0 | 0 | 0 | 12 | 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 | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "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"] | 7 | B |
4,516 | # 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 | 8,477,639 | 1 | A | 0 | 2 | 3 | 0 | 0 | 8 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: /kaggle/input. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 17"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 3 | A |
4,517 | train = pd.read_csv("/kaggle/input/bike-sharing-demand/train.csv",parse_dates=["datetime"])
train.head() | Yes | 4 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,518 | test = pd.read_csv("/kaggle/input/bike-sharing-demand/test.csv",parse_dates=["datetime"])
test.head() | Yes | 4 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,519 | train.info()
test.info() | No | 5 | 40 | Debug | show_table_attributes | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,520 | train["year"] = train["datetime"].dt.year
train["month"] = train["datetime"].dt.month
train["hour"] = train["datetime"].dt.hour
train["dayofweek"] = train["datetime"].dt.dayofweek
train.shape | Yes | 5 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,521 | test["year"] = test["datetime"].dt.year
test["month"] = test["datetime"].dt.month
test["hour"] = test["datetime"].dt.hour
test["dayofweek"] = test["datetime"].dt.dayofweek
test.shape | Yes | 4 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,522 | for var in categorical_feature:
train[var] = train[var].astype("category")
test[var] = test[var].astype("category")
train.info() | Yes | 5 | 16 | Data_Transform | data_type_conversions | null | 1 | A | 0 | 1 | 1 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,523 | X_train = train[feature]
X_test = test[feature]
X_train.head() | Yes | 3 | 21 | Data_Transform | prepare_x_and_y | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,524 | Y_train = train["count"]
Y_train.head() | Yes | 3 | 41 | Debug | show_table | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,525 | model = RandomForestRegressor(n_estimators=500)
Y_train_log = np.log1p(Y_train)
model.fit(X_train,Y_train_log)
result = model.predict(X_test) | Yes | 4 | 7 | Model_Train | train_model | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,526 | sub = pd.read_csv("/kaggle/input/bike-sharing-demand/sampleSubmission.csv")
sub.head() | Yes | 4 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,527 | sub["count"] = np.exp(result)
sub.head() | Yes | 5 | 55 | Data_Export | prepare_output | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,528 | sub.to_csv("20_03_29sub.csv",index=False) | No | 5 | 25 | Data_Export | save_to_csv | 8,477,639 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
4,530 | import calendar
import seaborn as sb
import xgboost as xgb
import plotly.express as px
import pandas_profiling as pp
import matplotlib.pyplot as plt
from plotly.subplots import make_subplots
from sklearn.tree import DecisionTreeRegressor
from sklearn.ensemble import RandomForestRegressor
from sklearn.preprocessing impo... | No | 5 | 22 | Environment | import_modules | 8,791,489 | 1 | A | 0 | 0 | 0 | 0 | 0 | 13 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 8 | A |
4,531 | #Reading the file
df_train = pd.read_csv("/kaggle/input/bike-sharing-demand/train.csv") | No | 5 | 45 | Data_Extraction | load_from_csv | 8,791,489 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | 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 10"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 8 | A |
4,532 | pp.ProfileReport(df_train) | 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,533 | df_train.isnull().sum(axis=0) | No | 5 | 39 | EDA | count_missing_values | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,534 | corr = df_train[['temp','atemp','humidity', 'windspeed','casual', 'registered',
'count']].corr()
f,axes = plt.subplots(1,1,figsize = (8,8))
sb.heatmap(corr,square=True,annot = True,linewidth = .5,center = 1.4,ax = axes) | No | 5 | 80 | Visualization | heatmap | 8,791,489 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}] | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | [] | 8 | B |
4,535 | y = ['casual','registered','count']
list_continuous = ['temp','atemp','humidity','windspeed']
n=3
s= 15
f,axes = plt.subplots(4,3,figsize = (s,s))
counter = 0
for i in list_continuous:
for j in y:
sb.lineplot(x = i , y = j , data = df_train, ax = axes[counter//n][counter%n])
counter+=1 | No | 4 | 33 | Visualization | distribution | 8,791,489 | 1 | A | 0 | 2 | 3 | 0 | 0 | 10 | 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": "Magic number detected... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Magic number"] | 8 | A |
4,536 | df_train['Date'] = pd.DatetimeIndex(df_train['datetime']).date
df_train['Hour'] = pd.DatetimeIndex(df_train['datetime']).hour
df_train['Day'] = pd.DatetimeIndex(df_train['datetime']).day
df_train['Month'] = pd.DatetimeIndex(df_train['datetime']).month
df_train['Year'] = pd.DatetimeIndex(df_train['datetime']).year
df_tr... | No | 5 | 8 | Data_Transform | feature_engineering | 8,791,489 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | 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"] | 8 | A |
4,537 | a = []
for i in df_train.index:
a.append('Total Count : '+str(df_train['count'][i]))
df_train['count_vis'] = a | No | 2 | 12 | Data_Transform | create_dataframe | 8,791,489 | 1 | A | 0 | 1 | 1 | 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"] | 8 | A |
4,538 | fig = px.line(x = 'Date', y = "count", data_frame = df_train,color = 'Hour',
range_y = (0,1150),hover_data = ['Hour','Date','casual','registered'],
title = 'Interactive LinePlot of the whole dataset(Hover for more details)',
hover_name = 'count_vis', text = None,height = 670,wi... | No | 5 | 75 | Visualization | time_series | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,539 | f,axes = plt.subplots(1,3,figsize = (17,7))
sb.despine(left = True)
x = 'season'
sb.barplot(x = x , y = 'casual' , data = df_train, saturation = 1, ax = axes[0])
sb.barplot(x = x , y = 'registered' , data = df_train, saturation = 1, ax = axes[1])
sb.barplot(x = x , y = 'count' , data = df_train, saturation = 1, ax = ... | No | 5 | 33 | Visualization | distribution | 8,791,489 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | 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"] | 8 | A |
4,540 | f,axes = plt.subplots(1,3,figsize = (17,7))
sb.despine(left = True)
x = 'holiday'
sb.barplot(x = x , y = 'casual' , data = df_train, saturation = 1, ax = axes[0] ,)
sb.barplot(x = x , y = 'registered' , data = df_train, saturation = 1, ax = axes[1])
sb.barplot(x = x , y = 'count' , data = df_train, saturation = 1, ax... | No | 5 | 33 | Visualization | distribution | 8,791,489 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | 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"] | 8 | A |
4,541 | f,axes = plt.subplots(1,3,figsize = (17,7))
sb.despine(left = True)
x = 'workingday'
sb.barplot(x = x , y = 'casual' , data = df_train, saturation = 1, ax = axes[0] ,)
sb.barplot(x = x , y = 'registered' , data = df_train, saturation = 1, ax = axes[1])
sb.barplot(x = x , y = 'count' , data = df_train, saturation = 1,... | No | 5 | 33 | Visualization | distribution | 8,791,489 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | 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"] | 8 | A |
4,542 | f,axes = plt.subplots(1,3,figsize = (17,7))
sb.despine(left = True)
x = 'weather'
sb.barplot(x = x , y = 'casual' , data = df_train, saturation = 1, ax = axes[0] )
sb.barplot(x = x , y = 'registered' , data = df_train, saturation = 1, ax = axes[1])
sb.barplot(x = x , y = 'count' , data = df_train, saturation = 1, ax ... | No | 5 | 33 | Visualization | distribution | 8,791,489 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | 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"] | 8 | A |
4,543 | f,axes = plt.subplots(1,3,figsize = (19,7))
sb.despine(left = True)
x = 'Hour'
sb.barplot(x = x , y = 'casual' , data = df_train, saturation = 1, ax = axes[0] ,)
sb.barplot(x = x , y = 'registered' , data = df_train, saturation = 1, ax = axes[1])
sb.barplot(x = x , y = 'count' , data = df_train, saturation = 1, ax = ... | No | 5 | 75 | Visualization | time_series | 8,791,489 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | 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"] | 8 | A |
4,544 | df_train.groupby('Weekday').count().index | No | 3 | 60 | Data_Transform | groupby | 8,791,489 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | [] | 8 | B |
4,545 | df_train_temp = df_train.groupby(['Hour','Weekday']).mean().reset_index()
dic = {'Weekday':['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday',
'Sunday']}
dic1 = {'registered':'Average count of registered poeple commuting.',
'count': 'Average people commuting','Hour':'Hour of the da... | No | 5 | 75 | Visualization | time_series | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,546 | df_train_temp = df_train.groupby(['Hour','Weekday']).mean().reset_index()
dic = {'Weekday':['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday',
'Sunday']}
dic1 = {'casual':'Average count of casual poeple commuting.',
'count': 'Average people commuting','Hour':'Hour of the day',
... | No | 5 | 75 | Visualization | time_series | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,547 | f,axes = plt.subplots(1,3,figsize = (19,7))
sb.despine(left = True)
x = 'Day'
sb.barplot(x = x , y = 'casual' , data = df_train, saturation = 1, ax = axes[0] ,)
sb.barplot(x = x , y = 'registered' , data = df_train, saturation = 1, ax = axes[1])
sb.barplot(x = x , y = 'count' , data = df_train, saturation = 1, ax = a... | No | 5 | 33 | Visualization | distribution | 8,791,489 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | 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"] | 8 | A |
4,548 | f,axes = plt.subplots(1,3,figsize = (19,7))
sb.despine(left = True)
x = 'Month'
#order = ['January','February','March','April','May','June','July','August','September','October','November','December']
plot = sb.barplot(x = x , y = 'casual' , data = df_train, saturation = 1, ax = axes[0])
sb.barplot(x = x , y = 'regist... | No | 5 | 75 | Visualization | time_series | 8,791,489 | 1 | A | 1 | 0 | 0 | 0 | 5 | 6 | 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"] | 8 | A |
4,549 | f,axes = plt.subplots(1,3,figsize = (19,7))
sb.despine(left = True)
x = 'Year'
sb.barplot(x = x , y = 'casual' , data = df_train, saturation = 1, ax = axes[0] ,)
sb.barplot(x = x , y = 'registered' , data = df_train, saturation = 1, ax = axes[1])
sb.barplot(x = x , y = 'count' , data = df_train, saturation = 1, ax = ... | No | 5 | 33 | Visualization | distribution | 8,791,489 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | 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"] | 8 | A |
4,550 | df_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,551 | for i in df_train.groupby('season').count().index:
s = 's'+str(i)
a=[]
for j in df_train.season:
if j==i:
a.append(1)
else:
a.append(0)
df_train[s]=a
df_train.sample(5) | Yes | 3 | 12 | Data_Transform | create_dataframe | 8,791,489 | 1 | A | 0 | 3 | 7 | 0 | 0 | 10 | 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"] | 8 | B |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.