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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3,926 | sns.pointplot(x=df['temp'], y=df['count'])
fig = plt.gcf()
fig.set_size_inches(30,12); | No | 5 | 33 | Visualization | distribution | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,927 | sns.pointplot(x=df['atemp'], y=df['count'])
fig = plt.gcf()
fig.set_size_inches(30,12); | No | 5 | 33 | Visualization | distribution | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,928 | _, _, r_value, _, _ = stats.linregress(df['count'], df['atemp'])
r_square = r_value ** 2
r_square.round(2) | No | 5 | 47 | Model_Evaluation | statistical_test | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,929 | sns.pointplot(x=df['hour'], y=df['count'])
fig = plt.gcf()
fig.set_size_inches(30,12); | No | 5 | 75 | Visualization | time_series | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,930 | sns.pointplot(x=df['temp'], y=df['atemp'])
fig = plt.gcf()
fig.set_size_inches(30,12); | No | 5 | 33 | Visualization | distribution | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,931 | _, _, r_value, _, _ = stats.linregress(df['temp'], df['atemp'])
r_square = r_value ** 2
r_square.round(2) | No | 5 | 47 | Model_Evaluation | statistical_test | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,932 | df = df.drop(labels='atemp', axis=1) | No | 5 | 10 | Data_Transform | drop_column | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,933 | df = df.drop(labels='count_log', axis=1) | No | 5 | 10 | Data_Transform | drop_column | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,934 | df = df.drop(labels='count_boxcox', axis=1) | No | 5 | 10 | Data_Transform | drop_column | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,935 | df = pd.get_dummies(df, columns=['weather'])
df.head() | No | 5 | 20 | Data_Transform | categorify | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,936 | df = df.drop(labels='weather_4', axis=1)
df.head() | No | 5 | 10 | Data_Transform | drop_column | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,937 | df['temp_weath_1'] = df['temp'] * df['weather_1']
df['temp_weath_2'] = df['temp'] * df['weather_2']
df['temp_weath_3'] = df['temp'] * df['weather_3'] | No | 5 | 8 | Data_Transform | feature_engineering | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,938 | df['temp_weath_1'] = df['temp_weath_1'].astype(int)
df['temp_weath_2'] = df['temp_weath_2'].astype(int)
df['temp_weath_3'] = df['temp_weath_3'].astype(int) | No | 5 | 16 | Data_Transform | data_type_conversions | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,939 | X = df.loc[:, df.columns != 'count']
y = np.log(df['count']) | No | 5 | 21 | Data_Transform | prepare_x_and_y | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,940 | X.shape, y.shape | No | 5 | 58 | Debug | show_shape | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,941 | X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42, test_size=0.2) | No | 5 | 13 | Data_Transform | split | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,942 | X_train.shape, y_train.shape, X_test.shape, y_test.shape | No | 5 | 58 | Debug | show_shape | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,943 | from sklearn.linear_model import LinearRegression, Lasso, ElasticNet, Ridge
from sklearn.tree import DecisionTreeRegressor
from sklearn.neighbors import KNeighborsRegressor
from sklearn.ensemble import GradientBoostingRegressor, RandomForestRegressor
from sklearn.svm import SVR
from sklearn.pipeline import Pipeline, ma... | No | 5 | 22 | Environment | import_modules | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 9 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,944 | pipelines = []
pipelines.append(('ScaledLR', Pipeline([('Scaler', StandardScaler()), ('LR', LinearRegression())])))
pipelines.append(('ScaledLASSO', Pipeline([('poly', PolynomialFeatures()), ('Scaler', StandardScaler()), ('LASSO', Lasso(random_state=42))])))
pipelines.append(('ScaledRID', Pipeline([('poly', Polynomial... | No | 5 | 79 | Visualization | model_coefficients | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,945 | df_test = pd.read_csv("../input/test.csv") | No | 5 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,946 | df_test['datetime'] = pd.to_datetime(df_test['datetime']) | No | 5 | 16 | Data_Transform | data_type_conversions | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,947 | df_test['dow'] = df_test['datetime'].dt.dayofweek | No | 5 | 8 | Data_Transform | feature_engineering | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,948 | df_test['month'] = df_test['datetime'].dt.month | No | 5 | 8 | Data_Transform | feature_engineering | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,949 | df_test['week'] = df_test['datetime'].dt.week | No | 5 | 8 | Data_Transform | feature_engineering | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,950 | df_test['hour'] = df_test['datetime'].dt.hour | No | 5 | 8 | Data_Transform | feature_engineering | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,951 | df_test['year'] = df_test['datetime'].dt.year | No | 5 | 8 | Data_Transform | feature_engineering | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,952 | df_test['day'] = df_test['datetime'].dt.day | No | 5 | 8 | Data_Transform | feature_engineering | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,953 | df_test = df_test.drop(labels='datetime', axis=1) | No | 5 | 10 | Data_Transform | drop_column | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,954 | df_test = df_test.drop(labels='atemp', axis=1) | No | 5 | 10 | Data_Transform | drop_column | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,955 | df_test = pd.get_dummies(df_test, columns=['weather']) | No | 5 | 20 | Data_Transform | categorify | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,956 | df_test = df_test.drop(labels='weather_4', axis=1) | No | 5 | 10 | Data_Transform | drop_column | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,957 | df_test['temp_weath_1'] = df_test['temp'] * df_test['weather_1']
df_test['temp_weath_2'] = df_test['temp'] * df_test['weather_2']
df_test['temp_weath_3'] = df_test['temp'] * df_test['weather_3'] | No | 5 | 8 | Data_Transform | feature_engineering | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,958 | df_test['temp_weath_1'] = df_test['temp_weath_1'].astype(int)
df_test['temp_weath_2'] = df_test['temp_weath_2'].astype(int)
df_test['temp_weath_3'] = df_test['temp_weath_3'].astype(int) | No | 5 | 16 | Data_Transform | data_type_conversions | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,959 | standardscaler = StandardScaler()
model = XGBRegressor(colsample_bytree=0.7, learning_rate=0.05, max_depth=7, min_child_weight=4, subsample=0.7, random_state=42) | No | 5 | 4 | Model_Train | choose_model_class | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,960 | model.fit(X_train, y_train) | 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 |
3,961 | model.predict(df_test) | No | 5 | 48 | Model_Evaluation | predict_on_test | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing Checker", "fix": "Write unit tests for data processing and model components.", "benefits": "Ensures code reliability and prevents bugs.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Excepti... | A | no applicable ML-specific findings | [] | ["Exception Handling Checker", "Unit Testing Checker"] | 9 | A |
3,962 | pipe = Pipeline([('poly', PolynomialFeatures()), ('StandardScaler', standardscaler), ('XGBR', model)])
pipe.fit(X_train, y_train)
y_pred = np.exp(pipe.predict(df_test))
y_pred | Yes | 4 | 7 | Model_Train | train_model | 2,165,156 | 1 | A | 0 | 0 | 0 | 1 | 0 | 4 | ok | 8 | 7 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 9 | B |
3,963 | df_test[['count']].to_csv('submission.csv', index=True) | No | 5 | 25 | Data_Export | save_to_csv | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,964 | df_test[['count']].head() | No | 5 | 41 | Debug | show_table | 2,165,156 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
3,965 | # Carregar os dados
df = pd.read_csv('../input/train.csv', parse_dates=[0])
test = pd.read_csv('../input/test.csv', parse_dates=[0]) | No | 5 | 45 | Data_Extraction | load_from_csv | 3,750,732 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 3 | 2 | [{"detector": "general_ml", "framework": "General ML", "name": "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "fix": "Not specified", "benefits": "Not specified", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name": "Har... | A | no applicable ML-specific findings | [] | ["Hardcoded file path", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness."] | 5 | A |
3,966 | b"# Transformao da coluna datetime (feature engineering)\ndf['year'] = df['datetime'].dt.year\ndf['month'] = df['datetime'].dt.month\ndf['day'] = df['datetime'].dt.day\ndf['dayofweek'] = df['datetime'].dt.dayofweek\ndf['hour'] = df['datetime'].dt.hour" | 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 |
3,967 | # Ordenar os dados pela coluna datetime
df.sort_values('datetime', inplace=True) | No | 5 | 9 | Data_Transform | sort_values | 3,750,732 | 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 7"}] | A | no applicable ML-specific findings | [] | ["InPlace Checker"] | 5 | A |
3,968 | # Separando os dataframes
test = df[df['count'].isnull()]
df = df[~df['count'].isnull()] | No | 5 | 13 | Data_Transform | split | 3,750,732 | 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 |
3,969 | # Separando o df em treino e validao
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 |
3,970 | train, valid = train_test_split(df, random_state=42) | No | 5 | 13 | Data_Transform | split | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,971 | # Usar o modelo de RandomForest
# Importar o modelo
from sklearn.ensemble import RandomForestRegressor | No | 5 | 22 | Environment | import_modules | 3,750,732 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
3,972 | # Instanciar o modelo
rf = RandomForestRegressor(random_state=42) | No | 5 | 4 | Model_Train | choose_model_class | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,973 | # Treinar o modelo
rf.fit(train[feats], train['count']) | No | 5 | 7 | Model_Train | train_model | 3,750,732 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 5 | 5 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Column Selection Checker", "Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 5 | B |
3,974 | # Fazendo as previses
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 |
3,975 | # Analisar as previses com base na mtrica
# Importando a mtrica
from sklearn.metrics import mean_squared_error' | No | 5 | 22 | Environment | import_modules | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
3,976 | b"# Validando as previses\nmean_squared_error(valid['count'], preds) ** (1/2)" | 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 |
3,977 | # Melhorando o modelo de RandomForest
rf = RandomForestRegressor(random_state=42, n_estimators=200, n_jobs=-1) | No | 5 | 4 | Model_Train | choose_model_class | 3,750,732 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"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 7"}] | A | no applicable ML-specific findings | [] | ["Verbose Mode Checker"] | 5 | A |
3,978 | # Preparando os dados para o kaggle
# Criando as previses para os dados de teste
preds_test = rf.predict(test[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 |
3,979 | # Salvando o arquivo para o Kaggle
test[['datetime', 'count']].to_csv('rf.csv', index=False) | No | 5 | 25 | Data_Export | save_to_csv | 3,750,732 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
3,980 | df = pd.read_csv('../input/train.csv', parse_dates=[0])
test = pd.read_csv('../input/test.csv', parse_dates=[0]) | No | 5 | 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 |
3,981 | df.rename(columns={'count':'rentals'},inplace=True) | No | 5 | 61 | Data_Transform | rename_columns | 3,826,257 | 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 6"}] | A | no applicable ML-specific findings | [] | ["InPlace Checker"] | 5 | A |
3,982 | df = df.append(test, sort=False) | No | 5 | 11 | Data_Transform | concatenate | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,983 | df['year'] = df.datetime.dt.year # df['datetime'].dt.year
df['month'] = df.datetime.dt.month
df['day'] = df.datetime.dt.day
df['dayofweek'] = df.datetime.dt.dayofweek
df['hour'] = df['datetime'].dt.hour | No | 5 | 8 | Data_Transform | feature_engineering | 3,826,257 | 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"] | 5 | A |
3,984 | df.sort_index(inplace=True) | No | 5 | 9 | Data_Transform | sort_values | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,985 | # Separando os dataframes
test = df[df['rentals'].isnull()]
df = df[~df['rentals'].isnull()] | No | 5 | 13 | Data_Transform | split | 3,826,257 | 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 |
3,986 | from sklearn.model_selection import train_test_split
train, valid = train_test_split(df, random_state=42) | No | 5 | 13 | Data_Transform | split | 3,826,257 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}] | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | [] | 5 | B |
3,987 | from sklearn.ensemble import RandomForestRegressor
rf = RandomForestRegressor(random_state=42, n_estimators=100,n_jobs=-1) | Yes | 4 | 4 | Model_Train | choose_model_class | 3,826,257 | 2 | B | 1 | 0 | 0 | 0 | 5 | 2 | ok | 1 | 1 | [{"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 8"}] | A | no applicable ML-specific findings | [] | ["Verbose Mode Checker"] | 5 | B |
3,988 | rf.fit(train[feats],train['rentals']) | 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 |
3,989 | # Fazer as previses
preds = rf.predict(valid[feats])' | No | 4 | 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 |
3,990 | from sklearn.metrics import mean_squared_error
mean_squared_error(valid['rentals'],preds)**(1/2) | Yes | 4 | 49 | Model_Evaluation | compute_test_metric | 3,826,257 | 1 | A | 0 | 0 | 0 | 1 | 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 |
3,991 | b"# Adicionar as previses ao dataframe\ntest['count'] = np.exp(preds_test)-1\n" | No | 4 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,992 | test[['datetime','count']] | No | 5 | 41 | Debug | show_table | 3,826,257 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
3,993 | train, valid = df[df['day'] <= 15], df.query('day > 15') | No | 5 | 14 | Data_Transform | filter | 3,826,257 | 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 |
3,994 | # Preparando os dados para o kaggle
# Criando as previses para os dados de teste
preds_test = rf.predict(test[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 |
3,995 | # Salvando o arquivo pro kaggle
test[['datetime','count']].to_csv('rf2.csv', index=False)
| No | 5 | 25 | Data_Export | save_to_csv | 3,826,257 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
3,997 | from sklearn.ensemble import RandomForestRegressor
rf = RandomForestRegressor(random_state=42, n_estimators=100,n_jobs=-1,oob_score=True) | No | 5 | 4 | Model_Train | choose_model_class | 3,826,257 | 2 | B | 1 | 0 | 0 | 0 | 5 | 2 | ok | 1 | 1 | [{"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 8"}] | A | no applicable ML-specific findings | [] | ["Verbose Mode Checker"] | 5 | B |
3,998 | rf.fit(df[feats],df['rentals'])
rf.oob_score_ | No | 4 | 7 | Model_Train | train_model | 3,826,257 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 5 | 5 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Column Selection Checker", "Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 5 | B |
3,999 | # Fazer as previses
preds = rf.oob_prediction_' | Yes | 4 | 22 | Environment | import_modules | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,000 | from sklearn.metrics import mean_squared_error
mean_squared_error(df['rentals'],preds)**(1/2) | Yes | 4 | 7 | Model_Train | train_model | 3,826,257 | 1 | A | 0 | 0 | 0 | 1 | 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,001 | # Salvando o arquivo pro kaggle
test[['datetime','count']].to_csv('rf3.csv', index=False)
| No | 5 | 25 | Data_Export | save_to_csv | 3,826,257 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
4,002 | def cv(df, test, feats, y_name, k=5):
score, preds, fis = [], [], []
chunk = df.shape[0] // k
for i in range(k):
if i+1 < k:
valid = df.iloc[i*chunk: (i+1)*chunk]
train = df.iloc[:i*chunk].append(df.iloc[(i+1)*chunk:])
else:
... | No | 2 | 7 | Model_Train | train_model | 3,826,257 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 5 | null |
4,003 | score, preds, fis = cv(df, test, feats, 'rentals') | No | 5 | 49 | Model_Evaluation | compute_test_metric | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,004 | score | No | 2 | 7 | Model_Train | train_model | null | 1 | A | 0 | 0 | 0 | 1 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,005 | pd.Series(score).mean()
| No | 5 | 7 | Model_Train | train_model | 3,826,257 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | 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"] | 5 | A |
4,006 | test['count'] = np.exp(pd.DataFrame(preds).mean())-1
test[['datetime','count']].to_csv('rf4.csv', index=False)
| No | 5 | 25 | Data_Export | save_to_csv | 3,826,257 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
4,007 | import numpy as np
import pandas as pd
import pandas_profiling as pp
import seaborn as sns
import matplotlib.pyplot as plt
import os
import datetime | No | 5 | 22 | Environment | import_modules | 3,930,917 | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker"] | 6 | A |
4,008 | import warnings
warnings.filterwarnings('ignore') | No | 5 | 23 | Environment | set_options | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,009 | HOME_PATH = r'../input'
os.listdir(HOME_PATH) | No | 5 | 88 | Debug | list_files | 3,930,917 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}, {"detector": "general_ml", "framework": "Genera... | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker", "Hardcoded file path"] | 6 | A |
4,010 | train_set = pd.read_csv(HOME_PATH+'/train.csv') | No | 5 | 45 | Data_Extraction | load_from_csv | 3,930,917 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}, {"detector": "general_ml", "framework": "Genera... | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker", "Hardcoded file path"] | 6 | A |
4,011 | def month_to_num(df):
""" Convert month to numerical """
for i in range(1,10):
df['month'].loc[df['month']=='0'+str(i)] = i
for i in range(10,13):
df['month'].loc[df['month']==str(i)] = i' | No | 5 | 20 | Data_Transform | categorify | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,012 | def time_to_num(df):
""" Convert time to numerical """
for i in range(0,10):
df['time'].loc[df['time']=='0'+str(i)+':00:00'] = i
for i in range(10,24):
df['time'].loc[df['time']==str(i)+':00:00'] = i' | No | 5 | 20 | Data_Transform | categorify | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,013 | def weekend(df):
df['weekend'] = np.zeros_like(df['holiday'])
df['weekend'].loc[(df['workingday'] == 0) & (df['holiday'] == 0)] = 1 | No | 5 | 8 | Data_Transform | feature_engineering | 3,930,917 | 1 | A | 0 | 1 | 0 | 0 | 0 | 3 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "NumPy", "name": "Array Creation Efficiency", "fix": "Specify dtype when creating arrays.", "benefits": "Improves memory efficiency and avoids unnecessary conversions.", "location": "Line 8"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Sele... | A | no applicable ML-specific findings | [] | ["Array Creation Efficiency", "Column Selection Checker", "Dependent Threshold Checker"] | 6 | A |
4,014 | def weekday(df):
df['weekday'] = df['datetime'].apply(lambda date : \\
datetime.datetime.strptime(str(date.split()[0]),"%Y-%m-%d").weekday())' | No | 5 | 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,015 | def process_df(df):
split_datetime(df)
round_temp(df)
# month_to_num(df)
time_to_num(df)
weekend(df)
weekday(df)
return df.drop('datetime', axis=1) | Yes | 4 | 8 | Data_Transform | feature_engineering | 3,930,917 | 1 | A | 0 | 1 | 0 | 0 | 0 | 7 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}, {"detector": "general_ml", "framework": "Genera... | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker", "Missing function docstring"] | 6 | A |
4,016 | fig = plt.figure(figsize=(10, 4))
fig.add_subplot(1,2,1)
sns.countplot(x='year', hue='count_bin', data=train_set.loc[train_set['year']==1])
fig.add_subplot(1,2,2)
sns.countplot(x='year', hue='count_bin', data=train_set.loc[train_set['year']==2]) | No | 5 | 33 | Visualization | distribution | 3,930,917 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Th... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Dependent Threshold Checker"] | 6 | A |
4,018 | fig = plt.figure(figsize=(20, 6))
fig.add_subplot(1,2,1)
sns.countplot(x='weekday', hue='count_bin', data=train_set)
fig.add_subplot(1,2,2)
sns.countplot(x='time', hue='count_bin', data=train_set) | No | 5 | 75 | Visualization | time_series | 3,930,917 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker"] | 6 | A |
4,019 | sns.factorplot(x="weekday",y="count",data=train_set,kind='bar')
sns.factorplot(x="time",y="count",data=train_set,kind='bar')' | 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,021 | # fig = plt.figure(figsize=(10, 4))
# fig.add_subplot(1,2,1)
sns.factorplot(x="weekend",y="count",data=train_set,kind='bar')
# sns.countplot(x='weekend', hue='count_bin', data=train_set.loc[train_set['weekend']==1])
# fig.add_subplot(1,2,2)
sns.factorplot(x="workingday",y="count",data=train_set,kind='bar')
# sns.countp... | No | 5 | 33 | Visualization | distribution | null | 3 | C | 2 | 0 | 0 | 0 | 10 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,022 | sns.factorplot(x="rounded_temp",y="count",data=train_set,kind='bar')' | No | 5 | 33 | Visualization | distribution | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,023 | sns.factorplot(x="rounded_atemp",y="count",data=train_set,kind='bar')' | No | 5 | 33 | Visualization | distribution | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,024 | fig = plt.figure()
fig.add_subplot(2,2,1)
plt.hist(train_set['count'].loc[(train_set['count']<50) & (train_set['season']==1)])
fig.add_subplot(2,2,2)
plt.hist(train_set['count'].loc[(train_set['count']<50) & (train_set['season']==2)])
fig.add_subplot(2,2,3)
plt.hist(train_set['count'].loc[(train_set['count']<50) & (t... | No | 5 | 33 | Visualization | distribution | 3,930,917 | 1 | A | 0 | 0 | 0 | 0 | 0 | 9 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Th... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Dependent Threshold Checker"] | 6 | A |
4,025 | sns.factorplot(x="season",y="count",data=train_set,kind='bar')' | No | 5 | 33 | Visualization | distribution | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,026 | sns.factorplot(x="weather",y="count",data=train_set,kind='bar')' | No | 5 | 33 | Visualization | distribution | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,027 | sns.factorplot(x="temp_bin",y="count",data=train_set,kind='bar')' | No | 5 | 33 | Visualization | distribution | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,028 | from sklearn.metrics import mean_squared_log_error
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import KFold, cross_val_score, GridSearchCV
import lightgbm as lgb
from xgboost import XGBRegressor
from sklearn.metrics import accuracy_score, make_scorer | No | 5 | 22 | Environment | import_modules | 3,930,917 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker"] | 6 | A |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.