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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7,273 | # Final prediction of the baseline models, as I am not going to tweak them, I will move directly to the test data<br><br>test_dataset = pd.read_csv("../input/test.csv")<br>dates = test_dataset[\'datetime\']<br>test_dataset[\'datetime\'] = test_dataset[\'datetime\'].apply(lambda x: pd.to_datetime(x).timestamp()) | Yes | 4 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,274 | CV = 5 # Cross Validate with 5 different folds of 20% data ( 80-20 split with 5 folds )
#Create a data frame that will store the results for all 5 trials of the 3 different models
cv_df = pd.DataFrame(index=range(CV * len(models)))
entries = [] # Initially all entries are empty | No | 4 | 12 | Data_Transform | create_dataframe | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,275 | casual = casual_model.predict(test_data)
registered = registered_model.predict(test_data)
total = casual + registered | No | 5 | 48 | Model_Evaluation | predict_on_test | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,276 | #For each Algorithm
for model in models:
model_name = model.__class__.__name__
# create 5 models with different 20% test sets, and store their accuracies
accuracies = cross_val_score(model, features, labels, scoring='accuracy', cv=CV)
# Append all 5 accuracies into the entries list ( after all 3 models are run... | No | 5 | 3 | Hyperparam_Tuning | find_best_model_class | null | 1 | A | 0 | 2 | 3 | 0 | 0 | 5 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,277 | # Store the entries into the results dataframe and name its columns
cv_df = pd.DataFrame(entries, columns=['model_name', 'fold_idx', 'accuracy']) | No | 5 | 12 | Data_Transform | create_dataframe | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,278 | test_dataset['datetime'] = dates
test_dataset['count'] = pd.Series(total) | No | 5 | 8 | Data_Transform | feature_engineering | 1,814,363 | 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"] | 6 | A |
7,279 | import seaborn as sns<br><br>sns.boxplot(x=\'model_name\', y=\'accuracy\', data=cv_df)<br>sns.stripplot(x=\'model_name\', y=\'accuracy\', data=cv_df, <br> size=8, jitter=True, edgecolor="gray", linewidth=2) | 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 |
7,280 | test_dataset[test_dataset['count'] < 0] | No | 5 | 14 | Data_Transform | filter | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,281 | # Mean accuracy of each algorithm
cv_df.groupby('model_name').accuracy.mean() | No | 5 | 60 | Data_Transform | groupby | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,282 | test_dataset.loc[test_dataset['count'] < 0, 'count'] = 0 | No | 5 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,283 | test_dataset[test_dataset['count'] <= 0] | No | 5 | 14 | Data_Transform | filter | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,284 | cv_df | No | 5 | 41 | Debug | show_table | null | 1 | A | 0 | 0 | 0 | 1 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,285 | test_dataset[['datetime', 'count']].to_csv('result.csv', index = False) | No | 5 | 25 | Data_Export | save_to_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,286 | from sklearn.model_selection import train_test_split
model = LogisticRegression(random_state=0)
#Split Data
X_train, X_test, y_train, y_test, indices_train, indices_test = train_test_split(features, labels, df.index, test_size=0.33, random_state=0)
#Train Algorithm
model.fit(X_train, y_train)
# Make Predictions
y_... | Yes | 3 | 7 | Model_Train | train_model | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 10 | 8 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Scaler Missing Checker", "fix": "Apply scaling before scaling-sensitive operations.", "benefits": "Improves model performance and accuracy.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation... | C | Cross Validation Checker=low, Cross-validation not detected=low, Scaler Missing Checker=medium | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "Scaler Missing Checker", "severity": "medium"}] | ["Dependent Threshold Checker", "Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 0 | C |
7,287 | import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(color_codes=True)
import os
print(os.listdir("../input")) | No | 5 | 88 | Debug | list_files | 1,860,696 | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 14"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 7 | A |
7,288 | df = pd.read_csv("../input/train.tsv", sep="\\t")<br>df_test = pd.read_csv("../input/test.tsv", sep="\\t") | 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 |
7,289 | df.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 |
7,290 | from sklearn.metrics import confusion_matrix
import seaborn as sns
conf_mat = confusion_matrix(y_test, y_pred)
sns.heatmap(conf_mat, annot=True, fmt='d',
xticklabels=category_id_df.Category.values, yticklabels=category_id_df.Category.values)
plt.ylabel('Actual')
plt.xlabel('Predicted') | No | 5 | 80 | Visualization | heatmap | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 0 | A |
7,291 | model.fit(features, labels) | 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 |
7,292 | import os
print(os.listdir("../input/bbc-test")) | No | 5 | 88 | Debug | list_files | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,293 | TEST_PATH = os.path.join("../input/bbc-test", "BBC News Test.csv")
#Load the data using pandas : Create a DataFrame
test_df = pd.read_csv(TEST_PATH)
| 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 |
7,294 | from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.svm import LinearSVC
from sklearn.pipeline import Pipeline
from sklearn.model_selection import StratifiedKFold | No | 5 | 22 | Environment | import_modules | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 0 | A |
7,295 | test_features = tfidf.transform(test_df.Text.tolist())
Y_pred = model.predict(test_features)
Y_pred | Yes | 3 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 0 | 0 | 1 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,296 | import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import datetime
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import log_loss | No | 5 | 22 | Environment | import_modules | 1,872,293 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
7,297 | #Create Submission Dataframe
submission = pd.DataFrame({
"ArticleId": test_df["ArticleId"],
"Category": Y_pred_name
}) | No | 5 | 12 | Data_Transform | create_dataframe | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,298 | # Convert submission dataframe to csv
# you could use any filename. We choose submission here
submission.to_csv('submission.csv', index=False) | No | 5 | 25 | Data_Export | save_to_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,299 | # This Python 3 environment comes with many helpful analytics libraries installed<br># It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python<br># For example, here\'s several helpful packages to load in <br><br>import numpy as np # linear algebra<br>import pandas as pd # data processi... | No | 5 | 88 | Debug | list_files | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,300 | import pandas as pd
import numpy as np
import seaborn as sns
import missingno as msno
import gc | No | 5 | 22 | Environment | import_modules | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 0 | A |
7,301 | def PrepareFeatures(TestOrTrain):<br> source = f\'../input/{TestOrTrain}.json\'<br> data = pd.read_json(source)<br> # Some noise in price feature we saw in Part 1:<br> ulimit = np.percentile(data.price.values, 99)<br> data[\'price\'][data[\'price\']>ulimit] = ulimit<br> # Get Different features as in ... | 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 |
7,302 | data = PrepareFeatures(\'train\')<br>cat_features = [\'hasParking\', \'hasGym\', \'hasPool\', \'noFee\', \'hasElevator\',<br> \'hasGarden\', \'isFurnished\', \'reducedFee\', \'hasAC\', \'hasRoof\',<br> \'petFriendly\', \'shareable\', \'freeMonth\', \'utilIncluded\']<br>CreateCategFeat(data... | No | 5 | 21 | Data_Transform | prepare_x_and_y | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,303 | X_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.05)
clf = RandomForestClassifier(n_estimators=2000)
clf.fit(X_train, y_train)
y_val_pred = clf.predict_proba(X_val)
log_loss(y_val, y_val_pred) | Yes | 3 | 7 | Model_Train | train_model | 1,872,293 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 12 | 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, 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"}] | ["Dependent Threshold Checker", "Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 5 | B |
7,304 | test = PrepareFeatures('test')
CreateCategFeat(test, cat_features)
X = test[features]
y = clf.predict_proba(X) | Yes | 4 | 48 | Model_Evaluation | predict_on_test | 1,872,293 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | 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": "Dependent Th... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Dependent Threshold Checker", "Exception Handling Checker", "Unit Testing Checker"] | 5 | A |
7,305 | labels2idx = {label: i for i, label in enumerate(clf.classes_)}
sub = pd.DataFrame()
sub["listing_id"] = test["listing_id"]
for label in ["high", "medium", "low"]:
sub[label] = y[:, labels2idx[label]]
sub.to_csv("submission_rf.csv", index=False) | Yes | 4 | 25 | Data_Export | save_to_csv | 1,872,293 | 1 | A | 0 | 1 | 1 | 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"] | 5 | A |
7,306 | import math
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
| Yes | 4 | 22 | Environment | import_modules | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
7,307 | df = pd.read_csv('../input/training/training.csv')
df_test=pd.read_csv('../input/test/test.csv')
df.dropna(inplace=True)
df.shape | Yes | 3 | 45 | Data_Extraction | load_from_csv | 1,888,718 | 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."] | 1 | A |
7,308 | y = df.iloc[:, :-1].values
y.shape | Yes | 4 | 14 | Data_Transform | filter | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,309 | from sklearn.model_selection import train_test_split
x_train, x_val, y_train, y_val = train_test_split(x, y, test_size=0.2, random_state=42)
x_train.shape, x_val.shape | Yes | 4 | 13 | Data_Transform | split | null | 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"}] | [] | 0 | B |
7,311 | x_train.shape, x_val.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 |
7,312 | # Definir correctamente la red neuronal (5 pts)<br>from keras.models import Sequential <br>from keras.layers import GlobalAveragePooling2D, Dense, Flatten,BatchNormalization, Dropout, Conv2D, MaxPool2D<br>from keras.optimizers import Adam, SGD<br>from keras import regularizers<br><br>lr = 0.01<br>bs = 256<br>nb = math.... | Yes | 4 | 4 | Model_Train | choose_model_class | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,313 | log = final_model.fit(x_train, y_train, batch_size=100, epochs=100,validation_data=[x_val, y_val]) | No | 5 | 7 | Model_Train | train_model | 1,888,718 | 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": "ScikitLear... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 1 | B |
7,314 | # Resultado del entrenamiento
# - mae entre 10 y 15 (3 pts)
# - mae entre 8 y 11 (5 pts)
# - mae entre 5 y 8 (7 pts)
# - mae menor o igual a 4.0 (9 pts)
print(f'MAE final: {final_model.evaluate(x_val, y_val)[1]}') | 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 |
7,315 | x_val[0,None].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 |
7,320 | results=final_model.predict(test)
results.shape | Yes | 4 | 48 | Model_Evaluation | predict_on_test | 1,888,718 | 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"] | 1 | A |
7,323 | lookup = pd.read_csv('../input/IdLookupTable.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 |
7,325 | submission = pd.concat([rowid,loc],axis = 1) | 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 |
7,326 | submission.to_csv('submission2.csv', index=False) | No | 5 | 25 | Data_Export | save_to_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,327 | # This Python 3 environment comes with many helpful analytics libraries installed<br># It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python<br># For example, here\'s several helpful packages to load in <br><br>import numpy as np # linear algebra<br>import pandas as pd # data processi... | No | 5 | 88 | Debug | list_files | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,328 | train_data = pd.read_csv("../input/atividade-3-pmr3508/train.csv")<br>test_data = pd.read_csv("../input/atividade-3-pmr3508/test.csv")<br>#Saving the id\'s, just in case they are needed in the submission<br>train_Id = train_data.loc[:,\'Id\']<br>test_Id = test_data.loc[:,\'Id\']<br>test_data = test_data.drop(\'Id\',axi... | Yes | 3 | 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 |
7,329 | def adding_new_features(df):
df.loc[:,'mean_rooms'] = df.loc[:,'total_rooms']/df.loc[:,'households']
df.loc[:,'rooms_per_person'] = df.loc[:,'total_rooms']/df.loc[:,'population']
df.loc[:,'mean_bedrooms'] = df.loc[:,'total_bedrooms']/df.loc[:,'households']
df.loc[:,'bedrooms_per_person'] = df.loc[:,'tot... | No | 5 | 8 | Data_Transform | feature_engineering | 1,903,921 | 1 | A | 0 | 1 | 0 | 1 | 0 | 10 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Missing docstring for function: adding_new_features. Consider adding documentation for parameters and return values.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 11"}] | A | no applicable ML-specific findings | [] | ["Missing function docstring"] | 10 | A |
7,330 | train_data['longitude'].plot(kind='hist')
test_data['longitude'].plot(kind='hist')
| No | 5 | 33 | Visualization | distribution | 1,903,921 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Column Selection Checker"] | 10 | B |
7,331 | train_data['latitude'].plot(kind='hist')
test_data['latitude'].plot(kind='hist') | No | 5 | 33 | Visualization | distribution | 1,903,921 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Column Selection Checker"] | 10 | B |
7,332 | dist2coast = pd.read_csv("../input/distance-to-coast/dist2coast.txt",delim_whitespace = True)
| No | 5 | 45 | Data_Extraction | load_from_csv | 1,903,921 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/distance-to-coast/dist2coast.txt. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 11"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 10 | A |
7,333 | def saving(name,y_predict): # "saving" some time with a compressed writing code<br> df = pd.DataFrame()<br> df[\'Id\'] = test_Id<br> df.set_index(\'Id\', inplace=True)<br> df[\'median_house_value\'] =y_predict<br> print(df)<br> return df.to_csv(name) | 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 |
7,334 | from sklearn import tree<br>x_train_data = train_data.drop(\'median_house_value\', axis = \'columns\')<br>y_train_data = train_data.loc[:,\'median_house_value\']<br>reg1 = tree.DecisionTreeRegressor(max_depth = 1)<br>reg1 = reg1.fit(x_train_data, y_train_data)<br>DTR_y = reg1.predict(test_data)<br>saving("DecisionTreeR... | 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 |
7,335 | from sklearn.neighbors import KNeighborsRegressor
reg2 = KNeighborsRegressor(n_neighbors=50) #50nn = 0.37494 at 70% of the test database, 1000nn = 0.38598
reg2 = reg2.fit(x_train_data, y_train_data)
knnR_y = reg2.predict(test_data)
saving("50nn Regressor.csv", knnR_y) | Yes | 3 | 7 | Model_Train | train_model | 1,903,921 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | 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"] | 10 | B |
7,336 | from sklearn import linear_model
reg3 = linear_model.LassoLars(alpha=.1, positive = True)
reg3.fit(x_train_data, y_train_data)
print (reg3.coef_)
LASSO_y = reg3.predict(test_data)
saving("LASSO LARS.csv", LASSO_y) # score = 0.38951
| Yes | 3 | 7 | Model_Train | train_model | 1,903,921 | 1 | A | 1 | 0 | 0 | 0 | 5 | 6 | ok | 8 | 7 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 10 | B |
7,337 | from sklearn.neural_network import MLPRegressor
reg4 = MLPRegressor()
reg4.fit(x_train_data, y_train_data)
MLP_y = reg4.predict(test_data)
saving("MultiLayerPerceptrons Regressor.csv", MLP_y) #0.373 | Yes | 3 | 7 | Model_Train | train_model | 1,903,921 | 2 | B | 2 | 0 | 0 | 0 | 10 | 5 | 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"] | 10 | B |
7,338 | reg5 = linear_model.BayesianRidge()
reg5.fit(x_train_data, y_train_data)
BRR_y = reg5.predict(test_data)
scores5 = cross_val_score(reg5, x_train_data, y_train_data, cv = 10)
saving("Bayesian Ridge Regressor.csv", BRR_y) | Yes | 3 | 7 | Model_Train | train_model | 1,903,921 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 7 | 5 | [{"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 12"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": ... | B | No random seed setting detected=low | [{"type": "No random seed setting detected", "severity": "low"}] | ["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 10 | B |
7,339 | reg7 = ExtraTreesRegressor()
reg7.fit(x_train_data, y_train_data)
ET_y = reg7.predict(test_data)
saving("ExtraTreesRegressor.csv", ET_y) # scores = 0.24383
| Yes | 3 | 7 | Model_Train | train_model | 1,903,921 | 1 | A | 1 | 0 | 0 | 0 | 5 | 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"] | 10 | B |
7,340 | from sklearn.ensemble import AdaBoostRegressor
reg8 = AdaBoostRegressor(base_estimator = RandomForestRegressor(max_depth=20), n_estimators=50)
reg8.fit(x_train_data, y_train_data)
ADA_y = reg8.predict(test_data)
saving("ADA Boost Regression.csv",ADA_y) # 0.22756 | Yes | 3 | 7 | Model_Train | train_model | 1,903,921 | 2 | B | 2 | 0 | 0 | 0 | 10 | 5 | ok | 10 | 8 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low, Randomness Control Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Randomness Control Checker", "severity": "low"}] | ["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 10 | B |
7,341 | reg_F = AdaBoostRegressor(base_estimator = RandomForestRegressor(max_depth=20), n_estimators=50)
reg_F.fit(x_train_data, y_train_data)
final = reg_F.predict(test_data)
saving("Final ADA Boost Regression.csv",final) # 0.22756 | Yes | 3 | 7 | Model_Train | train_model | 1,903,921 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 10 | 8 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low, Randomness Control Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Randomness Control Checker", "severity": "low"}] | ["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 10 | B |
7,342 | train = pd.read_csv('../input/train.csv')
test = pd.read_csv('../input/test.csv')
sample = pd.read_csv('../input/test.csv') | No | 5 | 45 | Data_Extraction | load_from_csv | 1,908,657 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 4 | 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."] | 4 | A |
7,343 | x_train = train[['LotArea','LotFrontage']].copy()
y_train = train['SalePrice'].copy() | No | 5 | 21 | Data_Transform | prepare_x_and_y | 1,908,657 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | 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"}] | [] | 4 | B |
7,344 | x_test = test[['LotArea','LotFrontage']].copy() | No | 5 | 21 | Data_Transform | prepare_x_and_y | 1,908,657 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 4 | A |
7,345 | y_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 |
7,346 | x_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 |
7,347 | x_train.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 |
7,348 | x_train.isnull().sum() | 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 |
7,349 | x_train.fillna(0,inplace=True)
x_test.fillna(0,inplace=True) | No | 5 | 17 | Data_Transform | correct_missing_values | 1,908,657 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 3 | 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 5"}, {"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["InPlace Checker"] | 4 | B |
7,350 | from sklearn.linear_model import LinearRegression
from sklearn.preprocessing import StandardScaler | No | 5 | 22 | Environment | import_modules | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 0 | A |
7,351 | x_train_scaler = x_scaler.fit_transform(x_train)
x_test_scaler = x_scaler.transform(x_test) | No | 5 | 18 | Data_Transform | normalization | 1,908,657 | 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... | D | Cross Validation Checker=low, Data Leakage Checker=high, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "No random seed setting detected", "severity": "low"}] | ["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"] | 4 | D |
7,352 | lr = LinearRegression() | 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 |
7,353 | lr.fit(x_train_scaler,y_train) | No | 5 | 7 | Model_Train | train_model | 1,908,657 | 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": "ScikitLear... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 4 | B |
7,354 | pred = lr.predict(x_test_scaler) | No | 5 | 48 | Model_Evaluation | predict_on_test | 1,908,657 | 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"] | 4 | A |
7,355 | pd.read_csv('../input/sample_sumbission.csv').head() | No | 5 | 45 | Data_Extraction | load_from_csv | 1,908,657 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 2 | 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."] | 4 | A |
7,356 | sub = pd.DataFrame(data = {'Id' : test.Id, 'SalePrice' :pred}) | No | 5 | 12 | Data_Transform | create_dataframe | 1,908,657 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 4 | A |
7,357 | sub.to_csv('submission.csv', index=False) | No | 5 | 25 | Data_Export | save_to_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,358 | import cv2 # working with, mainly resizing, images
import numpy as np # dealing with arrays
import os # dealing with directories
from random import shuffle # mixing up or currently ordered data that might lead our network astray in training.
train_dir = '../input/train'
test_di... | No | 5 | 77 | Other | define_variables | 1,915,708 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 2 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/train. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 8"}, {"detector": "general_ml", "framework": "General ML", "name": "Hardcode... | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 2 | A |
7,359 | X = np.array([i[0] for i in train]).reshape(-1,1,50,50)
Y = [i[1] for i in train]
test_x = np.array([i[0] for i in test]).reshape(-1,1,50,50)
test_y = [i[1] for i in test] | No | 5 | 21 | Data_Transform | prepare_x_and_y | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,360 | from keras.models import Sequential
from keras.layers import Dense , Activation
from keras.layers import Dropout
from keras.layers import Flatten
from keras.constraints import maxnorm
from keras.optimizers import SGD
from keras.layers import Convolution2D
from keras.layers import Conv2D , BatchNormalization
from keras.... | No | 5 | 23 | Environment | set_options | 1,915,708 | 1 | A | 0 | 0 | 0 | 0 | 0 | 12 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
7,361 | # Initialising the CNN
classifier = Sequential()
# Step 1 - Convolution
classifier.add(Convolution2D(32, 3, 3, input_shape = (1,50,50), activation = 'relu'))
# Step 2 - Pooling
classifier.add(MaxPooling2D(pool_size = (2, 2)))
# Adding a second convolutional layer
classifier.add(Convolution2D(32, 3, 3, activation = '... | No | 5 | 4 | Model_Train | choose_model_class | 1,915,708 | 1 | A | 0 | 0 | 0 | 0 | 0 | 11 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
7,362 | import matplotlib.pyplot as plt<br>%matplotlib inline<br><br>from IPython.display import set_matplotlib_formats<br>set_matplotlib_formats('pdf', 'png')<br>pd.options.display.float_format = '{:.2f}'.format<br>rc={'savefig.dpi': 75, 'figure.autolayout': False, 'figure.figsize': [12, 8], 'axes.labelsize': 18,\\<br> 'axe... | Yes | 4 | 23 | Environment | set_options | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,363 | # Setting working directory
path = '../input/'
path_result = '../output/' | No | 5 | 77 | Other | define_variables | 1,881,540 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 3 | 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"] | 9 | A |
7,364 | train = pd.read_csv(path + \'train_data.csv\')<br>test = pd.read_csv(path + \'teste_data.csv\')<br>train = train.rename(columns={"default": "target", "ids":"id"})<br>test = test.rename(columns={"ids":"id"}) | 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 |
7,365 | test_id = test.id | No | 5 | 77 | Other | define_variables | 1,881,540 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker"] | 9 | A |
7,366 | def missing_values_table(df):<br> mis_val = df.isnull().sum()<br> mis_val_percent = 100 * df.isnull().sum() / len(df)<br> mis_val_table = pd.concat([mis_val, mis_val_percent], axis=1)<br> mis_val_table_ren_columns = mis_val_table.rename(<br> columns = {0 : \'Missing Values\', 1 : \'% ... | No | 5 | 53 | Other | something_strange | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,367 | missing_values_table(train) | 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 |
7,368 | missingValueColumns = train.columns[train.isnull().any()].tolist()
df_null = train[missingValueColumns] | No | 5 | 10 | Data_Transform | drop_column | 1,881,540 | 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, 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", "Dependent Threshold Checker"] | 9 | B |
7,369 | msno.bar(df_null,figsize=(20,8),color=default_color,fontsize=18,labels=True) | No | 5 | 34 | Visualization | missing_values | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,370 | msno.heatmap(df_null,figsize=(20,8),cmap=colormap) | No | 5 | 80 | Visualization | heatmap | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,371 | msno.dendrogram(df_null,figsize=(20,8)) | No | 5 | 34 | Visualization | missing_values | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,372 | train = train.dropna(subset=['target']) | No | 5 | 17 | Data_Transform | correct_missing_values | 1,881,540 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Dependent Threshold Checker"] | 9 | B |
7,373 | plt.figure(figsize=(15,5))
ax = sns.countplot('target',data=train,color=default_color)
for p in ax.patches:
ax.annotate('{:.2f}%'.format(100*p.get_height()/len(train['target'])), (p.get_x()+ 0.3, p.get_height()+0.2)) | No | 5 | 33 | Visualization | distribution | 1,881,540 | 1 | A | 0 | 1 | 1 | 0 | 0 | 4 | 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"] | 9 | A |
7,374 | meta_data = get_meta(train)
meta_data | No | 5 | 77 | Other | define_variables | null | 1 | A | 0 | 0 | 0 | 1 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,375 | meta_counts = meta_data.groupby(['role', 'level']).agg({'dtype': lambda x: x.count()}).reset_index()
meta_counts | No | 5 | 60 | Data_Transform | groupby | null | 1 | A | 0 | 0 | 0 | 1 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,376 | fig,ax = plt.subplots()<br>fig.set_size_inches(20,5)<br>sns.barplot(data=meta_counts[(meta_counts.role != \'target\') & (meta_counts.role != \'id\') ],x="level",y="dtype",ax=ax,color=default_color)<br>ax.set(xlabel=\'Variable Type\', ylabel=\'Count\',title="Variables Count Across Datatype") | 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 |
7,377 | col_ordinal = meta_data[(meta_data.level == 'ordinal') & (meta_data.keep)].index
col_nominal = meta_data[(meta_data.level == 'nominal') & (meta_data.keep)& (meta_data.role != 'target')& (meta_data.role != 'id')].index
col_interval = meta_data[(meta_data.level == 'interval') & (meta_data.keep)].index
col_binary =... | No | 5 | 14 | Data_Transform | filter | 1,881,540 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | 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"] | 9 | A |
7,378 | def count_label_encoding(train, test,col):
for i in col:
df1 = train[i].value_counts().reset_index(name='freq_'+ i).rename(columns={'index': 'lc_'+ i})
train = pd.merge(train,df1,left_on=i, right_on='lc_'+ i, how='left')
test = pd.merge(test,df1,left_on=i, right_on='lc_'+ i, how='left')
... | No | 4 | 10 | Data_Transform | drop_column | 1,881,540 | 1 | A | 1 | 4 | 4 | 0 | 5 | 10 | ok | 6 | 6 | [{"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", "Dependent Threshold Checker", "Missing function docstring"] | 9 | B |
7,379 | train, test = count_label_encoding(train, test,col_nominal)
train, test = count_label_encoding(train, test,col_binary) | No | 5 | 53 | Other | something_strange | 1,881,540 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker"] | 9 | A |
7,380 | plt.figure(figsize=(18,16))
plt.title('Pearson correlation of continuous features', y=1.05, size=15)
sns.heatmap(train[col_interval].corr(),linewidths=0.1,vmax=1.0, square=True, cmap=colormap, linecolor='white', annot=True, fmt = '.2f') | No | 5 | 80 | Visualization | heatmap | 1,881,540 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Column Selection Checker", "Dependent Threshold Checker"] | 9 | B |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.