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,349 | teste[['datetime', 'count']].to_csv('rf.csv' ,index=False) | No | 5 | 25 | Data_Export | save_to_csv | 6,602,052 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
4,350 | # verificando o df de treino
df.info() | 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,351 | b"# vamos transformar os dados. toda a transformao dever ser replicada nos dados de teste\n\n# aplicar log na varivel de resposta\n\ndf['count'] = np.log(df['count'])" | 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,352 | #apendando os dois para poder fazer a transformao de uma dez s. depois separa
df = df.append(test)' | No | 5 | 11 | Data_Transform | concatenate | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,353 | #convertendo a coluna datetime
df['datetime'] = pd.to_datetime(df['datetime']) | No | 5 | 16 | Data_Transform | data_type_conversions | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,354 | #criando novas colunas usando data e hora
df['year'] = df['datetime'].dt.year
df['month'] = df['datetime'].dt.month
df['day'] = df['datetime'].dt.day
df['hour'] = df['datetime'].dt.hour
df['dayofweek'] = df['datetime'].dt.dayofweek | No | 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,355 | b"# dividir os dados que foram juntados para a transformao - treino e teste. se estiver dado nulo nas tres variveis target\n# pertence ao df de teste\n\n# primeiro os dados de teste\ntest = df[df['count'].isnull()]" | No | 5 | 13 | Data_Transform | split | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,356 | b"# agora os dados de treino o sinal de til a negao quando uma comparao no est envolvida\n\ndf = df[~df['count'].isnull()]" | No | 5 | 14 | Data_Transform | filter | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,357 | # dividindo o df de treino
# importando o scikitlearn para a diviso da base
from sklearn.model_selection import train_test_split' | No | 5 | 22 | Environment | import_modules | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
4,358 | #dividir 75% treino e 25% validao - padro
train, valid = train_test_split(df, random_state=42)
' | No | 5 | 13 | Data_Transform | split | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,359 | b"#escolher as colunas que vo ser usadas e as que no\n\n# lista das colunas no usadas\nremoved_cols = ['casual', 'registered', 'count', 'datetime']\n\n#lista das columas de entrada\n\nfeats = [c for c in train.columns if c not in removed_cols]\n" | No | 2 | 14 | Data_Transform | filter | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,360 | feats | No | 3 | 71 | Debug | show_columns | null | 1 | A | 0 | 0 | 0 | 1 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,361 | # usando o random forest
# importando o modelo
from sklearn.ensemble import RandomForestRegressor | No | 5 | 22 | Environment | import_modules | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 0 | A |
4,362 | # instanciar o modelo
rf = RandomForestRegressor(random_state=42,n_jobs=-1)
#n_jobs nr de job que rodam e paralalo para dar o fit. -1 #para usar todos os processadores
#n_estimator - nro de arvores. o defalt 10 mas mudar para 100 na proxima verso 0.22
' | No | 5 | 4 | Model_Train | choose_model_class | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,363 | #treinar o modelo com os dados de treino
rf.fit(train[feats], train['count']) | No | 5 | 7 | Model_Train | train_model | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,364 | #faznedo as previses em cima dos dados de validao
preds = rf.predict(valid[feats])' | No | 5 | 48 | Model_Evaluation | predict_on_test | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,365 | b"#aplicando a mtrica\nmean_squared_error(valid['count'], preds) ** (1/2)\n" | No | 5 | 49 | Model_Evaluation | compute_test_metric | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,366 | train_preds = rf.predict(train[feats]) | No | 5 | 27 | Model_Train | predict_on_train | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,367 | # aplicando nos dados de treino
#dados conhecidos
mean_squared_error(train['count'], train_preds) ** (1/2) | No | 5 | 28 | Model_Train | compute_train_metric | null | 1 | A | 0 | 0 | 0 | 1 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,368 |
test['count'] = np.exp(rf.predict(test[feats])) | No | 5 | 48 | Model_Evaluation | predict_on_test | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,369 | test[['datetime', 'count']].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,370 | b"#Aumentar a floresta - 200 rvores\n# instanciar o modelo\nrf2 = RandomForestRegressor(random_state=42,n_jobs=-1, n_estimators=200, min_samples_leaf=5)\n#n_jobs nr de job que rodam e paralalo para dar o fit. -1 #para usar todos os processadores\n#n_estimator - nro de arvores. o defalt 10 mas mudar para 100 na proxi... | Yes | 4 | 7 | Model_Train | train_model | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,371 | #Gerando o novo arquivo
test['count'] = np.exp(rf2.predict(test[feats]))
#visualizando o arquivo para envio
test[['datetime', 'count']].to_csv('rf2.csv', index=False) | Yes | 5 | 25 | Data_Export | save_to_csv | 6,702,048 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing Checker", "fix": "Write unit tests for data processing and model components.", "benefits": "Ensures code reliability and prevents bugs.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Excepti... | A | no applicable ML-specific findings | [] | ["Exception Handling Checker", "Unit Testing Checker"] | 5 | A |
4,372 | #Pandas Rolling
df = df.append(test) | No | 5 | 11 | Data_Transform | concatenate | 6,702,048 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
4,373 | #ordenando o dataframe
df.sort_values('datetime', inplace=True) | No | 5 | 9 | Data_Transform | sort_values | 6,702,048 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 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 8"}] | A | no applicable ML-specific findings | [] | ["InPlace Checker"] | 5 | A |
4,374 | #Criando a coluna rolling_temp
df['rolling_temp'] = df['temp'].rolling(3,min_periods=1).mean() | No | 4 | 8 | Data_Transform | feature_engineering | 6,702,048 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 5 | A |
4,375 | #Criando a coluna rolling_atemp
df['rolling_atemp'] = df['atemp'].rolling(3,min_periods=1).mean() | No | 5 | 8 | Data_Transform | feature_engineering | 6,702,048 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 5 | A |
4,376 | #Separando os dataframes
test = df[df['casual'].isnull()]
df = df[~df['casual'].isnull()] | No | 5 | 14 | Data_Transform | filter | 6,702,048 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 5 | A |
4,377 | # Dividindo os dados de treino em train and validation
train, valid = train_test_split(df, random_state=42) | No | 5 | 13 | Data_Transform | split | 6,702,048 | 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"}] | [] | 5 | B |
4,378 | #escolher as colunas que vo ser usadas
#lista das columas de entrada
feats = [c for c in train.columns if c not in removed_cols]' | No | 3 | 14 | Data_Transform | filter | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,379 | b"#Novo modelo usando colunas roling\n# instanciar o modelo\nrf3 = RandomForestRegressor(random_state=42,n_jobs=-1, n_estimators=200, min_samples_leaf=5)\n#n_jobs nr de job que rodam e paralalo para dar o fit. -1 #para usar todos os processadores\n#n_estimator - nro de arvores. o defalt 10 mas mudar para 100 na prox... | Yes | 3 | 7 | Model_Train | train_model | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,380 | #Gerando o novo arquivo
test['count'] = np.exp(rf3.predict(test[feats]))
#visualizando o arquivo para envio
test[['datetime', 'count']].to_csv('rf3.csv', index=False) | Yes | 4 | 48 | Model_Evaluation | predict_on_test | 6,702,048 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing Checker", "fix": "Write unit tests for data processing and model components.", "benefits": "Ensures code reliability and prevents bugs.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Excepti... | A | no applicable ML-specific findings | [] | ["Exception Handling Checker", "Unit Testing Checker"] | 5 | A |
4,381 | # import modules
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import GridSearchCV
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import Ridge
from sklearn.linear_model import Lasso
from matplotlib import pyplot as plt
from datetime import datetime as dt
imp... | Yes | 3 | 45 | Data_Extraction | load_from_csv | 6,774,944 | 1 | A | 2 | 0 | 0 | 0 | 10 | 12 | 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,382 | # create date feature from datetime
trainset.insert(1, 'date', pd.DataFrame([x[:10] for x in trainset.datetime]))
# create time feature from datetime
trainset.insert(2, 'time', pd.DataFrame([x[11:] for x in trainset.datetime]))
# convert datetime from string to datetime
trainset.date = [dt.strptime(x, '%Y-%m-%d').weekd... | Yes | 4 | 16 | Data_Transform | data_type_conversions | 6,774,944 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 5 | 5 | [{"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "Assign operations to a new DataFrame variable.", "benefits": "Prevents data loss and improves code clarity.", "location": "Line 15"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker"... | 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", "InPlace Checker"] | 7 | B |
4,383 | # get index of the time elements in unique list
_, idx = np.unique(trainset.time, return_inverse = True)
# replace time feature with the index just computed
trainset.time = idx
# trainset quick view
trainset.head() | No | 5 | 8 | Data_Transform | feature_engineering | 6,774,944 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | 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,384 | # date - count boxplot
plt.figure(), sns.boxplot(x = trainset['date'], y = trainset['count']) | No | 5 | 75 | Visualization | time_series | 6,774,944 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 7 | A |
4,385 | # check sum of nulls
trainset.isnull().sum() | No | 5 | 39 | EDA | count_missing_values | 6,774,944 | 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,386 | # draw the pairplot of the variables
plt.figure(), sns.pairplot(trainset)
# check target boxplot to see outliers
plt.figure(), sns.boxplot(trainset['count']) | Yes | 5 | 81 | Visualization | relationship | 6,774,944 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 7 | A |
4,387 | # apply log transform to remove the number of outliers
trainset['count'] = np.log(trainset['count'])
# repeat pairplot
plt.figure(), sns.pairplot(trainset)
# repeat boxplot
plt.figure(), sns.boxplot(trainset['count']) | Yes | 5 | 81 | Visualization | relationship | 6,774,944 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 7 | A |
4,388 | # variables correlation heatmap
plt.figure(figsize = (10,10)), sns.heatmap(trainset.corr()) | No | 5 | 80 | Visualization | heatmap | 6,774,944 | 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,389 | # remove features highly correlated
trainset.drop(['casual','registered','temp'], axis = 1, inplace = True)
# graph heatmap again
plt.figure(figsize = (10,10)), sns.heatmap(trainset.corr()) | Yes | 3 | 10 | Data_Transform | drop_column | 6,774,944 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 4 | 4 | [{"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 9"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Chec... | 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"}] | ["InPlace Checker"] | 7 | B |
4,390 | # group time values into day segments
trainset.time = [0 if x >= 0 and x < 6 else(1 if x > 5 and x < 13 else (2 if x > 12 and x < 19 else 3)) for x in trainset.time]
# trainset quick view
trainset.head() | Yes | 4 | 16 | Data_Transform | data_type_conversions | 6,774,944 | 1 | A | 0 | 6 | 9 | 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,391 | # get original datetime column for submission
testdates = testset.datetime
# create date feature from datetime
testset.insert(1, 'date', pd.DataFrame([x[:10] for x in testset.datetime]))
# create time feature from datetime
testset.insert(2, 'time', pd.DataFrame([x[11:] for x in testset.datetime]))
# convert datetime fr... | Yes | 5 | 8 | Data_Transform | feature_engineering | 6,774,944 | 1 | A | 0 | 8 | 11 | 0 | 0 | 12 | ok | 4 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "Assign operations to a new DataFrame variable.", "benefits": "Prevents data loss and improves code clarity.", "location": "Line 17"}, {"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": ... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "InPlace Checker"] | 7 | A |
4,392 | # features
Xtrain = trainset.iloc[:,:-1]
Xtest = testset.iloc[:,:]
# target
ytrain = trainset.iloc[:,-1]
# standard scaler
sca = StandardScaler().fit(Xtrain)
# standarize features
Xtrain = sca.transform(Xtrain)
Xtest = sca.transform(Xtest)
# classifier
clf = RandomForestRegressor(random_state = 0)
# regularization para... | Yes | 3 | 6 | Hyperparam_Tuning | train_on_grid | 6,774,944 | 1 | A | 0 | 0 | 0 | 0 | 0 | 13 | ok | 16 | 8 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Pipeline Che... | E | Data Leakage Checker=high, Inconsistent scaling methods=high, Pipeline Checker=low | [{"type": "Data Leakage Checker", "severity": "high"}, {"type": "Inconsistent scaling methods", "severity": "high"}, {"type": "Pipeline Checker", "severity": "low"}] | ["Column Selection Checker", "Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 7 | E |
4,393 | import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from scipy.special import boxcox, inv_boxcox
train_df=pd.read_csv('../input/train.csv')
train_df.describe() | No | 3 | 45 | Data_Extraction | load_from_csv | 6,901,265 | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/train.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 9"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 2 | A |
4,394 | sns.boxplot(train_df['count'])
plt.show()
cnt=train_df['count'].values
q99=np.percentile(cnt,[99])
train_df=train_df[train_df['count']<q99[0]]
sns.distplot(train_df['count'])
plt.show() | Yes | 5 | 33 | Visualization | distribution | 6,901,265 | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | 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,395 | from scipy.stats import boxcox
sns.distplot(boxcox(train_df['count'])[0])
plt.show()
sns.distplot(train_df['count'].apply(lambda x:np.log(x)))
plt.show()
sns.distplot(train_df['count'].apply(lambda x:x**0.5))
plt.show()
train_df['count']=train_df['count'].apply(lambda x:np.log(x)) | Yes | 3 | 33 | Visualization | distribution | 6,901,265 | 1 | A | 0 | 0 | 0 | 0 | 0 | 8 | 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,396 |
from datetime import datetime
#converting string dattime to datetime
train_df['datetime']=train_df['datetime'].apply(lambda x:datetime.strptime(x,'%Y-%m-%d %H:%M:%S'))
new_df=train_df
new_df['month']=new_df['datetime'].apply(lambda x:x.month)
new_df['hour']=new_df['datetime'].apply(lambda x:x.hour) | Yes | 5 | 8 | Data_Transform | feature_engineering | 6,901,265 | 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,397 | new_df.cov()
sns.heatmap(new_df.corr())
plt.show()
sns.boxplot('windspeed',data=train_df)
| Yes | 5 | 80 | Visualization | heatmap | 6,901,265 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
4,398 | new_df.corr() | 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,399 | '''
humid + temp + month + hour + season + weather
humid + temp + month + hour
humid + temp + month
humid + temp
'''
final_df=new_df.drop(['datetime', 'holiday', 'workingday', 'atemp', 'windspeed', 'casual', 'registered'], axis=1)
#final_df=new_df.drop(['datetime', 'holiday', 'workingday', 'atemp', 'windspeed', 'casu... | Yes | 4 | 10 | Data_Transform | drop_column | 6,901,265 | 4 | D | 4 | 0 | 0 | 0 | 20 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | D |
4,400 |
weather_df=pd.get_dummies(new_df['weather'],prefix='w',drop_first=True)
#year_df=pd.get_dummies(new_df['year'],prefix='y',drop_first=True)
month_df=pd.get_dummies(new_df['month'],prefix='m',drop_first=True)
hour_df=pd.get_dummies(new_df['hour'],prefix='h',drop_first=True)
season_df=pd.get_dummies(new_df['season'],pref... | Yes | 4 | 20 | Data_Transform | categorify | 6,901,265 | 1 | A | 4 | 0 | 0 | 0 | 20 | 48 | 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,401 |
X=final_df.iloc[:,final_df.columns!='count'].values
print (X)
Y=final_df.iloc[:,4].values
# Y=final_df.iloc[:,2].values
print (Y) | No | 3 | 21 | Data_Transform | prepare_x_and_y | 6,901,265 | 1 | A | 1 | 0 | 0 | 0 | 5 | 4 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
4,402 | import xgboost as xg
xgr=xg.XGBRegressor(max_depth=8,min_child_weight=6,gamma=0.4)
xgr.fit(X,Y)
'''import xgboost as xg
from sklearn.model_selection import GridSearchCV
def grid_search():
xgr=xg.XGBRegressor(max_depth=8,min_child_weight=6,gamma=0.4)
xgr.fit(X,Y)
#rf=RandomForestRegressor(n_estimator... | Yes | 5 | 6 | Hyperparam_Tuning | train_on_grid | 6,901,265 | 1 | A | 1 | 0 | 0 | 0 | 5 | 31 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: import xgboost as xg\nfrom sklearn.model_selection import GridSearchCV\n\ndef grid_search():\n\n xgr=xg.XGBRegressor(max_depth=8,min_child_weight=6,gamma=0.4)\n xgr.fit(X,Y)\n\n #rf=RandomForestRegressor(n_estimators=... | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 2 | A |
4,404 | new_df.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,405 | new_df=pd.read_csv('../input/test.csv')
test_df=pd.read_csv('../input/test.csv')
new_df['datetime']=new_df['datetime'].apply(lambda x:datetime.strptime(x,'%Y-%m-%d %H:%M:%S'))
new_df['month']=new_df['datetime'].apply(lambda x:x.month)
new_df['hour']=new_df['datetime'].apply(lambda x:x.hour)
weather_df=pd.get_dummies... | Yes | 3 | 45 | Data_Extraction | load_from_csv | 6,901,265 | 1 | A | 0 | 0 | 0 | 0 | 0 | 15 | 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,406 | import xgboost as xg
xgr=xg.XGBRegressor(max_depth=8,min_child_weight=6,gamma=0.4,colsample_bytree=0.6,subsample=0.6)
xgr.fit(X,Y)
X_test=new_df.iloc[:,:].values
X_test.shape
#print (new_df.columns)
y_output=xgr.predict(X_test)
y_output
test_df['count'] = pd.Series(np.exp(y_output))
test_df = test_df.drop(['humidity... | Yes | 3 | 7 | Model_Train | train_model | 6,901,265 | 1 | A | 0 | 0 | 0 | 1 | 0 | 10 | 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,407 | # This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load in
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O... | Yes | 5 | 88 | Debug | list_files | null | 1 | A | 0 | 2 | 3 | 0 | 0 | 6 | 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 12"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 0 | A |
4,408 | train = pd.read_csv('/kaggle/input/bike-sharing-demand/train.csv',parse_dates = ["datetime"])# object
train.head(30) # 5 .() .
train['hour']=train['datetime'].dt.hour #hour, year
train['year'] = train['datetime'].dt.year
train['dayofweek']=train['datetime'].dt.dayofweek #weekday
train['day']=train['da... | 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,409 | test = pd.read_csv('/kaggle/input/bike-sharing-demand/test.csv',parse_dates = ["datetime"])# (count) .
test['hour'] = test['datetime'].dt.hour
test['year'] = test['datetime'].dt.year
test['dayofweek']=test['datetime'].dt.dayofweek
test['day']=test['datetime'].dt.day
test['month']=test['datetime'].dt.month
#test['we... | 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,410 | b"weekday_df=train[train['workingday']==1] # ==. workingday 1 True => True . \nprint(weekday_df.shape) # \n\nweekend_df=train[train['workingday']==0]\nweekend_df.shape" | No | 4 | 14 | Data_Transform | filter | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,411 | b"import matplotlib.pyplot as plt # matplotlib \nimport seaborn as sns # \na,b = plt.subplots(1,1,figsize=(20,12)) #,, \nsns.boxplot(train['hour'],train['count']) #boxplot => (count), (hour) \n# => \n# => 25%\n# => \n# => . . \n# 10 ~15 . => 5 , . => .=> .\n" | Yes | 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,412 | b"a,b = plt.subplots(1,1,figsize=(20,12))\nsns.distplot(train['count'])# \n# \n# ,\n#1. . \n#2. .( )\n\n# y(train count) \n# train test . \n# ? => . . . \n#=> => y .\n#=> . \n\n" | 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,413 | b"a,b = plt.subplots(1,1,figsize=(20,12)) \nsns.boxplot(train['month'],train['count']) #tree column 1 column . day column . " | 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,415 | a,b = plt.subplots(1,1,figsize=(20,12))
sns.boxplot(weekday_df['hour'],weekday_df['count']) | No | 5 | 75 | Visualization | time_series | 7,304,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 2 | A |
4,416 | a,b = plt.subplots(1,1,figsize=(20,12))
sns.boxplot(weekend_df['hour'],weekend_df['count']) | No | 5 | 75 | Visualization | time_series | 7,304,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 2 | A |
4,417 | figure, (a,b,c,d,e,f) = plt.subplots(nrows=6)
figure.set_size_inches(18,25)
sns.pointplot(train['hour'],train['count'], ax = a)
sns.pointplot(train['hour'],train['count'],hue = train['workingday'], ax = b)
sns.pointplot(train['hour'],train['count'],hue = train['holiday'], ax = c)
sns.pointplot(train['hour'],train['cou... | No | 5 | 75 | Visualization | time_series | 7,304,408 | 1 | A | 0 | 0 | 0 | 0 | 0 | 8 | 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,418 | b"print(train.groupby('year')['count'].mean()) # . \ntrain.groupby('year')['count'].median() #. => " | No | 2 | 40 | Debug | show_table_attributes | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,419 | b"train_2011=train[train['year']==2011] #2011 .\ntrain_2011.groupby('month')['count'].mean()\na,b=plt.subplots(1,1,figsize=(20,12))\nsns.boxplot(train_2011['month'],train['count'])" | No | 4 | 33 | Visualization | distribution | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,420 | b"print(train.groupby('dayofweek')['count'].mean()) # 0~6 => ~\ntrain.groupby('holiday')['count'].mean() # ?" | No | 3 | 40 | Debug | show_table_attributes | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,421 | b"train['dayofweek'].value_counts() # . . . " | 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,422 | train.dtypes #datetime object. . . | No | 5 | 70 | Debug | show_data_types | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,423 | b"train2 = train.drop(['datetime','casual','registered','count','month','day'],axis=1) # datetime, test 3 . . \n# train2 4 . axis=0 -> row . axis=1 -> column . \ntrain2.head()" | Yes | 5 | 10 | Data_Transform | drop_column | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,424 | b"test2 = test.drop(['datetime','month','day'],axis=1) # test datetime \ntest2.head()" | Yes | 4 | 10 | Data_Transform | drop_column | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,425 | b"# # \n# from sklearn.ensemble import RandomForestRegressor \n\n# # \n# rf = RandomForestRegressor(n_estimators=100,random_state=1,n_jobs=4) # / /\n\n#; 10-> => 100 / / \n#random_state => / n_jobs =4 , \n\n# # 100 ? => . train set \n# . test set a=b \n# \n\n# #\n# rf.fit(train2,np.log... | Yes | 4 | 7 | Model_Train | train_model | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,426 | Sub = pd.read_csv('/kaggle/input/bike-sharing-demand/sampleSubmission.csv')
Sub.head() | Yes | 4 | 45 | Data_Extraction | load_from_csv | 7,304,408 | 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,427 | b"Sub['count'] = np.exp(result) # #\nSub.head()" | Yes | 5 | 55 | Data_Export | prepare_output | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,428 | b"Sub.to_csv('20191231.csv',index=False) # index=False index=True . column 2. " | No | 5 | 25 | Data_Export | save_to_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,429 | import pandas as pd
%matplotlib inline
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
import warnings; warnings.simplefilter('ignore')
# Input data files are available in the "../input/" directory.
# For example, running this (by clicking run or pressing Shift+Ent... | Yes | 5 | 88 | Debug | list_files | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
4,430 | train=data=pd.read_csv('/kaggle/input/bike-sharing-demand/train.csv')
test=pd.read_csv('/kaggle/input/bike-sharing-demand/test.csv')
train.info()
Y1train=train['casual']
Y2train=train['registered']
Ytrain=train['count']
| No | 3 | 45 | Data_Extraction | load_from_csv | 7,673,227 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | 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."] | 2 | B |
4,431 | figure, axs = plt.subplots(nrows=3, ncols=2)
figure.set_size_inches(14,6)
sns.distplot(Ytrain, ax=axs[0][0], fit=norm)
sns.distplot(np.log(Ytrain+1), ax=axs[0][1], fit=norm)
sns.distplot(Y1train, ax=axs[1][0], fit=norm)
sns.distplot(np.log(Y1train+1), ax=axs[1][1], fit=norm)
sns.distplot(Y2train, ax=axs[2][0], fit=n... | No | 5 | 33 | Visualization | distribution | 7,673,227 | 1 | A | 0 | 0 | 0 | 0 | 0 | 8 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
4,432 | feature_names=list(test)
train=train[feature_names]
all_data=pd.concat((train, test))
print(train.shape, test.shape, all_data.shape)
print(Ytrain)
all_data['datetime']=pd.to_datetime(all_data['datetime'])
all_data['year']=all_data['datetime'].dt.year
all_data['month']=all_data['datetime'].dt.month
all_data['day']=all_... | Yes | 3 | 8 | Data_Transform | feature_engineering | 7,673,227 | 1 | A | 0 | 0 | 0 | 0 | 0 | 14 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
4,433 | Xtrain=all_data[:len(train)]
Xtest=all_data[len(train):]
Xtrain.info()
#"""
import itertools
import copy
tmpXtrain = copy.deepcopy(Xtrain)
tmpXtest = copy.deepcopy(Xtest)
for cmb in itertools.combinations_with_replacement(list(Xtrain.keys()), 2):
tmpXtrain["-".join(cmb)] = Xtrain[cmb[0]] * Xtrain[cmb[1]]
tmpXt... | Yes | 4 | 13 | Data_Transform | split | 7,673,227 | 1 | A | 0 | 1 | 1 | 0 | 0 | 10 | 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"}] | [] | 2 | B |
4,434 | !pip install optuna | No | 5 | 87 | Environment | install_modules | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,435 | import optuna.integration.lightgbm as lgb
from sklearn.model_selection import train_test_split
from sklearn import datasets
X_train, X_test, y_train, y_test = train_test_split(tmpXtrain, np.log1p(Y1train), test_size=0.1)
lgb_train = lgb.Dataset(X_train, y_train)
lgb_eval = lgb.Dataset(X_test, y_test, reference=lgb_tr... | Yes | 3 | 7 | Model_Train | train_model | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
4,436 | X_train, X_test, y_train, y_test = train_test_split(tmpXtrain, np.log1p(Y2train), test_size=0.1)
lgb_train = lgb.Dataset(X_train, y_train)
lgb_eval = lgb.Dataset(X_test, y_test, reference=lgb_train)
lgbm_params = {
'objective': 'regression',
'metric': 'rmse',
}
best_params, tuning_history = dict(), list()
boo... | Yes | 3 | 13 | Data_Transform | split | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,437 | pred_casual = booster_casual.predict(tmpXtest, num_iteration=booster_casual.best_iteration)
pred_casual = np.expm1(pred_casual)
pred_registered = booster_registered.predict(tmpXtest, num_iteration=booster_registered.best_iteration)
pred_registered = np.expm1(pred_registered)
pred = pred_casual + pred_registered
pred[... | Yes | 4 | 25 | Data_Export | save_to_csv | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,438 | b"# \nimport pandas as pd\nimport numpy as np\nimport seaborn as sns\nfrom matplotlib import pyplot as plt\nfrom sklearn import metrics\nfrom sklearn.linear_model import LinearRegression\nfrom sklearn.model_selection import train_test_split\nfrom pathlib import Path\nfrom IPython.display import display\nfrom datetime ... | Yes | 5 | 23 | Environment | set_options | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,439 | #
def load(path: Path) -> DataFrame:
# return pd.read_csv(path)
return pd.read_csv(path, parse_dates=True, index_col="datetime")' | No | 5 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,440 | ROOT_DIR = Path("/kaggle/input/bike-sharing-demand")
TRAIN_DATA_PATH = ROOT_DIR / "train.csv"
TEST_DATA_PATH = ROOT_DIR / "test.csv"
TARGET_NAME = 'count'
original_train: DataFrame = load(TRAIN_DATA_PATH)
original_test: DataFrame = load(TEST_DATA_PATH)' | No | 4 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,441 | original_train.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,442 | original_test.head() | No | 5 | 41 | Debug | show_table | 7,854,996 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 11 | A |
4,443 | only_train_columns = [c1 for c1 in original_train.columns if not c1 in original_test.columns and c1 != TARGET_NAME]
print('Only Train Columns')
print(only_train_columns)
only_test_columns = [c1 for c1 in original_test.columns if not c1 in original_train.columns]
print('Only Test Columns')
print(only_test_columns) | Yes | 3 | 13 | Data_Transform | split | 7,854,996 | 1 | A | 2 | 3 | 1 | 0 | 4 | 6 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 11 | A |
4,444 | original_train.isnull().sum() | No | 5 | 39 | EDA | count_missing_values | 7,854,996 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | 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,445 | original_test.isnull().sum() | No | 5 | 39 | EDA | count_missing_values | 7,854,996 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 11 | A |
4,446 | original_train.dtypes | No | 5 | 70 | Debug | show_data_types | 7,854,996 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 11 | A |
4,447 | original_test.dtypes | No | 5 | 70 | Debug | show_data_types | 7,854,996 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 11 | A |
4,448 | feature_columns = [c1 for c1 in original_train.columns if c1 in original_test.columns and c1 != TARGET_NAME]
feature_columns | No | 4 | 14 | Data_Transform | filter | 7,854,996 | 1 | A | 0 | 2 | 1 | 1 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 11 | A |
4,449 | sns.distplot(original_train[TARGET_NAME]) | No | 5 | 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,450 | def draw_distplot(df, name, fig, m, n, idx):
ax = fig.add_subplot(m, n, idx)
ax = sns.distplot(df[name])
def draw_distplots(df, columns):
M = round(len(columns)/2)
N = 2
fig = plt.figure(figsize=[N*10, M*6])
for idx, name in enumerate(columns):
draw_distplot(df=df, name=name, fig=fig, m... | 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_distplots. 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.