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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
5,582 | test['Phrase'][0] | 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 |
5,583 | train['Sentiment'].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 |
5,584 | !pip install pytorch-pretrained-bert pytorch-nlp | No | 5 | 87 | Environment | install_modules | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
5,585 | import torch
from torch.utils.data import TensorDataset, DataLoader, RandomSampler, SequentialSampler
from keras.preprocessing.sequence import pad_sequences
from sklearn.model_selection import train_test_split
from pytorch_pretrained_bert import BertTokenizer, BertConfig
from pytorch_pretrained_bert import BertAdam, Be... | No | 5 | 22 | Environment | import_modules | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
5,586 | device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
n_gpu = torch.cuda.device_count()
torch.cuda.get_device_name(0) | No | 5 | 23 | Environment | set_options | null | 1 | A | 0 | 1 | 1 | 0 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,587 | train['Sentiment'] = train.Sentiment.astype(int)
test['Sentiment'] = test.Sentiment.astype(int) | No | 5 | 16 | Data_Transform | data_type_conversions | 5,860,807 | 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"] | 3 | A |
5,588 | # Create sentence and label lists
sentences = train.Phrase.values
# We need to add special tokens at the beginning and end of each sentence for BERT to work properly
sentences = ["[CLS] " + sentence + " [SEP]" for sentence in sentences]
labels = train.Sentiment.values | No | 5 | 77 | Other | define_variables | 5,860,807 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
5,589 | np.unique(labels) | 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 |
5,590 | tokenizer = BertTokenizer.from_pretrained('bert-base-uncased', do_lower_case=True)
tokenized_texts = [tokenizer.tokenize(sent) for sent in sentences]
print ("Tokenize the first sentence:")
print (tokenized_texts[0])' | No | 4 | 78 | Data_Transform | string_transform | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,591 | import seaborn as sns | No | 5 | 22 | Environment | import_modules | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,592 | sns.distplot(train.Phrase.apply(lambda x: len(x.split()))) | No | 5 | 33 | Visualization | distribution | 5,860,807 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
5,593 | # Set the maximum sequence length. The longest sequence in our training set is 47, but we'll leave room on the end anyway.
# In the original paper, the authors used a length of 512.
MAX_LEN = 32 | No | 5 | 77 | Other | define_variables | 5,860,807 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Magic number detected: 32", "fix": "Not specified", "benefits": "Not specified", "location": "Line 6"}] | A | no applicable ML-specific findings | [] | ["Magic number"] | 3 | A |
5,594 | # Pad our input tokens
input_ids = pad_sequences([tokenizer.convert_tokens_to_ids(txt) for txt in tokenized_texts],
maxlen=MAX_LEN, dtype="long", truncating="post", padding="post") | No | 5 | 78 | Data_Transform | string_transform | 5,860,807 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
5,595 | # Use the BERT tokenizer to convert the tokens to their index numbers in the BERT vocabulary
input_ids = [tokenizer.convert_tokens_to_ids(x) for x in tokenized_texts] | No | 5 | 78 | Data_Transform | string_transform | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,596 | input_ids = pad_sequences(input_ids, maxlen=MAX_LEN, dtype="long", truncating="post", padding="post") | No | 5 | 78 | Data_Transform | string_transform | 5,860,807 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
5,597 | # Create attention masks
attention_masks = []
# Create a mask of 1s for each token followed by 0s for padding
for seq in input_ids:
seq_mask = [float(i>0) for i in seq]
attention_masks.append(seq_mask) | No | 5 | 53 | Other | something_strange | null | 1 | A | 0 | 1 | 1 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,598 | # Use train_test_split to split our data into train and validation sets for training
train_inputs, validation_inputs, train_labels, validation_labels = train_test_split(input_ids, labels,
random_state=2018, test_size=0.1)
train_masks, validation_masks, _, _ ... | No | 5 | 13 | Data_Transform | split | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,599 | train_labels | No | 5 | 41 | Debug | show_table | null | 1 | A | 0 | 0 | 0 | 1 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,600 | # Convert all of our data into torch tensors, the required datatype for our model
train_inputs = torch.tensor(train_inputs)
validation_inputs = torch.tensor(validation_inputs)
train_labels = torch.tensor(train_labels)
validation_labels = torch.tensor(validation_labels)
train_masks = torch.tensor(train_masks)
validatio... | No | 5 | 16 | Data_Transform | data_type_conversions | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,601 | # Select a batch size for training. For fine-tuning BERT on a specific task, the authors recommend a batch size of 16 or 32
batch_size = 32
# Create an iterator of our data with torch DataLoader. This helps save on memory during training because, unlike a for loop,
# with an iterator the entire dataset does not need ... | No | 4 | 13 | Data_Transform | split | 5,860,807 | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "TensorFlow", "name": "Model Evaluation Checker", "fix": "Evaluate model performance using model.evaluate().", "benefits": "Provides standardized model evaluation.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Model Evaluation Checker"] | 3 | A |
5,602 | # Load BertForSequenceClassification, the pretrained BERT model with a single linear classification layer on top.
model = BertForSequenceClassification.from_pretrained("bert-base-uncased", num_labels=5)
model.cuda() | No | 5 | 30 | Model_Train | load_pretrained | 5,860,807 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
5,603 | param_optimizer = list(model.named_parameters())
no_decay = ['bias', 'gamma', 'beta']
optimizer_grouped_parameters = [
{'params': [p for n, p in param_optimizer if not any(nd in n for nd in no_decay)],
'weight_decay_rate': 0.01},
{'params': [p for n, p in param_optimizer if any(nd in n for nd in no_decay)]... | No | 5 | 59 | Model_Train | init_hyperparams | 5,860,807 | 1 | A | 0 | 2 | 0 | 0 | 0 | 8 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
5,604 | # This variable contains all of the hyperparemeter information our training loop needs
optimizer = BertAdam(optimizer_grouped_parameters,
lr=2e-5,
warmup=.1) | No | 3 | 59 | Model_Train | init_hyperparams | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,605 | # Function to calculate the accuracy of our predictions vs labels
def flat_accuracy(preds, labels):
pred_flat = np.argmax(preds, axis=1).flatten()
labels_flat = labels.flatten()
return np.sum(pred_flat == labels_flat) / len(labels_flat) | No | 5 | 84 | Other | not_enough_vertices | null | 1 | A | 0 | 1 | 0 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,606 | train_loss_set = []
# Number of training epochs (authors recommend between 2 and 4)
epochs = 4
# trange is a tqdm wrapper around the normal python range
for _ in trange(epochs, desc="Epoch"):
# Training
# Set our model to training mode (as opposed to evaluation mode)
model.train()
# Tracking varia... | No | 4 | 7 | Model_Train | train_model | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
5,607 | plt.figure(figsize=(15,8))
plt.title("Training loss")
plt.xlabel("Batch")
plt.ylabel("Loss")
plt.plot(train_loss_set)
plt.show() | No | 5 | 35 | Visualization | learning_history | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,608 | test = pd.read_csv("../input/test.tsv", sep='\\t')
test_id = test['PhraseId']' | 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 |
5,609 | # Create sentence and label lists
sentences = test.Phrase.values
# We need to add special tokens at the beginning and end of each sentence for BERT to work properly
sentences = ["[CLS] " + sentence + " [SEP]" for sentence in sentences]
# labels = test.Sentiment.values
tokenized_texts = [tokenizer.tokenize(sent) for s... | No | 5 | 78 | Data_Transform | string_transform | 5,860,807 | 2 | B | 1 | 0 | 0 | 0 | 5 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | B |
5,610 | MAX_LEN = 32
# Pad our input tokens
input_ids = pad_sequences([tokenizer.convert_tokens_to_ids(txt) for txt in tokenized_texts],
maxlen=MAX_LEN, dtype="long", truncating="post", padding="post")
# Use the BERT tokenizer to convert the tokens to their index numbers in the BERT vocabulary
input_i... | Yes | 5 | 78 | Data_Transform | string_transform | 5,860,807 | 1 | A | 0 | 1 | 1 | 0 | 0 | 9 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Magic number detected: 32", "fix": "Not specified", "benefits": "Not specified", "location": "Line 4"}] | A | no applicable ML-specific findings | [] | ["Magic number"] | 3 | A |
5,611 | prediction_inputs = torch.tensor(input_ids)
prediction_masks = torch.tensor(attention_masks)
prediction_labels = torch.tensor(labels)
batch_size = 32 | Yes | 5 | 16 | Data_Transform | data_type_conversions | 5,860,807 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
5,612 | prediction_data = TensorDataset(prediction_inputs, prediction_masks, prediction_labels)
prediction_sampler = SequentialSampler(prediction_data)
prediction_dataloader = DataLoader(prediction_data, sampler=prediction_sampler, batch_size=batch_size) | No | 4 | 13 | Data_Transform | split | 5,860,807 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
5,613 | # Prediction on test set
# Put model in evaluation mode
model.eval()
# Tracking variables
predictions , true_labels = [], []
# Predict
for batch in prediction_dataloader:
# Add batch to GPU
batch = tuple(t.to(device) for t in batch)
# Unpack the inputs from our dataloader
b_input_ids, b_input_mask, b_label... | No | 5 | 48 | Model_Evaluation | predict_on_test | 5,860,807 | 1 | A | 0 | 1 | 1 | 0 | 0 | 10 | ok | 1 | 1 | [{"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": ""}] | A | no applicable ML-specific findings | [] | ["Memory Release Checker"] | 3 | A |
5,614 | preds = np.concatenate(predictions) | No | 5 | 11 | Data_Transform | concatenate | 5,860,807 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
5,615 | # preds, target = learn_classifier.get_preds(DatasetType.Test, ordered=True)
labels = np.argmax(preds, axis =1)
| No | 2 | 8 | Data_Transform | feature_engineering | 5,860,807 | 3 | C | 1 | 0 | 0 | 0 | 5 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | C |
5,616 | submission = pd.DataFrame({'PhraseId': test_id, 'Sentiment': labels})
submission.to_csv('submission.csv', index=False)
submission.head() | Yes | 5 | 25 | Data_Export | save_to_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,617 | def mlen(row):
s=row['lemma'].split(' ')
return len(s)
train_df['len']=train_df.apply(mlen,axis=1)
train_df.head() | No | 5 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 1 | 0 | 0 | 0 | 5 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,618 | max(train_df['len']) | No | 5 | 40 | Debug | show_table_attributes | null | 1 | A | 0 | 0 | 0 | 1 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,619 | test_df['len']=test_df.apply(mlen,axis=1)
max(test_df['len']) | No | 5 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 0 | 0 | 1 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,620 | from sklearn.preprocessing import OneHotEncoder
ohe=OneHotEncoder()
Y_train=train_df.iloc[:,3]
Y_train=Y_train.as_matrix()
Y_train=Y_train.reshape(-1,1)
Y_tr=ohe.fit_transform(Y_train) | No | 5 | 20 | Data_Transform | categorify | 3,995,628 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 7 | 7 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Pipeline Checker", "fix": "Use Pipelines for all scikit-learn estimators.", "benefits": "Prevents data leakage and ensures correct model evaluation.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross V... | D | Cross Validation Checker=low, Data Leakage Checker=high, No random seed setting detected=low, Pipeline Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Pipeline Checker", "severity": "low"}] | ["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 3 | D |
5,621 | from keras.models import Sequential
from keras.layers import Dense,Dropout,Embedding,LSTM | No | 5 | 22 | Environment | import_modules | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,622 | model.summary() | No | 5 | 79 | Visualization | model_coefficients | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,623 | model.fit(X_train,Y_tr,batch_size=64,epochs=15) | No | 5 | 7 | Model_Train | train_model | 3,995,628 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 4 | 4 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 3 | B |
5,624 | s=model.predict(X_test)
s=np.argmax(s,axis=1)
print(s)
s=pd.DataFrame(s)
s['PhraseId']=test_df['PhraseId']
s.columns=['Sentiment','PhraseId']
s=s[['PhraseId','Sentiment']]
s.to_csv('submissions.csv',index=False) | No | 4 | 25 | Data_Export | save_to_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 8 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,625 | # 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 | 7,497,960 | 1 | A | 0 | 2 | 3 | 0 | 0 | 6 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: /kaggle/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"] | 3 | A |
5,626 | try:
%tensorflow_version 2.x
except Exception:
pass
import tensorflow as tf
# The Natural Language Toolkit, or more commonly NLTK, is a suite of libraries and programs for symbolic and
# statistical natural language processing for English written in the Python programming language.
import nltk
from nltk.tokenize... | No | 5 | 84 | Other | not_enough_vertices | 7,497,960 | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 3 | null |
5,627 | from keras.utils import to_categorical
import random
from sklearn.model_selection import train_test_split
from keras.preprocessing import sequence
from keras.preprocessing.text import Tokenizer
from keras.layers import Dense,Dropout,Embedding,LSTM
from keras.callbacks import EarlyStopping
from keras.losses import categ... | No | 5 | 23 | Environment | set_options | 7,497,960 | 1 | A | 0 | 0 | 0 | 0 | 0 | 12 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
5,628 | from zipfile import ZipFile
for zip_path in ['../input/sentiment-analysis-on-movie-reviews/train.tsv.zip',
'../input/sentiment-analysis-on-movie-reviews/test.tsv.zip']:
with ZipFile(zip_path, 'r') as zip:
# printing all the contents of the zip file
zip.printdir()
# ext... | No | 5 | 73 | Data_Extraction | load_from_zip | 7,497,960 | 1 | A | 0 | 1 | 1 | 0 | 0 | 8 | ok | 2 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/sentiment-analysis-on-movie-reviews/train.tsv.zip. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 6"}, {"detector": "general_ml", ... | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 3 | A |
5,629 | sample = pd.read_csv("../input/sentiment-analysis-on-movie-reviews/sampleSubmission.csv")
train = pd.read_csv("train.tsv", delimiter='\\t')
test = pd.read_csv("test.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 |
5,630 | train.shape, test.shape | No | 5 | 58 | Debug | show_shape | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,632 |
def clean_sentences(df):
reviews = []
for sent in tqdm(df['Phrase']):
#remove html content
review_text = BeautifulSoup(sent).get_text()
#remove non-alphabetic characters
review_text = re.sub("[^a-zA-Z]"," ", review_text)
#tokenize the sentences
... | No | 5 | 78 | Data_Transform | string_transform | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,633 | target=train.Sentiment.values
y_target=to_categorical(target)
num_classes=y_target.shape[1] | No | 5 | 20 | Data_Transform | categorify | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,634 | X_train,X_val,y_train,y_val = train_test_split(train_sentences,
y_target,
test_size=0.2,
stratify=y_target) | No | 5 | 13 | Data_Transform | split | 7,497,960 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Randomness Control Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Randomness Control Checker", "severity": "low"}] | [] | 3 | B |
5,635 | unique_words = set()
len_max = 0
for sent in tqdm(X_train):
unique_words.update(sent)
if(len_max<len(sent)):
len_max = len(sent)
#length of the list of unique_words gives the no of unique words
print(len(list(unique_words)))
print(len_max) | No | 5 | 54 | EDA | count_unique_values | 7,497,960 | 1 | A | 0 | 2 | 3 | 0 | 0 | 8 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
5,636 | history=model.fit(X_train, y_train, validation_data=(X_val, y_val),epochs=6, batch_size=256, verbose=1, callbacks=callback) | No | 5 | 7 | Model_Train | train_model | 7,497,960 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Exception Handling Checker", "Unit Testing Checker"] | 3 | B |
5,637 | import matplotlib.pyplot as plt
# Create count of the number of epochs
epoch_count = range(1, len(history.history['loss']) + 1)
# Visualize learning curve. Here learning curve is not ideal. It should be much smoother as it decreases.
#As mentioned before, altering different hyper parameters especially learning rate c... | No | 5 | 35 | Visualization | learning_history | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 8 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,638 | #make the predictions with trained model and submit the predictions.
y_pred=model.predict_classes(X_test) | No | 5 | 48 | Model_Evaluation | predict_on_test | 7,497,960 | 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"] | 3 | A |
5,639 | sample.Sentiment=y_pred
sample.to_csv('Submission.csv',index=False) | No | 5 | 25 | Data_Export | save_to_csv | 7,497,960 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
5,640 | !pip install -U sentence-transformers | No | 5 | 87 | Environment | install_modules | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
5,641 | from sentence_transformers import SentenceTransformer
#there are about 10 pretrained models
#roberta-large-nli-stsb-mean-tokens - returns 1024 dimentional vector
#distilbert-base-nli-stsb-mean-tokens - returns 768 dimentional vector
PRETRAINED_MODEL='roberta-large-nli-stsb-mean-tokens' # 'distilbert-base-nli-stsb-... | No | 5 | 30 | Model_Train | load_pretrained | 8,364,491 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
5,642 | import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
from pathlib import Path
from sklearn import preprocessing
import os
from timeit import default_timer
import tensorflow as tf
import tensorflow.keras as keras
import regex as re
import lightgbm as lgbm | No | 5 | 22 | Environment | import_modules | 8,364,491 | 1 | A | 0 | 0 | 0 | 0 | 0 | 10 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
5,643 | DATA_ROOT = Path("..") / "/kaggle/input/sentiment-analysis-on-movie-reviews"
train = pd.read_csv(DATA_ROOT / 'train.tsv.zip', sep="\\t")
test = pd.read_csv(DATA_ROOT / 'test.tsv.zip', sep="\\t")
print(train.shape,test.shape)
train.head()' | 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 |
5,644 | b"\n#add two simple features - number of chars and words\ndef add_features (df):\n df['nwords'] = df.Phrase.apply(lambda text: len(re.findall(r'\\w+', text)))\n df['nchars'] = df.Phrase.apply(lambda text: len(text))" | No | 5 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,645 | X_train = np.array(train_embedd)
X_test = np.array(test_embedd)
X_train = np.concatenate((X_train, train[['nchars','nwords']].values), axis=1)
X_test = np.concatenate((X_test, test[['nchars','nwords']].values), axis=1)
X_train.shape, X_test.shape | No | 4 | 11 | Data_Transform | concatenate | 8,364,491 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 4 | 2 | [{"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 6"}, {"detector": "framework_specific", "framework": "NumPy", "name": "Array Creati... | A | no applicable ML-specific findings | [] | ["Array Creation Efficiency", "DataFrame Conversion Checker"] | 5 | A |
5,646 | #convert labels into 5-dimentional vector
enc = preprocessing.OneHotEncoder()
label = train['Sentiment'].values.reshape ((-1,1))
enc.fit(label)
y_train = enc.transform(label).toarray()
y_train.shape | No | 4 | 8 | Data_Transform | feature_engineering | 8,364,491 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 12 | 10 | [{"detector": "framework_specific", "framework": "Pandas", "name": "DataFrame Conversion Checker", "fix": "Use .to_numpy() instead of .values.", "benefits": "Ensures future compatibility and avoids unexpected behaviour.", "location": "Line 9"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column S... | D | Cross Validation Checker=low, Data Leakage Checker=high, No random seed setting detected=low, Pipeline Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Pipeline Checker", "severity": "low"}] | ["Column Selection Checker", "DataFrame Conversion Checker", "Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 5 | D |
5,647 | y_preds = model.predict(X_test)
y_preds.shape | No | 5 | 48 | Model_Evaluation | predict_on_test | 8,364,491 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 3 | 3 | [{"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", "Memory Release Checker", "Unit Testing Checker"] | 5 | A |
5,648 | sample_submission = pd.read_csv(DATA_ROOT / 'sampleSubmission.csv')
sample_submission['Sentiment'] = np.argmax(y_preds,axis=1)
sample_submission.to_csv("predictions.csv", index=False)' | No | 4 | 25 | Data_Export | save_to_csv | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,649 | sample_submission.tail() | 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 |
5,650 | import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
import tensorflow as tf
from tensorflow.keras.preprocessing.text import Tokenizer
from tensorflow.keras.preprocessing.sequence import pad_sequences
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers imp... | No | 5 | 22 | Environment | import_modules | 9,863,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 9 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 9 | A |
5,651 | b"df_train = pd.read_csv('/kaggle/input/sentiment-analysis-on-movie-reviews/train.tsv.zip', sep='\\t', usecols=['Phrase', 'Sentiment'])\ndf_submission = pd.read_csv('/kaggle/input/sentiment-analysis-on-movie-reviews/test.tsv.zip', sep='\\t', usecols=['Phrase'])" | No | 5 | 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 |
5,652 | X_train, X_test, y_train, y_test = train_test_split(df_train['Phrase'].values, df_train['Sentiment'].values, test_size=0.1) | No | 5 | 13 | Data_Transform | split | 9,863,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida... | B | Cross Validation Checker=low, Randomness Control Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Randomness Control Checker", "severity": "low"}] | ["Column Selection Checker"] | 9 | B |
5,653 | # initialize Tokenizer to encode strings into integers
tokenizer = Tokenizer()
# calculate number of rows in our dataset
num_rows = df_train.shape[0]
# create vocabulary from all words in our dataset for encoding
tokenizer.fit_on_texts(df_train['Phrase'].values)
# max length of 1 row (number of words)
row_max_length... | Yes | 4 | 8 | Data_Transform | feature_engineering | 9,863,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 11 | ok | 5 | 5 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Column Selection Checker", "Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 9 | B |
5,654 | y_train_cat = to_categorical(y_train)
y_test_cat = to_categorical(y_test)
target_length = y_train_cat.shape[1]
print('Original vector size: {}'.format(y_train.shape))
print('Converted vector size: {}'.format(y_train_cat.shape)) | No | 4 | 58 | Debug | show_shape | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,655 | EMBEDDING_DIM = 256
model = Sequential()
model.add(Embedding(vocabulary_size, EMBEDDING_DIM, input_length=row_max_length))
model.add(SpatialDropout1D(0.2))
model.add(Bidirectional(GRU(128)))
model.add(Dense(128, activation='relu'))
model.add(Dropout(0.2))
model.add(Dense(target_length, activation='softmax'))
model.com... | No | 4 | 7 | Model_Train | train_model | 9,863,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 11 | ok | 9 | 9 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Checkpointing Checker", "Exception Handling Checker", "Logging Checker", "Magic number", "Memory Release Checker", "Model Evaluation Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 9 | B |
5,656 | # predict test data
y_sub_hat_ = model.predict(X_sub_pad)
y_sub_hat = [np.argmax(x) for x in y_sub_hat_]
# save to csv
df_save = pd.read_csv('/kaggle/input/sentiment-analysis-on-movie-reviews/sampleSubmission.csv')
df_save['Sentiment'] = y_sub_hat
df_save.to_csv('Submission.csv', index = False)
print('Submission saved... | Yes | 4 | 48 | Model_Evaluation | predict_on_test | 9,863,967 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 7 | 7 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "NumPy", "name": "Missing Axis Speci... | C | Missing Axis Specification=medium | [{"type": "Missing Axis Specification", "severity": "medium"}] | ["Column Selection Checker", "Exception Handling Checker", "Hardcoded file path", "Memory Release Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker"] | 9 | C |
5,657 | from pathlib import Path
DATA_ROOT = Path("..") / "/kaggle/input/sentiment-analysis-on-movie-reviews"
train = pd.read_csv(DATA_ROOT / 'train.tsv.zip', sep="\\t")
test = pd.read_csv(DATA_ROOT / 'test.tsv.zip', sep="\\t")
print(train.shape,test.shape)
train.head()' | 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 |
5,658 | np.random.seed(2000)
w2 = np.random.randn(S+1,5,)
#w1 = np.zeros([S+1,5]) | No | 5 | 77 | Other | define_variables | 10,982,355 | 2 | B | 1 | 0 | 0 | 0 | 5 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | B |
5,659 | test_x_two[:5] | No | 5 | 41 | Debug | show_table | 10,982,355 | 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 |
5,660 | loss_list = [loss] | No | 5 | 77 | Other | define_variables | 10,982,355 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
5,661 | tmp = PhraseId
tmp.shape | No | 5 | 58 | Debug | show_shape | 10,982,355 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
5,662 | cls.shape | No | 5 | 58 | Debug | show_shape | 10,982,355 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
5,663 | cls | No | 5 | 53 | Other | something_strange | 10,982,355 | 1 | A | 0 | 0 | 0 | 1 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
5,664 | c = np.unique(b) | No | 5 | 57 | Debug | show_unique_values | 10,982,355 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
5,665 | len(c) | 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 |
5,666 | d=np.array(test_sentenceId) | No | 5 | 77 | Other | define_variables | 10,982,355 | 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 3"}] | A | no applicable ML-specific findings | [] | ["Array Creation Efficiency"] | 2 | A |
5,667 | e = np.unique(d) | No | 5 | 77 | Other | define_variables | 10,982,355 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
5,668 | len(e) | No | 5 | 53 | Other | something_strange | 10,982,355 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
5,669 | ans = np.array(ans) | No | 4 | 16 | Data_Transform | data_type_conversions | 10,982,355 | 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 3"}] | A | no applicable ML-specific findings | [] | ["Array Creation Efficiency"] | 2 | A |
5,670 | a = test['PhraseId'] | No | 5 | 77 | Other | define_variables | 10,982,355 | 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 |
5,671 | df = pd.DataFrame({'PhraseId':a,'Sentiment':ans}) | No | 5 | 12 | Data_Transform | create_dataframe | 10,982,355 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
5,672 | df.to_csv("submission.csv",index=False,sep=',')' | No | 5 | 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 |
5,673 | data = pd.read_csv("/kaggle/input/sentiment-analysis-on-movie-reviews/train.tsv.zip",sep='\\t')
data.head(10)' | 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 |
5,674 | data.shape | No | 5 | 58 | Debug | show_shape | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,675 | x_train = []
x_train = data['Phrase']
print(type(x_train))
x_train = np.asarray(x_train)
print(type(x_train))
x_train.shape | No | 4 | 21 | Data_Transform | prepare_x_and_y | 11,266,342 | 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"] | 2 | A |
5,676 | y_train=[]
y_train = data['Sentiment']
y_train = np.asarray(y_train)
print(type(y_train))
y_train.shape | No | 4 | 21 | Data_Transform | prepare_x_and_y | 11,266,342 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 2 | A |
5,677 | x_train = [rev.replace(",","").replace(".","").lower() for rev in x_train] | No | 5 | 78 | Data_Transform | string_transform | 11,266,342 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
5,678 | Y_train = np.zeros((y_train.size, y_train.max()+1))
Y_train[np.arange(y_train.size),y_train] = 1
Y_train | No | 5 | 53 | Other | something_strange | 11,266,342 | 1 | A | 0 | 0 | 0 | 1 | 0 | 3 | ok | 2 | 2 | [{"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 3"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Sele... | A | no applicable ML-specific findings | [] | ["Array Creation Efficiency", "Column Selection Checker"] | 2 | A |
5,679 | Y_train.shape | No | 5 | 58 | Debug | show_shape | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
5,680 | review_max_len = 200
vocab_size = 5000 | No | 5 | 77 | Other | define_variables | 11,266,342 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 2 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Magic number detected: 200", "fix": "Not specified", "benefits": "Not specified", "location": "Line 3"}, {"detector": "general_ml", "framework": "General ML", "name": "Magic number detected: 5000", "fix": "Not specified", "benefits": "Not specified", "loca... | A | no applicable ML-specific findings | [] | ["Magic number"] | 2 | A |
5,681 | from keras.preprocessing.text import one_hot
x_train_num = [one_hot(i,vocab_size) for i in x_train] | No | 5 | 20 | Data_Transform | categorify | 11,266,342 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 2 | A |
5,682 | X_train.shape | No | 5 | 58 | Debug | show_shape | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.