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,548 | print(text_list[229]) | No | 5 | 41 | Debug | show_table | 3,001,116 | 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"] | 2 | A |
1,549 | y_pred_dt_confirmed=dt1.predict(X_test_confirmed) | 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 |
1,550 | np.sqrt(mean_squared_log_error( y_test_confirmed, y_pred_dt_confirmed )) | No | 5 | 49 | Model_Evaluation | compute_test_metric | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,551 | train = pd.concat([train,pd.get_dummies(train['Country_Region'], prefix='ps')],axis=1)
train.drop(['Country_Region'],axis=1, inplace=True)
train = pd.concat([train,pd.get_dummies(train['Province_State'], prefix='ps')],axis=1)
train.drop(['Province_State'],axis=1, inplace=True) | Yes | 3 | 11 | Data_Transform | concatenate | 8,658,083 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 6 | 5 | [{"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "Assign operations to a new DataFrame variable.", "benefits": "Prevents data loss and improves code clarity.", "location": "Line 5"}, {"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Column Selection Checker", "InPlace Checker"] | 3 | B |
1,552 | doc = nlp(analyze)
for token in doc:
print(token.text, token.dep_, token.head.pos_) | No | 5 | 41 | Debug | show_table | 3,001,116 | 1 | A | 0 | 1 | 1 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
1,553 | #Fatalities
X_train_fatal, X_test_fatal, y_train_fatal, y_test_fatal = train_test_split(X_dataset, y2, 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,554 | print(text_list[900:950]) | No | 5 | 41 | Debug | show_table | 3,001,116 | 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"] | 2 | A |
1,555 | out_df = pd.DataFrame({"ID":test_ids}) | No | 5 | 12 | Data_Transform | create_dataframe | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,556 | # Using the data on 18 Mar to calculate the tendency of the pandemic.
date_datause = '2020-03-18'
date_actualdata = '2020-03-30'
date_length = (pd.to_datetime(date_actualdata) - pd.to_datetime(date_datause)).days
predict_region_list = []
effect_ind = 0
for it in range(len(region)):
region_it = region[it]
if reg... | Yes | 2 | 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 |
1,557 | # aggregate cases and fatalities
def do_aggregation(df, col, mean_range):
df_new = copy.deepcopy(df)
col_new = '{}_({}-{})'.format(col, mean_range[0], mean_range[1])
df_new[col_new] = 0
tmp = df_new[col].rolling(mean_range[1]-mean_range[0]+1).mean()
df_new[col_new][mean_range[0]:] = tmp[:-(mean_rang... | No | 4 | 8 | Data_Transform | feature_engineering | null | 1 | A | 2 | 5 | 3 | 0 | 16 | 33 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,558 | dt2=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,559 | test = pd.concat([test,pd.get_dummies(test['Country_Region'], prefix='ps')],axis=1)
test.drop(['Country_Region'],axis=1, inplace=True)
test = pd.concat([test,pd.get_dummies(test['Province_State'], prefix='ps')],axis=1)
test.drop(['Province_State'],axis=1, inplace=True) | Yes | 4 | 10 | Data_Transform | drop_column | 8,658,083 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 3 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "Assign operations to a new DataFrame variable.", "benefits": "Prevents data loss and improves code clarity.", "location": "Line 5"}, {"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "InPlace Checker"] | 3 | A |
1,560 | from fastai.text import *
from tqdm import tqdm_notebook as tqdm | No | 5 | 22 | Environment | import_modules | 3,065,122 | 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"] | 1 | A |
1,561 | dt2.fit(X_train_fatal, y_train_fatal) | 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 |
1,562 | y_pred_dt_fatal=dt2.predict(X_test_fatal) | 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 |
1,563 | np.sqrt(mean_squared_log_error( y_test_fatal, y_pred_dt_fatal )) | No | 5 | 49 | Model_Evaluation | compute_test_metric | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,564 | df_traintest3 = []
for place in places[:]:
df_tmp = df_traintest2[df_traintest2['place_id']==place].reset_index(drop=True)
df_tmp = do_aggregations(df_tmp)
df_traintest3.append(df_tmp)
df_traintest3 = pd.concat(df_traintest3).reset_index(drop=True)
df_traintest3[df_traintest3['place_id']=='China/Hubei'].hea... | No | 3 | 11 | Data_Transform | concatenate | null | 1 | A | 0 | 1 | 1 | 0 | 0 | 7 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,565 | out_df['A'] = results_A
out_df['B'] = results_B
out_df['NEITHER'] = results_N | No | 5 | 55 | Data_Export | prepare_output | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,566 | test_data=test_df_pop[["Date","Population","Density","day_from_jan_first","temp","min","max","stp","wdsp","prcp","fog","Country_Region_Types","Lat","Long"]] | No | 5 | 12 | Data_Transform | create_dataframe | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
1,567 | out_df.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,568 | !head -2 ../input/gendered-pronoun-resolution/sample_submission_stage_1.csv | No | 5 | 41 | Debug | show_table | 3,127,294 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 5 | null |
1,569 | test_data.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,570 | # add Smoking rate per country
# data of smoking rate is obtained from https://ourworldindata.org/smoking
df_smoking = pd.read_csv("../input/smokingstats/share-of-adults-who-smoke.csv")
print(np.sort(df_smoking['Entity'].unique())[:10])
df_smoking.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 |
1,571 | import pandas as pd
pd.set_option('max_colwidth', 4000) | No | 4 | 22 | Environment | import_modules | 3,127,294 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
1,572 | test_data["Date"] = test_data["Date"].apply(lambda x:x.replace("-",""))
test_data["Date"] = test_data["Date"].astype(int) | No | 4 | 8 | Data_Transform | feature_engineering | 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,573 | y_confirmed=dt1.predict(test_data) | No | 5 | 48 | Model_Evaluation | predict_on_test | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing Checker", "fix": "Write unit tests for data processing and model components.", "benefits": "Ensures code reliability and prevents bugs.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Excepti... | A | no applicable ML-specific findings | [] | ["Exception Handling Checker", "Unit Testing Checker"] | 7 | A |
1,574 | b"def read_df(path):\n \n df = pd.read_csv(path, index_col='ID', sep='\\t', encoding='utf-8')\n\n # add some columns\n\n # the ending offset of the pronoun and the candidates referring entities\n df['Pronoun-offset-end'] = df['Pronoun-offset'] + df['Pronoun'].str.len()\n df['A-offset-end'] = df['A-off... | 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,575 | # extract newest data
df_smoking_recent = df_smoking.sort_values('Year', ascending=False).reset_index(drop=True)
df_smoking_recent = df_smoking_recent[df_smoking_recent['Entity'].duplicated()==False]
df_smoking_recent['Country_Region'] = df_smoking_recent['Entity']
df_smoking_recent['SmokingRate'] = df_smoking_recent['... | Yes | 3 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,576 | df = read_df('../input/gendered-pronoun-resolution/test_stage_1.tsv')
df.sample() | No | 4 | 45 | Data_Extraction | load_from_csv | 3,127,294 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/gendered-pronoun-resolution/test_stage_1.tsv. 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 |
1,577 | # merge
df_traintest4 = pd.merge(df_traintest3, df_smoking_recent[['Country_Region', 'SmokingRate']], on='Country_Region', how='left')
print(df_traintest4.shape)
df_traintest4.head() | No | 4 | 32 | Data_Transform | merge | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,578 | len(df) | No | 5 | 58 | Debug | show_shape | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,579 | y_fatal=dt2.predict(test_data) | No | 5 | 48 | Model_Evaluation | predict_on_test | 8,679,319 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing Checker", "fix": "Write unit tests for data processing and model components.", "benefits": "Ensures code reliability and prevents bugs.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Excepti... | A | no applicable ML-specific findings | [] | ["Exception Handling Checker", "Unit Testing Checker"] | 7 | A |
1,580 | # fill na with world smoking rate
SmokingRate = df_smoking_recent['SmokingRate'][df_smoking_recent['Entity']=='World'].values[0]
print("Smoking rate of the world: {:.6f}".format(SmokingRate))
df_traintest4['SmokingRate'][pd.isna(df_traintest4['SmokingRate'])] = SmokingRate
df_traintest4.head()' | No | 4 | 17 | Data_Transform | correct_missing_values | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,581 | submission=pd.DataFrame({'ForecastId': test_df["ForecastId"], 'ConfirmedCases': y_confirmed, 'Fatalities': y_fatal})' | No | 5 | 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 |
1,582 | # add data from World Economic Outlook Database
# https://www.imf.org/external/pubs/ft/weo/2017/01/weodata/index.aspx
df_weo = pd.read_csv("../input/smokingstats/WEO.csv")
df_weo.head() | No | 4 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,583 | print(df_weo['Subject Descriptor'].unique()) | No | 5 | 57 | Debug | show_unique_values | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,584 | submission["ConfirmedCases"]=submission["ConfirmedCases"].astype(int)
submission["Fatalities"]=submission["Fatalities"].astype(int) | No | 5 | 16 | Data_Transform | data_type_conversions | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,585 | submission.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,586 | train = train.loc[:,~train.columns.duplicated()]
test = test.loc[:,~test.columns.duplicated()] | No | 5 | 19 | Data_Transform | remove_duplicates | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,587 | y = train.Fatalities
x = train.drop(["Fatalities", "ConfirmedCases"], axis = 1) | No | 5 | 21 | Data_Transform | prepare_x_and_y | 8,658,083 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}] | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | [] | 3 | B |
1,588 | !wget https://github.com/google-research-datasets/gap-coreference/raw/master/gap-development.tsv -q
!wget https://github.com/google-research-datasets/gap-coreference/raw/master/gap-test.tsv -q
!wget https://github.com/google-research-datasets/gap-coreference/raw/master/gap-validation.tsv -q | No | 5 | 42 | Data_Extraction | load_from_url | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,589 | data_path = Path(".") | No | 5 | 77 | Other | define_variables | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,590 | train = pd.read_csv(data_path/"gap-development.tsv", sep="\\t")
val = pd.read_csv(data_path/"gap-validation.tsv", sep="\\t")
test = pd.read_csv(data_path/"gap-test.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,591 | print(len(train), len(val), len(test)) | No | 5 | 58 | Debug | show_shape | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,592 | from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn import linear_model
from sklearn.model_selection import train_test_split
from sklearn import metrics
from sklearn import preprocessing
from sklearn.ensemble import RandomForestRegressor
import xgboost as xgb
from catboost import CatBoostRegressor
... | No | 5 | 23 | Environment | set_options | 8,658,083 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 3 | null |
1,593 | # This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load in
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O... | No | 5 | 88 | Debug | list_files | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 12"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 0 | A |
1,594 | from sklearn.model_selection import train_test_split
def linear_models(X_model, y_model, model_name):
X_train, X_test, y_train, y_test = train_test_split(X_model, y_model, random_state = 42)
if model_name == "ridge":
model = linear_model.Ridge(alpha = 0.1, random_state = 42).fit(X_train, y_train)
... | No | 3 | 4 | Model_Train | choose_model_class | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
1,595 | train["is_valid"] = True
test["is_valid"] = False
val["is_valid"] = True
df_pretrain = pd.concat([train, test, val]) | No | 5 | 11 | Data_Transform | concatenate | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,596 | db = (TextList.from_df(df_pretrain, data_path/"db", cols="Text").split_from_df(col="is_valid").label_for_lm().databunch()) | No | 5 | 53 | Other | something_strange | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,597 | vocab = db.vocab | No | 5 | 77 | Other | define_variables | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,598 | lm = language_model_learner(db, AWD_LSTM, drop_mult=0.5, pretrained=True) | 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,599 | lm.unfreeze() | No | 5 | 53 | Other | something_strange | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,600 | lm.lr_find() | No | 5 | 53 | Other | something_strange | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,601 | lm.recorder.plot() | No | 5 | 53 | Other | something_strange | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,602 | import modeling
import extract_features
import tokenization
import tensorflow as tf | No | 5 | 22 | Environment | import_modules | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 0 | A |
1,603 | lm.fit_one_cycle(3, 1e-3) | No | 5 | 7 | Model_Train | train_model | 3,065,122 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 5 | 5 | [{"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", "Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 1 | B |
1,604 | from keras import backend as K
from keras import initializers, regularizers, constraints, optimizers, layers
from keras.engine.topology import Layer | No | 5 | 22 | Environment | import_modules | 3,308,267 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
1,605 | #downloading weights and cofiguration file for the model
!wget https://storage.googleapis.com/bert_models/2018_10_18/uncased_L-12_H-768_A-12.zip
with zipfile.ZipFile("uncased_L-12_H-768_A-12.zip","r") as zip_ref:
zip_ref.extractall()
!ls 'uncased_L-12_H-768_A-12'' | No | 5 | 30 | Model_Train | load_pretrained | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,606 | #!wget https://raw.githubusercontent.com/google-research/bert/master/modeling.py
!wget https://raw.githubusercontent.com/isikkuntay/AIND/master/modeling.py
!wget https://raw.githubusercontent.com/isikkuntay/AIND/master/run_classifier.py
!wget https://raw.githubusercontent.com/google-research/bert/master/extract_featur... | No | 5 | 42 | Data_Extraction | load_from_url | 3,308,267 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 5 | null |
1,607 | !wget https://raw.githubusercontent.com/google-research-datasets/gap-coreference/master/gap-development.tsv
!wget https://raw.githubusercontent.com/google-research-datasets/gap-coreference/master/gap-validation.tsv
!wget https://raw.githubusercontent.com/google-research-datasets/gap-coreference/master/gap-test.tsv
!ls | No | 5 | 42 | Data_Extraction | load_from_url | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,608 | def compute_offset_no_spaces(text, offset):
\tcount = 0
\tfor pos in range(offset):
\t\tif text[pos] != " ": count +=1
\treturn count
def count_chars_no_special(text):
\tcount = 0
\tspecial_char_list = ["#"]
\tfor pos in range(len(text)):
\t\tif text[pos] not in special_char_list: count +=1
\treturn count
def count_l... | 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,609 | #Copying Simple NLP notebook over here:
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... | No | 2 | 1 | Hyperparam_Tuning | find_best_score | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
1,610 | def run_bert(data):
\t'''
\tRuns a forward propagation of BERT on input text, extracting contextual word embeddings
\tInput: data, a pandas DataFrame containing the information in one of the GAP files
\tOutput: emb, a pandas DataFrame containing contextual embeddings for the words A, B and Pronoun. Each embedding is a... | No | 4 | 1 | Hyperparam_Tuning | find_best_score | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
1,611 | from keras import backend, models, layers, initializers, regularizers, constraints, optimizers
from keras import callbacks as kc
from keras import optimizers as ko
from sklearn.model_selection import cross_val_score, KFold, train_test_split
from sklearn.metrics import log_loss
import time
dense_layer_sizes = [37]
dr... | No | 5 | 59 | Model_Train | init_hyperparams | null | 1 | A | 1 | 0 | 0 | 0 | 5 | 14 | ok | 3 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Magic number detected: 0.6", "fix": "Not specified", "benefits": "Not specified", "location": "Line 11"}, {"detector": "general_ml", "framework": "General ML", "name": "Magic number detected: 5", "fix": "Not specified", "benefits": "Not specified", "locati... | A | no applicable ML-specific findings | [] | ["Magic number"] | 0 | A |
1,612 | class IsLayer(Layer):
#Layer to be used after a dense one. It will multiply all the elements with each other.
#In a sense, it allows the neurons to have a say on each others' outputs. This layer, hopefully,
#compares the relative importance of neurons.The compound prob is regulated with weights.
#The i... | No | 5 | 53 | Other | something_strange | 3,308,267 | 1 | A | 1 | 4 | 0 | 0 | 2 | 15 | 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": "general_ml", "framework": "General ML", "name": "Missing docstring for... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Missing class docstring", "Missing function docstring"] | 5 | A |
1,613 | def build_mlp_model(input_shape, num_output):
\tX_input = layers.Input(input_shape)
\t# First dense layer
\tX = layers.Dense(dense_layer_sizes[0], name = 'dense0')(X_input)
\tX = layers.BatchNormalization(name = 'bn0')(X)
\tX = layers.Activation('relu')(X)
\tX = layers.Dropout(dropout_rate, seed = 7)(X)
#\tX = IsLayer... | No | 5 | 4 | Model_Train | choose_model_class | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,614 | def parse_json(embeddings):
\t'''
\tParses the embeddigns given by BERT, and suitably formats them to be passed to the MLP model
\tInput: embeddings, a DataFrame containing contextual embeddings from BERT, as well as the labels for the classification problem
\tcolumns: "emb_A": contextual embedding for the word A
\t ... | No | 5 | 53 | Other | something_strange | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
1,615 | # Read development embeddigns from json file - this is the output of Bert
development = pd.read_json("contextual_embeddings_gap_development.json")
X_development, Y_development = parse_json(development)
validation = pd.read_json("contextual_embeddings_gap_validation.json")
X_validation, Y_validation = parse_json(valida... | No | 3 | 1 | Hyperparam_Tuning | find_best_score | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,616 | # There may be a few NaN values, where the offset of a target word is greater than the max_seq_length of BERT.
# They are very few, so I'm just dropping the rows.
remove_test = [row for row in range(len(X_test)) if np.sum(np.isnan(X_test[row]))]
X_train = np.delete(X_test, remove_test, 0)
Y_train = np.delete(Y_test, re... | No | 5 | 17 | Data_Transform | correct_missing_values | 3,308,267 | 1 | A | 0 | 3 | 0 | 0 | 0 | 7 | ok | 6 | 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 14"}, {"detector": "framework_specific", "framework": "NumPy", "name": "Array Creat... | C | Missing Axis Specification=medium | [{"type": "Missing Axis Specification", "severity": "medium"}] | ["Array Creation Efficiency", "Column Selection Checker"] | 5 | C |
1,617 | # Will train on data from the gap-test and gap-validation files, in total 2454 rows
#X_train = np.concatenate((X_test, X_validation), axis = 0)
#Y_train = np.concatenate((Y_test, Y_validation), axis = 0)
# Will predict probabilities for data from the gap-development file; initializing the predictions
#prediction = np.... | No | 5 | 77 | Other | define_variables | 3,308,267 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | 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 13"}] | A | no applicable ML-specific findings | [] | ["Array Creation Efficiency"] | 5 | A |
1,618 | # Training and cross-validation
folds = KFold(n_splits=n_fold, shuffle=True, random_state=3)
scores = []
for fold_n, (train_index, valid_index) in enumerate(folds.split(X_train)):
\t# split training and validation data
\tprint('Fold', fold_n, 'started at', time.ctime())
\tX_tr, X_val = X_train[train_index], X_train[val... | No | 3 | 1 | Hyperparam_Tuning | find_best_score | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,619 | def build_neither_mlp(input_shape, num_output):
\tX_input = layers.Input(input_shape)
\t# First dense layer
\tX = layers.Dense(dense_layer_sizes[0], name = 'dense0')(X_input)
\tX = layers.BatchNormalization(name = 'bn0')(X)
\tX = layers.Activation('relu')(X)
\tX = layers.Dropout(dropout_rate, seed = 7)(X)
# Outpu... | No | 5 | 4 | Model_Train | choose_model_class | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,620 | X_val_A = val_prediction[: int(len(val_prediction)/2)]
X_val_B = val_prediction[int(len(val_prediction)/2) :]
X_train_neither = np.concatenate((X_val_A, X_val_B), axis=1)
Y_val_A = Y_validation[: int(len(Y_validation)/2)]
Y_val_B = Y_validation[int(len(Y_validation)/2) :]
Y_train_neither = 1 - Y_val_A - Y_val_B | No | 5 | 21 | Data_Transform | prepare_x_and_y | 3,308,267 | 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"] | 5 | A |
1,621 | print(X_val_A.shape)
print(X_val_B.shape)
print(X_train_neither.shape)
print(Y_val_A.shape)
print(Y_val_B.shape)
print(Y_train_neither.shape) | No | 5 | 58 | Debug | show_shape | 3,308,267 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
1,622 | neither_model = build_neither_mlp([X_train_neither.shape[1]],1)
neither_model.compile(optimizer = optimizers.Adam(lr = learning_rate), loss = "binary_crossentropy")
neither_model.fit(X_train_neither, y = Y_train_neither, epochs = epochs, batch_size = batch_size, validation_data = (X_train_neither, Y_train_neither), ver... | No | 3 | 7 | Model_Train | train_model | 3,308,267 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 9 | 8 | [{"detector": "framework_specific", "framework": "TensorFlow", "name": "Memory Release Checker", "fix": "Clear session after model creation/training using tf.keras.backend.clear_session().", "benefits": "Prevents memory leaks and reduces resource usage.", "location": ""}, {"detector": "framework_specific", "framework":... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Exception Handling Checker", "Logging Checker", "Memory Release Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker"] | 5 | B |
1,623 | X_dev_A = dev_prediction[: int(len(dev_prediction)/2)]
X_dev_B = dev_prediction[int(len(dev_prediction)/2) :]
X_dev_neither = np.concatenate((X_dev_A, X_dev_B), axis=1) | No | 5 | 13 | Data_Transform | split | 3,308,267 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 5 | A |
1,624 | dev_neither = neither_model.predict(x = X_dev_neither, verbose = 0) | No | 5 | 27 | Model_Train | predict_on_train | 3,308,267 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "TensorFlow", "name": "Memory Release Checker", "fix": "Clear session after model creation/training using tf.keras.backend.clear_session().", "benefits": "Prevents memory leaks and reduces resource usage.", "location": ""}, {"detector": "framework_specific", "framework":... | A | no applicable ML-specific findings | [] | ["Exception Handling Checker", "Memory Release Checker", "Unit Testing Checker"] | 5 | A |
1,625 | # Write the prediction to file for submission
submission = pd.read_csv("../input/sample_submission_stage_1.csv", index_col = "ID")
submission["A"] = X_dev_A
submission["B"] = X_dev_B
submission["NEITHER"] = dev_neither
submission.to_csv("submission_bert.csv") | No | 4 | 25 | Data_Export | save_to_csv | 3,308,267 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path d... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Hardcoded file path"] | 5 | A |
1,626 | import pandas as pd
import numpy as np
import keras
import spacy
from collections import defaultdict
from sklearn.metrics import log_loss
import matplotlib.pyplot as plt
%matplotlib inline
import time
import os
print(os.listdir("../input"))
# Any results you write to the current directory are saved as output. | No | 5 | 88 | Debug | list_files | 3,338,077 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
1,627 | nlp = spacy.load('en_core_web_lg') | 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,628 | spacy_tok = SpacyTokenizer("en")
tokenizer = Tokenizer(spacy_tok) | No | 5 | 84 | Other | not_enough_vertices | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,629 | df_pretrain.Text.apply(lambda x: len(tokenizer.process_text(x, spacy_tok))).describe() | 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 |
1,630 | class Graph():
def __init__(self):
"""
self.edges is a dict of all possible next nodes
e.g. {'X': ['A', 'B', 'C', 'E'], ...}
self.weights has all the weights between two nodes,
with the two nodes as a tuple as the key
e.g. {('X', 'A'): 7, ('X', 'B'): 2, ...}
"... | 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,631 | def get_rank(token):
"""Step up with token.head until it reaches the root. Returns with step number and root"""
i = 0
next_token = token
while(next_token!=next_token.head):
i+=1
next_token=next_token.head
return i, next_token
def child_count(token):
cc = 0
for child in token... | No | 5 | 53 | Other | something_strange | 3,338,077 | 1 | A | 1 | 4 | 2 | 0 | 5 | 12 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,632 | def build_answers(data):
answers = []
for i in range(len(data)):
dataNext = data.loc[i]
Acoref = dataNext["A-coref"]
Bcoref = dataNext["B-coref"]
answerNext = [int(Acoref), int(Bcoref), 1-int(Acoref or Bcoref)]
answers.append(answerNext)
return np.vstack(answers) | No | 5 | 53 | Other | something_strange | 3,338,077 | 1 | A | 4 | 3 | 2 | 0 | 8 | 9 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,633 | def build_features(data):
"""Generates features from input data"""
features = []
sum_good = 0
for i in range(0,len(data)):
fi = []
dataNext = data.loc[i]
text = dataNext["Text"]
#print(visualise(dataNext))
doc=nlp(text)
Aoff = dataNext["A-offset"]
... | No | 5 | 53 | Other | something_strange | 3,338,077 | 2 | B | 28 | 14 | 33 | 0 | 101 | 63 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,634 | !pip install pytorch-pretrained-bert
!pip install https://github.com/ceshine/pytorch_helper_bot/archive/0.0.4.zip | No | 3 | 22 | Environment | import_modules | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
1,635 | import os
# This variable is used by helperbot to make the training deterministic
os.environ["SEED"] = "420"
import logging
from pathlib import Path
import torch
import torch.nn as nn
import numpy as np
import pandas as pd
from torch.utils.data import Dataset, DataLoader
from pytorch_pretrained_bert import BertToken... | No | 5 | 23 | Environment | set_options | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 12 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "PyTorch", "name": "Deterministic Algorithm Usage Checker", "fix": "Enable deterministic algorithms using torch.use_deterministic_algorithms(True).", "benefits": "Ensures consistent results across different hardware and runs.", "location": ""}] | B | Deterministic Algorithm Usage Checker=low | [{"type": "Deterministic Algorithm Usage Checker", "severity": "low"}] | [] | 0 | B |
1,636 | BERT_MODEL = 'bert-large-uncased'
CASED = False | No | 5 | 77 | Other | define_variables | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,637 | df_train = pd.read_csv("gap-test.tsv", delimiter="\\t")
df_val = pd.read_csv("gap-validation.tsv", delimiter="\\t")
df_test = pd.read_csv("gap-development.tsv", delimiter="\\t")
sample_sub = pd.read_csv("../input/sample_submission_stage_1.csv")
assert sample_sub.shape[0] == df_test.shape[0]' | 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,638 | tokenizer = BertTokenizer.from_pretrained(
BERT_MODEL,
do_lower_case=CASED,
never_split = ("[UNK]", "[SEP]", "[PAD]", "[CLS]", "[MASK]", "[A]", "[B]", "[P]")
)
# These tokens are not actually used, so we can assign arbitrary values.
tokenizer.vocab["[A]"] = -1
tokenizer.vocab["[B]"] = -1
tokenizer.vocab["[P... | No | 4 | 30 | Model_Train | load_pretrained | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 8 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
1,639 | sample = df.sample(random_state=100)
display_entry(sample.iloc[0]) | No | 4 | 41 | Debug | show_table | 3,127,294 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
1,640 | import os
# This variable is used by helperbot to make the training deterministic
os.environ["SEED"] = "323"
import logging
from pathlib import Path
import torch
import torch.nn as nn
import numpy as np
import pandas as pd
from tqdm import tqdm_notebook
from sklearn.metrics import log_loss
from sklearn.model_selecti... | No | 5 | 23 | Environment | set_options | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 18 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "PyTorch", "name": "Deterministic Algorithm Usage Checker", "fix": "Enable deterministic algorithms using torch.use_deterministic_algorithms(True).", "benefits": "Ensures consistent results across different hardware and runs.", "location": ""}] | B | Deterministic Algorithm Usage Checker=low | [{"type": "Deterministic Algorithm Usage Checker", "severity": "low"}] | [] | 0 | B |
1,641 | result = pd.DataFrame({'ID': df.index, 'A': 1, 'B': 1, 'NEITHER': 1})
result.to_csv('dummy_all_equal.csv', index=False) | No | 4 | 25 | Data_Export | save_to_csv | 3,127,294 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
1,642 | result['A'] = 1
result['B'] = 0
result['NEITHER'] = 0
result.to_csv('dummy_A.csv', index=False) | No | 4 | 25 | Data_Export | save_to_csv | 3,127,294 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | 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 |
1,643 | result['A'] = 0
result['B'] = 1
result['NEITHER'] = 0
result.to_csv('dummy_B.csv', index=False) | No | 5 | 25 | Data_Export | save_to_csv | 3,127,294 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | 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 |
1,644 | result['A'] = 0
result['B'] = 0
result['NEITHER'] = 1
result.to_csv('dummy_NEITHER.csv', index=False) | No | 5 | 25 | Data_Export | save_to_csv | 3,127,294 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | 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 |
1,645 | # https://scikit-learn.org/stable/modules/generated/sklearn.metrics.log_loss.html
from sklearn.metrics import log_loss
y_true = ["spam", "ham", "ham", "spam"]
# The labels in y_pred are assumed to be ordered alphabetically, as done by preprocessing.LabelBinarizer
# ["ham", "spam"]
y_pred = [
[.1, .9],
[.9, .1... | No | 4 | 49 | Model_Evaluation | compute_test_metric | 3,127,294 | 1 | A | 0 | 0 | 0 | 0 | 0 | 9 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
1,646 | # This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load in
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O... | No | 4 | 22 | Environment | import_modules | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 17 | ok | 4 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 13"}, {"detector": "general_ml", "framework": "General ML", "name": "Hardcoded fil... | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 0 | A |
1,647 | final_test.shape | No | 5 | 58 | Debug | show_shape | 3,544,896 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.