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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6,603 | print("train_x shape",train_x.shape)
print("test_x shape", test_x.shape)
# convert train_y to np. array
train_y = np.array(train_y)
print("train_y.shape", train_y.shape) | No | 5 | 58 | Debug | show_shape | 1,002,729 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 1 | 1 | [{"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 7"}] | A | no applicable ML-specific findings | [] | ["Array Creation Efficiency"] | 3 | A |
6,604 | # mean normalize train and test images
train_x = train_x/255
test_x = test_x/255 | No | 5 | 8 | Data_Transform | feature_engineering | 1,002,729 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
6,605 | # import required packages
from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation, Flatten, BatchNormalization
from keras.layers import Conv2D, MaxPooling2D
from keras.utils import np_utils, to_categorical
from sklearn.model_selection import train_test_split | No | 5 | 22 | Environment | import_modules | 1,002,729 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
6,606 | from scipy import sparse <br>from sklearn.feature_extraction.text import CountVectorizer<br>tfidf = CountVectorizer(stop_words=\'english\', max_features=200)<br>tfidf.fit(list(train_df[\'features\']) + list(test_df[\'features\']))<br>tr_sparse = tfidf.transform(train_df["features"])<br>te_sparse = tfidf.transform(test_... | No | 4 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
6,607 | print(train_df[features_to_use].head())
| No | 5 | 41 | Debug | show_table | 242,755 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | 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"] | 7 | B |
6,608 | train_X = sparse.hstack([train_df[features_to_use], tr_sparse]).tocsr()
| No | 4 | 32 | Data_Transform | merge | 242,755 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | 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"] | 7 | B |
6,609 | test_X = sparse.hstack([test_df[features_to_use], te_sparse]).tocsr()
| No | 4 | 32 | Data_Transform | merge | 242,755 | 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 |
6,610 | target_num_map = {'high':0, 'medium':1, 'low':2}
train_y = np.array(train_df['interest_level'].apply(lambda x: target_num_map[x]))
print(train_X.shape, test_X.shape)
| No | 4 | 20 | Data_Transform | categorify | 242,755 | 1 | A | 0 | 0 | 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 9"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Sele... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Array Creation Efficiency", "Column Selection Checker"] | 7 | B |
6,611 | preds, model = runXGB(train_X, train_y, test_X, num_rounds=818)
out_df = pd.DataFrame(preds)
out_df.columns = ["high", "medium", "low"]
out_df["listing_id"] = test_df.listing_id.values
out_df.to_csv("xgb_starter2.csv", index=False)
| No | 4 | 55 | Data_Export | prepare_output | 242,755 | 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"] | 7 | A |
6,612 | %matplotlib inline
import matplotlib.pyplot as plt
from tqdm import tqdm_notebook
import numpy as np
import pandas as pd
import torch
import torchvision
import torchvision.transforms as transforms
import torch.nn as nn
import torch.nn.functional as F | No | 5 | 23 | Environment | set_options | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
6,613 | torch.__version__ | No | 4 | 23 | Environment | set_options | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,614 | from torch.autograd import Variable | 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 |
6,615 | use_gpu = torch.cuda.is_available()
use_gpu | No | 4 | 77 | Other | define_variables | null | 1 | A | 0 | 0 | 0 | 1 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,616 | !ls ../input/cifar10-python/ | No | 5 | 88 | Debug | list_files | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,617 | !tar -zxvf ../input/cifar10-python/cifar-10-python.tar.gz | No | 5 | 73 | Data_Extraction | load_from_zip | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,618 | model.fit(X_train, y_train, batch_size=128, epochs=240, verbose=1,validation_split=0.2) | No | 5 | 7 | Model_Train | train_model | 736,747 | 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": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Exception Handling Checker", "Unit Testing Checker"] | 3 | B |
6,619 | from xgboost import XGBRegressor
model_XGB = XGBRegressor()
model_XGB.fit(X_train,y_train) | Yes | 4 | 4 | Model_Train | choose_model_class | 736,747 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | 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"] | 3 | B |
6,620 | predict = model.predict(X_test) | 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 |
6,621 | X_test['demand'] = X_test['pred'].apply(make_positive) | No | 5 | 8 | Data_Transform | feature_engineering | 736,747 | 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"] | 3 | A |
6,622 | X_test[['id','demand']].to_csv('result.csv',index=False) | No | 5 | 25 | Data_Export | save_to_csv | 736,747 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
6,623 | import numpy as np
import pandas as pd
import random
import matplotlib.pyplot as plt
from sklearn.ensemble import RandomForestClassifier
from sklearn.ensemble import GradientBoostingClassifier
from sklearn.ensemble import BaggingClassifier
from sklearn.naive_bayes import GaussianNB, MultinomialNB, BernoulliNB
from skl... | No | 5 | 88 | Debug | list_files | 1,036,151 | 1 | A | 0 | 0 | 0 | 0 | 0 | 21 | ok | 2 | 2 | [{"detector": "general_ml", "framework": "General ML", "name": "Magic number detected: 5", "fix": "Not specified", "benefits": "Not specified", "location": "Line 43"}, {"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input. Consider using configuration files or environment... | A | no applicable ML-specific findings | [] | ["Hardcoded file path", "Magic number"] | 15 | A |
6,624 |
# show data on 2d plots
positives = train_data_pca[train_labels[:]==1]
negatives = train_data_pca[train_labels[:]==0]
positivest = test_data_pca[test_predicted[:]==1]
negativest = test_data_pca[test_predicted[:]==0]
for j in range(decompose_to):
plt.figure(figsize=(20,15))
for i in range(decompose_to):
... | No | 5 | 33 | Visualization | distribution | 1,036,151 | 1 | A | 0 | 3 | 5 | 0 | 0 | 25 | 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"] | 15 | A |
6,625 | # PREDICTING THE EFFECTS OF GENETIC VARIATIONS USING LGBM
# BY - OMKAR SABNIS - 29-05-2018
#Importing library
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import re
import nltk
from nltk.corpus import stopwords
from nltk.stem.porter import PorterStemmer
from sklearn.fea... | No | 5 | 22 | Environment | import_modules | 1,042,691 | 1 | A | 0 | 0 | 0 | 0 | 0 | 16 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
6,626 | # READING THE DATASETS<br>train = pd.read_csv("../input/training_variants")<br>trainx = pd.read_csv(\'../input/training_text\',sep = \'\\|\\|\', engine= \'python\', header=None, <br> skiprows=1, names=["ID","Text"])<br>train = pd.merge(train, trainx, how = \'left\', on = \'ID\').fillna(\'\')<br>trai... | Yes | 3 | 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 |
6,627 | test = pd.read_csv("../input/stage2_test_variants.csv")<br>testx = pd.read_csv(\'../input/stage2_test_text.csv\',sep = \'\\|\\|\', engine= \'python\', header=None, <br> skiprows=1, names=["ID","Text"])<br>test = pd.merge(test, testx, how = \'left\', on = \'ID\').fillna(\'\')<br>test.head() | 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 |
6,628 | def textlen(train):
k = train['Text'].apply(lambda x: len(str(x).split()))
l = train['Text'].apply(lambda x: len(str(x)))
return k, l
train['Text_no_word'], train['Text_no_char'] = textlen(train)
test['Text_no_word'], test['Text_no_char'] = textlen(test) | No | 5 | 8 | Data_Transform | feature_engineering | 1,042,691 | 1 | A | 0 | 1 | 0 | 0 | 0 | 6 | 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", "Missing function docstring"] | 9 | B |
6,629 | tfidf = TfidfVectorizer(<br>\tmin_df=1, max_features=1600, strip_accents='unicode',lowercase =True,<br>\tanalyzer='word', token_pattern=r'\\w+', ngram_range=(1, 3), use_idf=True, <br>\tsmooth_idf=True, sublinear_tf=True, stop_words = 'english')<br>X_train = tfidf.fit_transform(train['Text']).toarray()<br>print(X_train)... | 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 |
6,630 | # FEATURE SCALING
sc = StandardScaler()
X_train = sc.fit_transform(X_train)
X_test = sc.transform(X_test)
y_train = train['Class'] | No | 5 | 21 | Data_Transform | prepare_x_and_y | 1,042,691 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 10 | 9 | [{"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... | D | Cross Validation Checker=low, Data Leakage Checker=high, No random seed setting detected=low, Pipeline Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "No random seed setting detected", "severity": "low"}, {"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"] | 9 | D |
6,631 | xtr,xvl,ytr,yvl = train_test_split(X_train,y_train,test_size=0.3,random_state=10) | No | 5 | 13 | Data_Transform | split | 1,042,691 | 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"}] | [] | 9 | B |
6,632 | predictions = [0 if i < 0 else i for i in predictions] | No | 1 | 53 | Other | something_strange | 4,702,749 | 1 | A | 0 | 1 | 1 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
6,633 | output = pd.DataFrame({'datetime': test_data.index,
'count': predictions})
output.to_csv('submission.csv', index=False) | Yes | 3 | 55 | Data_Export | prepare_output | 4,702,749 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
6,634 | # SUBMISSION OF FILE IN CSV FORMAT:
submit = pd.DataFrame(test.ID)
submit = submit.join(pd.DataFrame(pred_test))
submit.columns = ['ID', 'class1','class2','class3','class4','class5','class6','class7','class8','class9']
submit.to_csv('submission.csv', index=False) | Yes | 3 | 25 | Data_Export | save_to_csv | 1,042,691 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
6,635 | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from scipy import stats
from sklearn.feature_extraction.text import CountVectorizer,TfidfVectorizer
from scipy.sparse import hstack
from sklearn.model_selection import train_test_split
import time
import lightgbm as lgb
import ... | No | 5 | 23 | Environment | set_options | 1,092,994 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
6,636 | train = pd.read_json('../input/train.json')
test = pd.read_json('../input/test.json') | No | 5 | 44 | Data_Extraction | load_from_disk | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,637 | merge.loc[merge['bathrooms'] > 7 , 'bathrooms'] = 7
merge['rooms'] = merge['bathrooms'] + merge['bedrooms']
merge['rooms_diff'] = merge['bathrooms'] - merge['bedrooms']
merge['half_bathrooms'] = ((merge['rooms'] - np.floor(merge['rooms'])) > 0).astype(int)
features_to_use = np.concatenate([features_to_use, ['bathrooms'... | No | 4 | 8 | Data_Transform | feature_engineering | 1,092,994 | 1 | A | 0 | 0 | 0 | 1 | 0 | 7 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,638 | merge.loc[merge[\'latitude\'] < 1, \'latitude\'] = merge[\'latitude\'].mode()[0]<br>merge.loc[merge[\'longitude\']>-1, \'longitude\'] = merge[\'longitude\'].mode()[0]<br>scaler = sklearn.preprocessing.MinMaxScaler(feature_range=(0,1))<br><br>merge[\'latitude\'] = scaler.fit_transform(np.array(merge[\'latitude\']).resha... | Yes | 2 | 18 | Data_Transform | normalization | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
6,639 | merge[\'num_description_len\'] = merge[\'description\'].str.len()<br>merge[\'num_description_words\'] = merge[\'description\'].apply(lambda x:len(x.split(\' \')))<br>merge[\'price_per_bedrooms\'] = merge[\'price\']/merge[\'bedrooms\']<br>merge[\'price_per_bathrooms\'] = merge[\'price\']/merge[\'bathrooms\']<br>merge[\'... | Yes | 4 | 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 |
6,640 | interest_level_dict = {'low' : 0, 'medium' : 1, 'high' : 2 }
merge['interest'] = merge['interest_level'].map(interest_level_dict) | No | 5 | 20 | Data_Transform | categorify | 1,092,994 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,641 | created_time = pd.to_datetime(merge['created'],format='%Y-%m-%d %H:%M:%S')
merge['month'] = created_time.dt.month
merge['day'] = created_time.dt.day
merge['hour'] = created_time.dt.hour
merge['weekday'] = created_time.dt.weekday
merge['week'] = created_time.dt.week
merge['quarter'] = created_time.dt.quarter
merge['week... | Yes | 4 | 8 | Data_Transform | feature_engineering | 1,092,994 | 1 | A | 0 | 0 | 0 | 1 | 0 | 13 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,642 | display_address_min_df = 10
street_address_min_df = 10
features_min_df = 10
description_max_features = 20 | No | 5 | 77 | Other | define_variables | 1,092,994 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,643 | cv = CountVectorizer(min_df=display_address_min_df)
X_display_address = cv.fit_transform(merge['display_address'])
cv = CountVectorizer(min_df=street_address_min_df)
X_street_address = cv.fit_transform(merge['street_address'])
merge['features_'] = merge['features'].apply(lambda x:' '.join(['_'.join(k.split(' ')) fo... | Yes | 4 | 8 | Data_Transform | feature_engineering | 1,092,994 | 1 | A | 0 | 0 | 0 | 0 | 0 | 12 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,644 | ohe = sklearn.preprocessing.OneHotEncoder()
X_encode = ohe.fit_transform(merge[features_to_encode]) | No | 5 | 20 | Data_Transform | categorify | 1,092,994 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,645 | def union_features(features_to_use, X_encode, X_vectorized, target, nrow_train):
X_origin = merge[features_to_use]
X_origin.fillna(0 ,inplace=True)
X = hstack((X_origin, X_encode, X_vectorized)).tocsr()
y = merge[target]
X_train_all = X[:nrow_train]
X_test = X[nrow_train:]
y_train_all = y[:... | Yes | 4 | 21 | Data_Transform | prepare_x_and_y | 1,092,994 | 1 | A | 6 | 1 | 0 | 0 | 15 | 11 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,646 | merge.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 |
6,647 | Y_pred = model.predict(xgb.DMatrix(X_test))
ids = np.array(test['listing_id']) | No | 5 | 48 | Model_Evaluation | predict_on_test | 1,092,994 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,648 | preds = pd.DataFrame({"listing_id": ids, "high":Y_pred[:, 0],<br> "medium":Y_pred[:, 1], "low":Y_pred[:, 2]})<br>preds.to_csv(\'my_submission.csv\' ,index=False) | 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 |
6,649 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import itertools
import graphviz
from sklearn.preprocessing import Imputer
from sklearn.model_selection import train_test_split, cross_val_score, KFold
from sklearn.metrics import confusion_matrix
from sklearn import tree
from... | Yes | 3 | 22 | Environment | import_modules | 1,175,067 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
6,650 | predict = pd.DataFrame(index=output['datetime'])
predict['count'] = output['count'].values
predict.head()
plot_timeseries_train_and_predict(train_data, predict, 2011, 2) | No | 2 | 41 | Debug | show_table | 4,702,749 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 8 | 7 | [{"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", "Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker"] | 6 | B |
6,651 | fig = plt.figure(figsize=(16,9))
plt.plot(train_data.index, train_data['count'], 'b', label = 'train')
plt.plot(output['datetime'],output['count'], 'r', label = 'test')
plt.title('Train and Test')
plt.legend()
plt.grid() | No | 5 | 75 | Visualization | time_series | 4,702,749 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 6 | A |
6,652 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import itertools
import graphviz
from sklearn.preprocessing import Imputer
from sklearn import preprocessing #hy
from sklearn.preprocessing import StandardScaler #hy
from sklearn.model_selection import train_test_split, cross... | Yes | 4 | 22 | Environment | import_modules | 1,201,516 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
6,653 | def plot_decision_tree(a,b):<br> """<br> http://scikit-learn.org/stable/modules/tree.html<br> """<br> dot_data = tree.export_graphviz(a, out_file=None, feature_names=b,class_names=[\'Healthy\',\'Diabetes\'],filled=False, rounded=True,special_characters=False) <br> graph = graphviz.Source(dot_data) <br>... | Yes | 1 | 80 | Visualization | heatmap | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,654 | dataset = read_csv('../input/train.csv')
dataset=dataset[['Id','Pregnancies','Glucose','BloodPressure','SkinThickness','Insulin','BMI','DiabetesPedigreeFunction','Age','Outcome']]
dataset.head(10) | Yes | 2 | 41 | Debug | show_table | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,655 | dataset2 = dataset.iloc[:, :-1]<br>print("# of Rows, # of Columns: ",dataset2.shape)<br>print("\<br>Column Name # of Null Values\<br>")<br>print((dataset2[:] == 0).sum()) | No | 4 | 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 |
6,656 | trainingData = read_csv(\'../input/train.csv\') <br>trainingData=trainingData[[\'Id\',\'Pregnancies\',\'Glucose\',\'BloodPressure\',\'SkinThickness\',\'Insulin\',\'BMI\',\'DiabetesPedigreeFunction\',\'Age\',\'Outcome\']]<br>testingData = read_csv(\'../input/test.csv\')<br>testingData=testingData[[\'Id\',\'Pregnancies\'... | Yes | 1 | 12 | Data_Transform | create_dataframe | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,657 | g = sns.heatmap(trainingFeatures.corr(),cmap="Blues",annot=False) | 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 |
6,658 | #trainingFeatures2 = trainingFeatures.drop(['Pregnancies','BloodPressure','DiabetesPedigreeFunction', 'Age','SkinThickness','Insulin','Id'], axis=1)
trainingFeatures2 = trainingFeatures.drop(['Id'], axis=1) | No | 5 | 10 | Data_Transform | drop_column | 1,201,516 | 3 | C | 1 | 0 | 0 | 0 | 5 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,659 | g = sns.heatmap(trainingFeatures2.corr(),cmap="Blues",annot=False)
print(trainingFeatures2.corr()) | Yes | 3 | 80 | Visualization | heatmap | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,660 | <br>#model = DecisionTreeClassifier(max_depth=8,min_samples_leaf=2)<br>#0.70-no norm . 0.76--w/ normalization<br>"""<br>model = LogisticRegression(penalty=\'l2\', dual=False, tol=0.0001, <br> C=1.0, fit_intercept=True, intercept_scaling=1, <br> class_weight=None, rand... | Yes | 1 | 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 |
6,661 | kfold = KFold(n_splits=10, random_state=10)<br>results = cross_val_score(model, trainingFeatures2, trainingLabels, cv=kfold)<br>#print("DecisionTreeClassifier:\<br>\<br>Cross_Val_Score: %.2f%% (%.2f%%)" % (results.mean()*100, results.std()*100))<br>print("Logistic Regression Classifier:\<br>\<br>Cross_Val_Score: %.2f%%... | Yes | 2 | 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 |
6,662 | test = testingData
test = pd.DataFrame(test)
test.columns=['Id','Pregnancies','Glucose','BloodPressure','SkinThickness','Insulin','BMI','DiabetesPedigreeFunction','Age']
#test2 = test.drop(['Id','Pregnancies','BloodPressure','DiabetesPedigreeFunction', 'Age','SkinThickness','Insulin'], axis=1)
test2 = test.drop(['Id' ]... | Yes | 1 | 12 | Data_Transform | create_dataframe | 1,201,516 | 2 | B | 3 | 0 | 0 | 0 | 15 | 9 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,663 | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import GridSearchCV
from sklearn.ensemble import GradientBoostingClassifier
from sklearn.ensemble import AdaBoostClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.neural_network import MLPClassi... | Yes | 3 | 22 | Environment | import_modules | 1,202,208 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
6,664 | X = train.drop(['Outcome'], axis = 1)
y = train.Outcome | Yes | 3 | 10 | Data_Transform | drop_column | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,665 | # parameters = {'criterion': ('gini', 'entropy'), 'n_estimators': [10, 50, 100, 105, 150]}
# gb = MLPClassifier(solver='lbfgs', alpha=1e-5, hidden_layer_sizes=(5, 2), random_state=1)
clf = MLPClassifier(solver='lbfgs', alpha=1e-5, hidden_layer_sizes=(5, 2), random_state=1)
# clf = GridSearchCV(gb, parameters)
clf.fit(X... | Yes | 2 | 4 | Model_Train | choose_model_class | 1,202,208 | 3 | C | 2 | 0 | 0 | 0 | 10 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,666 | predicted = clf.predict(test) | 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 |
6,667 | print(predicted) | No | 1 | 53 | Other | something_strange | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,668 | output = pd.DataFrame(predicted,columns = ['Outcome'])
test = pd.read_csv('../input/test.csv')
output['Id'] = test['Id']
output[['Id','Outcome']].to_csv('submission.csv', index = False)
output.head() | Yes | 1 | 12 | Data_Transform | create_dataframe | 1,202,208 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,669 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import itertools
import graphviz
from sklearn.preprocessing import Imputer
from sklearn.model_selection import train_test_split, cross_val_score, KFold
from sklearn.metrics import confusion_matrix
from sklearn import tree
from... | Yes | 3 | 22 | Environment | import_modules | 1,202,586 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
6,670 | trainingData = read_csv('../input/train.csv')
trainingData=trainingData[['Id','Pregnancies','Glucose','BloodPressure','SkinThickness','Insulin','BMI','DiabetesPedigreeFunction','Age','Outcome']]
testingData = read_csv('../input/test.csv')
testingData=testingData[['Id','Pregnancies','Glucose','BloodPressure','SkinThick... | Yes | 1 | 12 | Data_Transform | create_dataframe | 1,202,586 | 1 | A | 0 | 0 | 0 | 0 | 0 | 14 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,671 | #model = DecisionTreeClassifier(max_depth=2,min_samples_leaf=2)<br>model = GradientBoostingClassifier(n_estimators=110, max_depth=3, min_samples_split=310, min_samples_leaf=5, max_features=7, subsample=0.85, learning_rate=0.1)<br>#model = XGBClassifier( learning_rate =0.1, n_estimators=10, max_depth=5, min_child_weight... | Yes | 1 | 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 |
6,672 | test = testingData
test = pd.DataFrame(test)
test.columns=['Id','Pregnancies','Glucose','BloodPressure','SkinThickness','Insulin','BMI','DiabetesPedigreeFunction','Age']
test2 = test.drop(['Id'], axis=1)
my_predictions = model.predict(test2)
Identifier = test.Id.astype(int)
my_submission = pd.DataFrame({'Id': Identifie... | Yes | 1 | 12 | Data_Transform | create_dataframe | 1,202,586 | 1 | A | 0 | 0 | 0 | 0 | 0 | 8 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,673 | from __future__ import print_function
import math
from IPython import display
from matplotlib import cm
from matplotlib import gridspec
from matplotlib import pyplot as plt
import numpy as np
import pandas as pd
from sklearn import metrics
import tensorflow as tf
from tensorflow.python.data import Dataset
import seab... | Yes | 3 | 22 | Environment | import_modules | 1,224,911 | 1 | A | 0 | 0 | 0 | 0 | 0 | 15 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Magic number detected: 10", "fix": "Not specified", "benefits": "Not specified", "location": "Line 21"}] | A | no applicable ML-specific findings | [] | ["Magic number"] | 5 | A |
6,674 | data = pd.read_csv("../input/train.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 |
6,675 | data = data.reindex(
np.random.permutation(data.index))
data.head() | Yes | 3 | 41 | Debug | show_table | 1,224,911 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "NumPy", "name": "Randomness Control Checker", "fix": "Use np.random.seed() for reproducibility.", "benefits": "Enables reproducible results and debugging.", "location": ""}] | B | Randomness Control Checker=low | [{"type": "Randomness Control Checker", "severity": "low"}] | [] | 5 | B |
6,676 | sns.heatmap(data.corr(), annot=True) | 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 |
6,677 | data.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 |
6,678 | data['Outcome'].hist(bins = 20) | No | 5 | 33 | Visualization | distribution | 1,224,911 | 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 |
6,679 | sns.pairplot(data, hue='Outcome') | No | 5 | 33 | Visualization | distribution | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,680 | data[['Pregnancies',
'Glucose',
'BloodPressure',
'SkinThickness',
'Insulin',
'BMI',
'DiabetesPedigreeFunction',
'Age']].hist(figsize=(16, 10), bins=50, xlabelsize=8, ylabelsize=8); | No | 5 | 33 | Visualization | distribution | 1,224,911 | 1 | A | 0 | 0 | 0 | 0 | 0 | 8 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
6,681 | data=data[data['Pregnancies']<=11]
data=data[data['BMI']>=12]
data=data[data['BloodPressure']>40]
data=data[data['Glucose']>40]
data=data[data['SkinThickness']<60] | No | 5 | 14 | Data_Transform | filter | 1,224,911 | 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 |
6,682 | data.describe() | No | 4 | 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 |
6,683 | def my_input_fn(features, targets, batch_size=1, shuffle=True, num_epochs=None):
# Convert pandas data into a dict of np arrays.
features = {key:np.array(value) for key,value in dict(features).items()}
# Construct a dataset, and configure batching/repeating.
... | Yes | 1 | 12 | Data_Transform | create_dataframe | 1,224,911 | 1 | A | 0 | 2 | 1 | 0 | 0 | 8 | 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": "ScikitLearn", "name": "Random... | B | Randomness Control Checker=low | [{"type": "Randomness Control Checker", "severity": "low"}] | ["Array Creation Efficiency", "Missing function docstring"] | 5 | B |
6,684 | def train_linear_classifier_model(<br> learning_rate,<br> steps,<br> hidden_units,<br> batch_size,<br> training_examples,<br> training_targets,<br> validation_examples,<br> validation_targets):<br> periods = 45<br> steps_per_period = steps / periods<br> # Create a linear classifier obje... | Yes | 1 | 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 |
6,685 | DNN_classifier = train_linear_classifier_model(
learning_rate=0.001,
steps=800,
batch_size=80,
hidden_units=[10, 10,10],
training_examples=training_examples,
training_targets=training_targets,
validation_examples=validation_examples,
validation_targets=validation_targets) | No | 4 | 4 | Model_Train | choose_model_class | 1,224,911 | 1 | A | 0 | 0 | 0 | 0 | 0 | 9 | 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"}] | ["Dependent Threshold Checker", "Logging Checker", "Model Evaluation Checker"] | 5 | B |
6,686 | testData = pd.read_csv("../input/test.csv") | No | 5 | 45 | Data_Extraction | load_from_csv | 1,224,911 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/test.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 6"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 5 | A |
6,687 | testData.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 |
6,688 | testData.isna().sum()
testData['Outcome'] = 0 | Yes | 4 | 39 | EDA | count_missing_values | 1,224,911 | 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 |
6,689 | test_examples = preprocess_features(testData)
test_examples.head() | Yes | 3 | 41 | Debug | show_table | 1,224,911 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
6,690 | test_validations = preprocess_targets(testData) | No | 1 | 53 | Other | something_strange | 1,224,911 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
6,691 | predict_test_input_fn = lambda: my_input_fn(test_examples, <br> test_validations["Outcome"], <br> num_epochs=1, <br> shuffle=False)<br><br>test_predictions = DNN_classifier.... | Yes | 2 | 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 |
6,692 | testData[['Id','Outcome']].to_csv('Submit.csv', index = False) | No | 5 | 25 | Data_Export | save_to_csv | 1,224,911 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
6,693 | # 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... | Yes | 4 | 22 | Environment | import_modules | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,694 |
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
from pandas import DataFrame, Series
import random
from tqdm import tqdm
import os
import math
import numpy as np
import h5py
import matplotlib.pyplot as plt
import tensorflow as tf
from tensorflow.python.framewo... | No | 5 | 22 | Environment | import_modules | 1,260,698 | 1 | A | 0 | 0 | 0 | 0 | 0 | 25 | ok | 2 | 1 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 3"}, {"detector": "framework_specific", "framework": "General", "name": "Import Checker", ... | A | no applicable ML-specific findings | [] | ["Import Checker"] | 5 | A |
6,695 | train_path = '../input/train/*.jpg'
x_train_adres = glob.glob(train_path)
m_train = len(x_train_adres)
y_train = np.zeros((m_train,1))
for i,ca in enumerate(x_train_adres):
if 'cat' in ca:
y_train[i] = 1
print(y_train.shape)
# print(y_train)
# print(x_train_adres[m_train-1])
| Yes | 2 | 58 | Debug | show_shape | 1,260,698 | 1 | A | 1 | 2 | 3 | 0 | 5 | 8 | ok | 4 | 4 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 3"}, {"detector": "framework_specific", "framework": "NumPy", "name": "Array Creation Effi... | A | no applicable ML-specific findings | [] | ["Array Creation Efficiency", "Column Selection Checker", "Hardcoded file path", "Import Checker"] | 5 | A |
6,696 | trainingFeatures2 = trainingFeatures.drop(['Pregnancies','BloodPressure','DiabetesPedigreeFunction', 'Age','SkinThickness','Insulin','Id'], axis=1) | No | 5 | 10 | Data_Transform | drop_column | 1,175,067 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,697 | test = testingData
test = pd.DataFrame(test)
test.columns=['Id','Pregnancies','Glucose','BloodPressure','SkinThickness','Insulin','BMI','DiabetesPedigreeFunction','Age']
test2 = test.drop(['Id','Pregnancies','BloodPressure','DiabetesPedigreeFunction', 'Age','SkinThickness','Insulin'], axis=1)
my_predictions = model.pre... | Yes | 2 | 25 | Data_Export | save_to_csv | 1,175,067 | 1 | A | 0 | 0 | 0 | 0 | 0 | 9 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
6,698 | # 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 |
6,699 | import numpy as np
import pandas as pd
train = pd.read_csv("../input/train.csv")
test = pd.read_csv("../input/test.csv") | Yes | 4 | 45 | Data_Extraction | load_from_csv | 1,270,236 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 4 | 3 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}, {"detector": "general_ml", "framework": "Genera... | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker", "Hardcoded file path", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness."] | 7 | A |
6,700 | X_train = train.iloc[:, 2:-1].values
Y_train = train.iloc[:, 21].values
X_test = test.iloc[:, 2:].values | No | 5 | 21 | Data_Transform | prepare_x_and_y | 1,270,236 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker"] | 7 | A |
6,701 | X_all = np.concatenate((X_train, X_test), axis=0)
| No | 5 | 11 | Data_Transform | concatenate | 1,270,236 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker"] | 7 | A |
6,702 | from sklearn.preprocessing import Imputer
imputer = Imputer(missing_values = 'NaN', strategy = 'most_frequent', axis = 0)
imputer = imputer.fit(X_all)
X_all = imputer.transform(X_all) | No | 5 | 17 | Data_Transform | correct_missing_values | 1,270,236 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 9 | 8 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | D | Cross Validation Checker=low, Data Leakage Checker=high, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Dependent Threshold Checker", "Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 7 | D |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.