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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1,447 | test_stage_1[0:5] | No | 5 | 41 | Debug | show_table | 2,843,645 | 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": "Dependent Th... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Dependent Threshold Checker"] | 3 | A |
1,448 | # assigning the GAP dev data as test data
test_df = pd.read_csv("https://raw.githubusercontent.com/google-research-datasets/gap-coreference/master/gap-development.tsv", delimiter='\\t')
# assigning the GAP test data as train data
train_df = pd.read_csv("https://raw.githubusercontent.com/google-research-datasets/gap-cor... | No | 5 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,449 | # using the full set of training and validation data
train_df = pd.concat([train_df,valid_df]) | No | 5 | 11 | Data_Transform | concatenate | 2,843,645 | 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"] | 3 | A |
1,450 | def scrape_url(url):
'''
get the title of the wikipedia page and replace "_" with white space
'''
return url[29:].lower().replace("_"," ")
def check_name_in_string(name,string):
'''
check whether the name string is a substring of another string (i.e. wikipedia title)
'''
return name.lo... | 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 |
1,451 | gold_train = []
for index, row in train_df.iterrows():
if (row["A-coref"]):
gold_train.append("A")
else:
if (row["B-coref"]):
gold_train.append("B")
else:
gold_train.append("NEITHER")
gold_test = []
for index, row in test_df.iterrows():
if (row[... | No | 3 | 12 | Data_Transform | create_dataframe | 2,843,645 | 1 | A | 0 | 6 | 16 | 0 | 0 | 18 | ok | 4 | 4 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida... | B | Cross Validation Checker=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Column Selection Checker", "Dependent Threshold Checker"] | 3 | B |
1,452 |
print(f1_score( gold_train, train_pred, average='micro'))
print(classification_report( gold_train, train_pred))
print(confusion_matrix(gold_train, train_pred)) | No | 5 | 28 | Model_Train | compute_train_metric | 2,843,645 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}, {"detector": "framework_specific", "framework":... | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker", "Unit Testing Checker"] | 3 | A |
1,453 | def prec_prob(gold, pred, test):
'''
Using the training set to determine the precision by class
and assigning it to the test data set
'''
scores = []
precision = precision_score(gold, pred, average=None,
labels=['A','B','NEITHER'])
A_prec = precision[0]
B... | No | 3 | 49 | Model_Evaluation | compute_test_metric | 2,843,645 | 1 | A | 3 | 4 | 8 | 0 | 6 | 16 | 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": "Dependent Th... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Dependent Threshold Checker", "Unit Testing Checker"] | 3 | A |
1,454 |
scores_train = prec_prob(gold_train, train_pred, train_pred)
log_loss(gold_train,scores_train) | No | 4 | 49 | Model_Evaluation | compute_test_metric | 2,843,645 | 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"] | 3 | A |
1,455 |
scores_test = prec_prob(gold_train, train_pred, test_pred)
log_loss(gold_test,scores_test) | No | 4 | 49 | Model_Evaluation | compute_test_metric | 2,843,645 | 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"] | 3 | A |
1,456 | sample_submission = pd.read_csv("../input/sample_submission_stage_1.csv") | No | 5 | 45 | Data_Extraction | load_from_csv | 2,843,645 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}, {"detector": "general_ml", "framework": "Genera... | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker", "Hardcoded file path"] | 3 | A |
1,457 | sample_submission[['A','B','NEITHER']] = scores_test | No | 5 | 55 | Data_Export | prepare_output | 2,843,645 | 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"] | 3 | A |
1,458 | sample_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 |
1,459 | #Gender classification using universal data set
#import libaries
import numpy as np
import pandas as pd
#ML Packages
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.feature_extraction import DictVectorizer
#load teh data set
data_set ... | 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 |
1,460 | train_set = pd.read_csv("../input/gendered-pronoun-resolution/test_stage_1.tsv", encoding="utf-8", error_bad_lines=False, delimiter='\\t')
train_set["A"] = train_set["A"].apply(Predict)
train_set["B"] = train_set["B"].apply(Predict)
' | No | 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 |
1,461 | train_set = train_set[["ID", "A", 'B'] ]' | No | 5 | 10 | Data_Transform | drop_column | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,462 |
train_set["NEITHER"] = abs(train_set["NEITHER"].astype(int)) | No | 5 | 16 | Data_Transform | data_type_conversions | 2,874,738 | 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 |
1,463 | train_set.to_csv('sub.csv', index=False) | No | 5 | 25 | Data_Export | save_to_csv | 2,874,738 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}] | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | [] | 7 | B |
1,464 | b"import numpy as np\nimport pandas as pd\nimport spacy\nfrom spacy import displacy\nnlp = spacy.load('en_core_web_sm')\nimport nltk\nfrom sklearn import *\n\ntest = pd.read_csv('../input/test_stage_2.tsv', delimiter='\\t').rename(columns={'A': 'A_Noun', 'B': 'B_Noun'})\nsub = pd.read_csv('../input/sample_submission_st... | No | 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 |
1,465 | gh_test = pd.read_csv("https://raw.githubusercontent.com/google-research-datasets/gap-coreference/master/gap-test.tsv", delimiter='\\t')
#Adding gh_train for stage two submission with new test data, will also add any new data available via Kaggle Competition data for stage2 :)
gh_train = pd.read_csv("https://raw.github... | 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 |
1,466 | def name_replace(s, r1, r2):
s = str(s).replace(r1,r2)
for r3 in r1.split(' '):
s = str(s).replace(r3,r2)
return s
def get_features(df):
df['section_min'] = df[['Pronoun-offset', 'A-offset', 'B-offset']].min(axis=1)
df['Pronoun-offset2'] = df['Pronoun-offset'] + df['Pronoun'].map(len)
d... | Yes | 5 | 8 | Data_Transform | feature_engineering | null | 1 | A | 1 | 3 | 1 | 0 | 5 | 25 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,467 | def get_nlp_features(s, w):
doc = nlp(str(s))
tokens = pd.DataFrame([[token.text, token.dep_] for token in doc], columns=['text', 'dep'])
return len(tokens[((tokens['text']==w) & (tokens['dep']=='poss'))])
train['A-poss'] = train['Text'].map(lambda x: get_nlp_features(x, 'subjectone'))
train['B-poss'] = tr... | No | 4 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 1 | 0 | 0 | 0 | 8 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,468 | train = train.rename(columns={'A-coref':'A', 'B-coref':'B'})
train['A'] = train['A'].astype(int)
train['B'] = train['B'].astype(int)
train['NEITHER'] = 1.0 - (train['A'] + train['B']) | No | 4 | 16 | Data_Transform | data_type_conversions | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,469 | test_stage_1 = pd.read_csv("../input/test_stage_1.tsv", sep="\\t")
test_stage_2 = pd.read_csv("../input/test_stage_2.tsv", sep="\\t")' | No | 5 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,470 | gap_test = pd.read_csv("https://raw.githubusercontent.com/google-research-datasets/gap-coreference/master/gap-test.tsv", delimiter='\\t')
gap_valid = pd.read_csv("https://raw.githubusercontent.com/google-research-datasets/gap-coreference/master/gap-validation.tsv", delimiter='\\t')' | No | 5 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,471 | gap_test[0:5] | No | 5 | 41 | Debug | show_table | 2,895,967 | 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 |
1,472 | def get_prior(df):
# count how many times neither antecedent is correct for the pronoun
Neither_count = len(df) - sum(df["A-coref"] | df["B-coref"])
# count the A coreferences
A_count = sum(df["A-coref"])
# count the B coreferences
B_count = sum(df["B-coref"])
# total number of samples
... | No | 5 | 8 | Data_Transform | feature_engineering | 2,895,967 | 1 | A | 6 | 1 | 0 | 0 | 12 | 13 | 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": "general_ml", "framework": "General ML", "name": "Missing docstring for... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Missing function docstring"] | 3 | A |
1,473 | sample_submission = pd.read_csv("../input/sample_submission_stage_1.csv")
| No | 5 | 45 | Data_Extraction | load_from_csv | 2,895,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/sample_submission_stage_1.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 4"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 3 | A |
1,474 | def assign_prior(df):
sub = pd.DataFrame()
for index, row in df.iterrows():
sub.loc[index, "ID"] = row["ID"]
sub.loc[index, "A"] = A_prior
sub.loc[index, "B"] = B_prior
sub.loc[index, "NEITHER"] = Neither_prior
return sub | No | 5 | 8 | Data_Transform | feature_engineering | 2,895,967 | 1 | A | 0 | 2 | 1 | 0 | 0 | 8 | 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": "general_ml", "framework": "General ML", "name": "Missing docstring for... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Missing function docstring"] | 3 | A |
1,475 | train = assign_prior(gap_test)
valid = assign_prior(gap_valid) | No | 5 | 53 | Other | something_strange | 2,895,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
1,476 | from sklearn.metrics import log_loss
def get_gold(df):
gold = []
for index, row in df.iterrows():
if (row["A-coref"]):
gold.append("A")
else:
if (row["B-coref"]):
gold.append("B")
else:
gold.append("NEITHER")
return gold | No | 5 | 53 | Other | something_strange | 2,895,967 | 1 | A | 0 | 4 | 8 | 0 | 0 | 12 | 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": "general_ml", "framework": "General ML", "name": "Missing docstring for... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Missing function docstring"] | 3 | A |
1,477 | train_gold = get_gold(gap_test)
valid_gold = get_gold(gap_valid) | No | 5 | 8 | Data_Transform | feature_engineering | 2,895,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
1,478 | train_pred = train[["A","B","NEITHER"]]
log_loss(train_gold,train_pred) | No | 3 | 8 | Data_Transform | feature_engineering | 2,895,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
1,479 | valid_pred = valid[["A","B","NEITHER"]]
log_loss(valid_gold,valid_pred) | No | 3 | 8 | Data_Transform | feature_engineering | 2,895,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
1,480 | sub1 = assign_prior(test_stage_1) | No | 3 | 8 | Data_Transform | feature_engineering | 2,895,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
1,481 | sub1[0:4] | No | 5 | 41 | Debug | show_table | 2,895,967 | 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 |
1,482 | sub1.to_csv("submission_1.csv", index=False) | No | 5 | 25 | Data_Export | save_to_csv | 2,895,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
1,483 | train_female = assign_prior(female_gap_test)
train_male = assign_prior(male_gap_test)
valid_female = assign_prior(female_gap_valid)
valid_male = assign_prior(male_gap_valid) | No | 3 | 8 | Data_Transform | feature_engineering | 2,895,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
1,484 | train_gold_female = get_gold(female_gap_test)
train_gold_male = get_gold(male_gap_test) | No | 3 | 8 | Data_Transform | feature_engineering | 2,895,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
1,485 | train_pred_female = train_female[["A","B","NEITHER"]]
log_loss(train_gold_female,train_pred_female) | No | 3 | 8 | Data_Transform | feature_engineering | 2,895,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
1,486 | train_pred_male = train_male[["A","B","NEITHER"]]
log_loss(train_gold_male,train_pred_male) | No | 3 | 8 | Data_Transform | feature_engineering | 2,895,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
1,487 | test_df_pop=pd.merge(test_df, country_lookup, how='left', left_on='Country_Region', right_on='Country (or dependency)') | No | 5 | 32 | Data_Transform | merge | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
1,488 | test_df_pop.info() | No | 5 | 40 | Debug | show_table_attributes | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
1,489 | train_df_pop.drop("Country (or dependency)", axis=1, inplace=True) | No | 5 | 10 | Data_Transform | drop_column | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 2 | 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 8"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Chec... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["InPlace Checker"] | 7 | B |
1,490 | test_df_pop.drop("Country (or dependency)", axis=1, inplace=True) | No | 5 | 10 | Data_Transform | drop_column | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "Assign operations to a new DataFrame variable.", "benefits": "Prevents data loss and improves code clarity.", "location": "Line 8"}] | A | no applicable ML-specific findings | [] | ["InPlace Checker"] | 7 | A |
1,491 | %load_ext google.cloud.bigquery | 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 |
1,492 | weather_df["da"]=weather_df["da"].astype(int) | No | 5 | 16 | Data_Transform | data_type_conversions | 8,679,319 | 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 |
1,493 | weather_df['day_from_jan_first'] = weather_df["da"] + 31*(weather_df["mo"]=='02') + 60*(weather_df["mo"]=='03') + 91*(weather_df["mo"]=='04')
' | 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 |
1,494 | train_wk1=pd.read_csv("../input/training-dataset-from-covid-19-week-1-forecasting/train-3.csv")
| No | 5 | 45 | Data_Extraction | load_from_csv | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/training-dataset-from-covid-19-week-1-forecasting/train-3.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 8"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 7 | A |
1,495 | train_wk1['country+province'] = train_wk1['Country/Region'].fillna('') + '-' + train_wk1['Province/State'].fillna('')
train_df_pop['country+province'] = train_df_pop['Country_Region'].fillna('') + '-' + train_df_pop['Province_State'].fillna('')
test_df_pop['country+province'] = test_df_pop['Country_Region'].fillna('') ... | No | 4 | 17 | Data_Transform | correct_missing_values | 8,679,319 | 2 | B | 1 | 0 | 0 | 0 | 6 | 3 | ok | 6 | 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", "Hardcoded file path"] | 7 | B |
1,496 | df = train_wk1.groupby('country+province')[['Lat', 'Long']].mean() | No | 5 | 60 | Data_Transform | groupby | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | [] | 7 | B |
1,497 | train_df_pop.reset_index(drop=True, inplace=True) | No | 5 | 84 | Other | not_enough_vertices | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}] | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | [] | 7 | B |
1,498 | train_df_pop["Id"]=train_df_pop.index | No | 5 | 8 | Data_Transform | feature_engineering | 8,679,319 | 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 |
1,499 | train_df_pop.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 |
1,500 | labelencoder = LabelEncoder() | No | 5 | 20 | Data_Transform | categorify | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,501 | train_df_pop['Country_Region_Types'] = labelencoder.fit_transform(train_df_pop['Country_Region']) | No | 5 | 20 | Data_Transform | categorify | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | 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... | D | Cross Validation Checker=low, Data Leakage Checker=high | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}] | ["Column Selection Checker", "Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 7 | D |
1,502 | test_df_pop['Country_Region_Types'] = labelencoder.fit_transform(test_df_pop['Country_Region']) | No | 5 | 20 | Data_Transform | categorify | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | 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... | D | Cross Validation Checker=low, Data Leakage Checker=high | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}] | ["Column Selection Checker", "Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 7 | D |
1,503 | train_df_pop.head() | No | 5 | 41 | Debug | show_table | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}] | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | [] | 7 | B |
1,504 | test_df_pop.head() | No | 5 | 41 | Debug | show_table | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
1,505 | train_df_pop.rename(columns={"Population (2020)":"Population"}, inplace=True) | No | 5 | 61 | Data_Transform | rename_columns | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 2 | 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 8"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Chec... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["InPlace Checker"] | 7 | B |
1,506 | test_df_pop.rename(columns={"Population (2020)":"Population"}, inplace=True) | No | 5 | 61 | Data_Transform | rename_columns | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "Assign operations to a new DataFrame variable.", "benefits": "Prevents data loss and improves code clarity.", "location": "Line 8"}] | A | no applicable ML-specific findings | [] | ["InPlace Checker"] | 7 | A |
1,507 | X_dataset=train_df_pop.copy() | No | 5 | 12 | Data_Transform | create_dataframe | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}] | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | [] | 7 | B |
1,508 | X_dataset=X_dataset[["Date","Population","Density","day_from_jan_first","temp","min","max","stp","wdsp","prcp","fog","Country_Region_Types","Lat","Long"]] | No | 5 | 10 | Data_Transform | drop_column | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
1,509 | X_dataset["Date"] = X_dataset["Date"].apply(lambda x:x.replace("-",""))
X_dataset["Date"] = X_dataset["Date"].astype(int) | No | 3 | 16 | Data_Transform | data_type_conversions | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 7 | A |
1,510 | X_dataset.info() | No | 5 | 40 | Debug | show_table_attributes | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
1,511 | X_dataset.head() | No | 5 | 41 | Debug | show_table | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
1,512 | X_dataset["fog"] = X_dataset["fog"].astype(int)
X_dataset["wdsp"] = X_dataset["wdsp"].astype(float) | No | 5 | 16 | Data_Transform | data_type_conversions | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 7 | A |
1,513 | X_dataset["Date"].max() | No | 5 | 40 | Debug | show_table_attributes | 8,679,319 | 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 |
1,514 | valid_gold_female = get_gold(female_gap_valid)
valid_gold_male = get_gold(male_gap_valid) | No | 3 | 8 | Data_Transform | feature_engineering | 2,895,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
1,515 | valid_pred_female = valid_female[["A","B","NEITHER"]]
log_loss(valid_gold_female,valid_pred_female) | No | 3 | 8 | Data_Transform | feature_engineering | 2,895,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
1,516 | valid_pred_male = valid_male[["A","B","NEITHER"]]
log_loss(valid_gold_male,valid_pred_male) | No | 3 | 8 | Data_Transform | feature_engineering | 2,895,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
1,517 | len(female_test_stage_2) | No | 4 | 58 | Debug | show_shape | 2,895,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
1,518 | len(male_test_stage_2) | No | 5 | 58 | Debug | show_shape | 2,895,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
1,519 | sub2 = assign_prior(test_stage_2) | No | 3 | 8 | Data_Transform | feature_engineering | 2,895,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
1,520 | sub2.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 |
1,521 | sub2.to_csv("submission.csv", index=False) | No | 5 | 25 | Data_Export | save_to_csv | 2,895,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
1,522 | import numpy as np
import pandas as pd
import spacy
from spacy import displacy
nlp = spacy.load("en_core_web_sm")
import nltk
from sklearn import *
from sklearn.model_selection import KFold
from sklearn.ensemble import RandomForestClassifier
import xgboost as xgb
from xgboost import XGBClassifier
import lightgbm as lgb... | Yes | 4 | 45 | Data_Extraction | load_from_csv | 2,897,818 | 1 | A | 1 | 0 | 0 | 0 | 5 | 15 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
1,523 | test = pd.read_csv("../input/test_stage_1.tsv", delimiter="\\t").rename(columns={"A": "A_Noun", "B": "B_Noun"})
sub = pd.read_csv("../input/sample_submission_stage_1.csv")
test.shape, sub.shape' | 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 |
1,524 | gh_test = pd.read_csv("https://raw.githubusercontent.com/google-research-datasets/gap-coreference/master/gap-test.tsv", delimiter='\\t')
gh_valid = pd.read_csv("https://raw.githubusercontent.com/google-research-datasets/gap-coreference/master/gap-validation.tsv", delimiter='\\t')
train = pd.concat((gh_test, gh_valid)).... | Yes | 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 |
1,525 | def name_replace(s, r1, r2):
s = str(s).replace(r1,r2)
for r3 in r1.split(" "):
s = str(s).replace(r3,r2)
return s
def get_features(df):
df['section_min'] = df[['Pronoun-offset', 'A-offset', 'B-offset']].min(axis=1)
df['Pronoun-offset2'] = df['Pronoun-offset'] + df['Pronoun'].map(len)
d... | 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 |
1,526 | %%time
def get_nlp_features(s, w):
doc = nlp(str(s))
tokens = pd.DataFrame([[token.text, token.dep_] for token in doc], columns=['text', 'dep'])
return len(tokens[((tokens['text']==w) & (tokens['dep']=='poss'))])
train['A-poss'] = train['Text'].map(lambda x: get_nlp_features(x, 'subjectone'))
train['B-poss... | No | 5 | 8 | Data_Transform | feature_engineering | 2,897,818 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 5 | null |
1,527 | train = train.rename(columns={"A-coref": "A", "B-coref": "B"})
train["A"] = train["A"].astype(int)
train["B"] = train["B"].astype(int)
train["NEITHER"] = 1.0 - (train["A"] + train["B"]) | No | 4 | 16 | Data_Transform | data_type_conversions | 2,897,818 | 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": "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"] | 5 | B |
1,528 | col = ["Pronoun-offset", "A-offset", "B-offset", "section_min", "Pronoun-offset2", "A-offset2", "B-offset2", "section_max", "A-poss", "B-poss", "A-dist", "B-dist"]
x1, x2, y1, y2 = model_selection.train_test_split(train[col].fillna(-1), train[["A", "B", "NEITHER"]], test_size=0.2, random_state=1)
x1.head() | No | 4 | 13 | Data_Transform | split | 2,897,818 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name... | B | Cross Validation Checker=low, Cross-validation not detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}] | [] | 5 | B |
1,529 | # set hyper parameters
lgb_params = {"learning_rate": 0.01,
"num_leaves": 16,
"min_data_in_leaf": 20,
"boosting": "gbdt",
"num_iterations": 120,
"bagging_fraction": 0.6,
"feature_fraction": 1.0,
"seed": 42,
"... | Yes | 3 | 7 | Model_Train | train_model | 2,897,818 | 1 | A | 2 | 1 | 1 | 0 | 10 | 45 | ok | 11 | 7 | [{"detector": "framework_specific", "framework": "NumPy", "name": "Missing Axis Specification", "fix": "Specify axis in array operations.", "benefits": "Improves performance and avoids unexpected behaviour.", "location": "Line 53"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Verbose Mode Ch... | C | Missing Axis Specification=medium | [{"type": "Missing Axis Specification", "severity": "medium"}] | ["Dependent Threshold Checker", "Exception Handling Checker", "Magic number", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 5 | C |
1,531 | b"test = pd.read_csv('../input/test_stage_1.tsv', delimiter='\\t').rename(columns={'A': 'A_Noun', 'B': 'B_Noun'})\nsub = pd.read_csv('../input/sample_submission_stage_1.csv')\ntest.shape, sub.shape" | No | 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 |
1,532 | # True test here:
#gh_train = pd.read_csv("https://raw.githubusercontent.com/google-research-datasets/gap-coreference/master/gap-development.tsv", delimiter='\\t')
gh_test = pd.read_csv("https://raw.githubusercontent.com/google-research-datasets/gap-coreference/master/gap-test.tsv", delimiter='\\t')
gh_valid = pd.read... | 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 |
1,533 | def get_coref(row):
coref = None
nlpr = nlp(row['Text'])
# dunno if more direct way to get token from text offset
for tok in nlpr.doc:
if tok.idx == row['Pronoun-offset']:
# model limitation that sometimes there are no coref clusters for the token?
# also, somet... | Yes | 2 | 8 | Data_Transform | feature_engineering | 2,942,474 | 1 | A | 3 | 8 | 15 | 0 | 9 | 20 | 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": "general_ml", "framework": "General ML", "name": "Missing docstring for... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Missing function docstring"] | 4 | A |
1,534 | def get_coref_features(df):
df['Coref'] = df.apply(get_coref, axis=1)
df['Spacy-Coref-A'] = df['Coref'] == df['A_Noun'].str.lower()
df['Spacy-Coref-B'] = df['Coref'] == df['B_Noun'].str.lower()
return df
train = get_coref_features(train)
test = get_coref_features(test) | No | 2 | 8 | Data_Transform | feature_engineering | 2,942,474 | 1 | A | 0 | 1 | 0 | 0 | 0 | 7 | 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": "general_ml", "framework": "General ML", "name": "Missing docstring for... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Missing function docstring"] | 4 | A |
1,535 | def name_replace(s, r1, r2):
s = str(s).replace(r1,r2)
for r3 in r1.split(' '):
s = str(s).replace(r3,r2)
return s
def get_features(df):
df['section_min'] = df[['Pronoun-offset', 'A-offset', 'B-offset']].min(axis=1)
df['Pronoun-offset2'] = df['Pronoun-offset'] + df['Pronoun'].map(len)
d... | No | 3 | 8 | Data_Transform | feature_engineering | null | 1 | A | 1 | 3 | 1 | 0 | 5 | 18 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,536 | col = ['Pronoun-offset', 'A-offset', 'B-offset', 'section_min', 'Pronoun-offset2', 'A-offset2', 'B-offset2', 'section_max', 'A-poss', 'B-poss', 'A-dist', 'B-dist', 'Spacy-Coref-A', 'Spacy-Coref-B']
x1, x2, y1, y2 = model_selection.train_test_split(train[col].fillna(-1), train[['A', 'B', 'NEITHER']], test_size=0.2, rand... | No | 4 | 13 | Data_Transform | split | 2,942,474 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name... | B | Cross Validation Checker=low, Cross-validation not detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}] | [] | 4 | B |
1,537 | model = multiclass.OneVsRestClassifier(ensemble.RandomForestClassifier(max_depth = 7, n_estimators=1000, random_state=33))
# model = multiclass.OneVsRestClassifier(ensemble.ExtraTreesClassifier(n_jobs=-1, n_estimators=100, random_state=33))
# param_dist = {'objective': 'binary:logistic', 'max_depth': 1, 'n_estimators'... | No | 3 | 7 | Model_Train | train_model | null | 1 | A | 2 | 0 | 0 | 0 | 10 | 9 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,538 | import os
import csv
import json
import string
import keras
from pandas.io.json import json_normalize
import matplotlib.pyplot as plt
import seaborn as sns
color = sns.color_palette()
from math import floor
import spacy
%matplotlib inline
from plotly import tools
import plotly.offline as py
py.init_notebook_mode(conn... | No | 5 | 23 | Environment | set_options | 3,001,116 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 2 | null |
1,539 | nlp = spacy.load('en_core_web_sm') | No | 5 | 30 | Model_Train | load_pretrained | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,540 | y1=train_df_pop[train_df_pop["Date"]<"2020-03-19"]["ConfirmedCases"]
y2=train_df_pop[train_df_pop["Date"]<"2020-03-19"]["Fatalities"] | No | 5 | 14 | Data_Transform | filter | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 3 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Chain Indexing", "fix": "Use single indexing or .loc[], .iloc[] methods.", "benefits": "Enhances code readability and prevents performance issues.", "location": "Line 8"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Chain Indexin... | A | no applicable ML-specific findings | [] | ["Chain Indexing", "Column Selection Checker"] | 7 | A |
1,541 | print(find_name_between_paran(analyze)) | No | 5 | 53 | Other | something_strange | 3,001,116 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
1,542 | #Confirmed Cases
X_train_confirmed, X_test_confirmed, y_train_confirmed, y_test_confirmed = train_test_split(X_dataset, y1, test_size = .20, random_state = 42) | No | 5 | 13 | Data_Transform | split | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}] | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | [] | 7 | B |
1,543 | results_df = pd.DataFrame({"correct":correct_name_list})
results_df['prv_obj'] = prev_dobj_list
results_df['pr_ls_sbj'] = prev_subj_list
results_df['pr_1_sbj'] = prev_first_subj_list
results_df['pr_2_sbj'] = prev_second_subj_list
results_df['c1st_sj'] = curr1st_subj_list
results_df['c2nd_sj'] = curr2nd_subj_list
result... | No | 3 | 55 | Data_Export | prepare_output | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,544 | import plotly.express as px
import pandas as pd
import plotly.graph_objects as go
import numpy as np
datafile = '../input/covid19-global-forecasting-week-2/train.csv'
data = pd.read_csv(datafile)
data['PSCR'] = data.Province_State.map(str)+data.Country_Region.map(str)
# %%
# ip pattern of the empirical data from 2020... | Yes | 2 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
1,545 | results_df.head(250) | No | 5 | 41 | Debug | show_table | 3,001,116 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
1,546 | dt1=DecisionTreeRegressor(criterion="friedman_mse",max_depth=20,random_state=42) | No | 5 | 4 | Model_Train | choose_model_class | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,547 | dt1.fit(X_train_confirmed, y_train_confirmed) | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.