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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3,309 | y_predicted = clf.predict(x_train)
accuracy, precision, recall, f1 = get_metrics(y_train, y_predicted)
print("train accuracy = %.3f, precision = %.3f, recall = %.3f, f1 = %.3f" % (accuracy, precision, recall, f1)) | Yes | 2 | 27 | Model_Train | predict_on_train | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,310 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.preprocessing import OneHotEncoder
from sklearn.preprocessing import MinMaxScaler
from sklearn.pipeline import Pipeline
from sklearn.compose import ColumnTransformer
from sklearn.model_selection import train_test_split, cross_val_scor... | No | 5 | 22 | Environment | import_modules | 8,223,416 | 1 | A | 0 | 0 | 0 | 0 | 0 | 16 | 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"] | 11 | A |
3,311 | test = pd.read_csv("../input/forest-cover-type-prediction/test.csv")
train = pd.read_csv("../input/forest-cover-type-prediction/train.csv") | No | 5 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,312 | X_train_full = train.drop(['Id', 'Cover_Type'], axis=1)
y_train_full = train.Cover_Type - 1
X_test = test.drop('Id', axis=1)
test_id = test.Id
print(X_train_full.shape)
print(X_test.shape) | Yes | 3 | 10 | Data_Transform | drop_column | 8,223,416 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Dependent Threshold Checker"] | 11 | B |
3,313 | print(list(zip(range(0,56), X_train_full.columns))) | No | 5 | 71 | Debug | show_columns | 8,223,416 | 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"] | 11 | A |
3,314 | scaler = MinMaxScaler()
Xs_train_full = scaler.fit_transform(X_train_full)
Xs_test = scaler.transform(X_test) | Yes | 3 | 4 | Model_Train | choose_model_class | 8,223,416 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 10 | 9 | [{"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"}] | ["Dependent Threshold Checker", "Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 11 | D |
3,315 | Xs_train, Xs_valid, y_train, y_valid = train_test_split(Xs_train_full, y_train_full, test_size=0.2, random_state=1, stratify=y_train_full)
print(Xs_train.shape)
print(Xs_valid.shape) | Yes | 2 | 13 | Data_Transform | split | 8,223,416 | 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": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Dependent Threshold Checker"] | 11 | B |
3,316 | temp = LogisticRegression(max_iter=10000)
temp.fit(Xs_train, y_train)
temp.score(Xs_train, y_train) | Yes | 2 | 4 | Model_Train | choose_model_class | 8,223,416 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 7 | 7 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Scaler Missing Checker", "fix": "Apply scaling before scaling-sensitive operations.", "benefits": "Improves model performance and accuracy.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation... | C | Cross Validation Checker=low, Cross-validation not detected=low, Scaler Missing Checker=medium | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "Scaler Missing Checker", "severity": "medium"}] | ["Dependent Threshold Checker", "Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 11 | C |
3,317 | np.random.seed(1)
model = Sequential()
model.add(Dense(512, input_shape=(54,), activation='relu'))
model.add(Dense(512, activation='relu'))
model.add(Dense(512, activation='relu'))
model.add(Dense(7, activation='softmax'))
model.summary() | No | 5 | 84 | Other | not_enough_vertices | 8,223,416 | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | 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"] | 11 | A |
3,318 | opt = keras.optimizers.Adam(lr=0.001)
model.compile(loss='sparse_categorical_crossentropy', optimizer=opt, metrics=['accuracy'])
h1 = model.fit(Xs_train, y_train, batch_size=20000, epochs=500,
validation_data=(Xs_valid, y_valid), verbose=2) | Yes | 2 | 4 | Model_Train | choose_model_class | 8,223,416 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 4 | 4 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Dependent Threshold Checker", "Exception Handling Checker", "Unit Testing Checker"] | 11 | B |
3,319 | K.set_value(model.optimizer.lr, 0.0001)
h2 = model.fit(Xs_train, y_train, batch_size=20000, epochs=500,
validation_data=(Xs_valid, y_valid), verbose=2) | Yes | 4 | 7 | Model_Train | train_model | 8,223,416 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 4 | 4 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Dependent Threshold Checker", "Exception Handling Checker", "Unit Testing Checker"] | 11 | B |
3,320 | K.set_value(model.optimizer.lr, 0.00001)
h3 = model.fit(Xs_train, y_train, batch_size=20000, epochs=500,
validation_data=(Xs_valid, y_valid), verbose=2) | Yes | 4 | 7 | Model_Train | train_model | 8,223,416 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 4 | 4 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Dependent Threshold Checker", "Exception Handling Checker", "Unit Testing Checker"] | 11 | B |
3,321 | test_pred = model.predict_classes(Xs_test) | No | 5 | 48 | Model_Evaluation | predict_on_test | 8,223,416 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}, {"detector": "framework_specific", "framework":... | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker", "Exception Handling Checker", "Unit Testing Checker"] | 11 | A |
3,322 | !pip install seaborn | Yes | 5 | 87 | Environment | install_modules | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,323 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.preprocessing import OneHotEncoder, MinMaxScaler, StandardScaler
from sklearn.model_selection import train_test_split, cross_val_score, GridSearchCV
from sklearn.pipeline import Pipeline
from sklearn.linear_model import LogisticRegres... | No | 5 | 22 | Environment | import_modules | 8,895,321 | 1 | A | 0 | 0 | 0 | 0 | 0 | 10 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 8 | A |
3,324 | submission_sample = pd.read_csv('../input/forest-cover-type-prediction/sampleSubmission.csv')
train = pd.read_csv('../input/forest-cover-type-prediction/train.csv')
test = pd.read_csv('../input/forest-cover-type-prediction/test.csv') | No | 5 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,325 | train.sample(5) | 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 |
3,326 | test.sample(5) | 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 |
3,327 | print(list(enumerate(train.columns))) | No | 5 | 71 | Debug | show_columns | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,328 | train.nunique() | No | 5 | 54 | EDA | count_unique_values | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,329 | submission = pd.DataFrame({
'Id':test_id,
'Cover_Type':test_pred
})
submission.head() | Yes | 4 | 12 | Data_Transform | create_dataframe | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,330 | submission.to_csv('my_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 |
3,331 | # 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
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.... | No | 5 | 88 | Debug | list_files | null | 1 | A | 0 | 2 | 3 | 0 | 0 | 7 | 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"] | 0 | A |
3,332 | train_data=pd.read_csv('/kaggle/input/forest-cover-type-prediction/train.csv')
train_data.head() | Yes | 3 | 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 |
3,333 | test_data=pd.read_csv('/kaggle/input/forest-cover-type-prediction/test.csv')
test_data.head() | Yes | 3 | 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 |
3,334 | train_data.info() | No | 5 | 40 | Debug | show_table_attributes | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,335 | test_data.info() | No | 5 | 40 | Debug | show_table_attributes | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,336 | from sklearn.model_selection import train_test_split | No | 5 | 22 | Environment | import_modules | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 0 | A |
3,337 | X=train_data.drop(labels=['Id','Cover_Type'],axis=1)
y=train_data['Cover_Type'] | Yes | 3 | 10 | Data_Transform | drop_column | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,338 | print(X_train.shape,y_train.shape)
print(X_val.shape,y_val.shape) | Yes | 5 | 58 | Debug | show_shape | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,339 | rfc=RandomForestClassifier(n_estimators=70)
rfc.fit(X_train,y_train) | Yes | 3 | 4 | Model_Train | choose_model_class | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,340 | rfc.score(X_val,y_val) | 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 |
3,341 | predict=rfc.predict(test_data.drop(labels=['Id'],axis=1)) | Yes | 3 | 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 |
3,342 | Submission=pd.DataFrame(data=predict,columns=['Cover_Type'])
Submission.head() | Yes | 2 | 12 | Data_Transform | create_dataframe | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,343 | 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 |
3,344 | Submission.to_csv('Submission.csv') | 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 |
3,345 | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import pickle
pd.set_option('display.max_columns', 100)
pd.options.mode.chained_assignment = None | Yes | 4 | 22 | Environment | import_modules | 9,278,535 | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | 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"] | 6 | A |
3,346 | dtrain = pd.read_csv(train_path, index_col=0)
dtest = pd.read_csv(test_path, index_col=0) | No | 5 | 45 | Data_Extraction | load_from_csv | 9,278,535 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | 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", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness."] | 6 | A |
3,347 | dtrain['Cover_Type'].value_counts() | No | 5 | 72 | EDA | count_values | 9,278,535 | 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 | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Column Selection Checker", "Dependent Threshold Checker"] | 6 | B |
3,348 | dtrain.info() | No | 5 | 40 | Debug | show_table_attributes | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,349 | # Now this includes values for all classes, better to groupyby the target variable and then get description.
dtrain.describe() | No | 5 | 40 | Debug | show_table_attributes | 9,278,535 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Dependent Threshold Checker"] | 6 | B |
3,350 | X_train,X_test,y_train,y_test = train_test_split(X,y,random_state = 10,test_size=0.2,shuffle =True) | No | 5 | 13 | Data_Transform | split | 10,712,817 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 4 | 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"}] | ["Dependent Threshold Checker", "Logging Checker"] | 19 | B |
3,351 | logistic_regression= LogisticRegression()
logistic_regression.fit(X_train,y_train)
y_pred=logistic_regression.predict(X_test) | Yes | 4 | 7 | Model_Train | train_model | 10,712,817 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 11 | 10 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Scaler Missing Checker", "fix": "Apply scaling before scaling-sensitive operations.", "benefits": "Improves model performance and accuracy.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation... | C | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low, Scaler Missing Checker=medium | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Scaler Missing Checker", "severity": "medium"}] | ["Dependent Threshold Checker", "Exception Handling Checker", "Memory Release Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 19 | C |
3,352 | # fit the model on the whole dataset
random_forest = RandomForestClassifier()
random_forest.fit(X_train, y_train) | No | 5 | 7 | Model_Train | train_model | 10,712,817 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 7 | 6 | [{"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"}] | ["Dependent Threshold Checker", "Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 19 | B |
3,353 | decisionTreeModel = DecisionTreeClassifier(criterion= 'entropy',
max_depth = None,
splitter='best',
random_state=10)
decisionTreeModel.fit(X_train,y_train) | No | 5 | 7 | Model_Train | train_model | 10,712,817 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | 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"] | 19 | B |
3,355 | KNeighborsModel = KNeighborsClassifier(n_neighbors = 7,
weights = 'distance',
algorithm = 'brute')
KNeighborsModel.fit(X_train,y_train) | No | 5 | 7 | Model_Train | train_model | 10,712,817 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | 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"] | 19 | B |
3,358 | bernoulliNBModel = BernoulliNB(alpha=0.1)
bernoulliNBModel.fit(X_train,y_train) | No | 5 | 7 | Model_Train | train_model | 10,712,817 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | 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"] | 19 | B |
3,359 | gaussianNBModel = GaussianNB()
gaussianNBModel.fit(X_train,y_train) | No | 5 | 7 | Model_Train | train_model | 10,712,817 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | 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"] | 19 | B |
3,360 | XGB_Classifier = XGBClassifier()
XGB_Classifier.fit(X_train, y_train) | No | 5 | 7 | Model_Train | train_model | 10,712,817 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | 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"] | 19 | B |
3,361 | #evaluation Details
models = [logistic_regression, random_forest, decisionTreeModel, KNeighborsModel,
bernoulliNBModel, gaussianNBModel, XGB_Classifier]
for model in models:
print(type(model).__name__,' Train Score is : ' ,model.score(X_train, y_train))
print(type(model).__name__,' Test Score is... | No | 3 | 48 | Model_Evaluation | predict_on_test | 10,712,817 | 1 | A | 0 | 1 | 1 | 0 | 0 | 8 | ok | 4 | 4 | [{"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", "Exception Handling Checker", "Memory Release Checker", "Unit Testing Checker"] | 19 | A |
3,362 | y_pred = XGB_Classifier.predict(X_test) | No | 5 | 48 | Model_Evaluation | predict_on_test | 10,712,817 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 4 | 4 | [{"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", "Exception Handling Checker", "Memory Release Checker", "Unit Testing Checker"] | 19 | A |
3,363 | import seaborn as sn
confusion_matrix = pd.crosstab(y_test, y_pred, rownames=['Actual'], colnames=['Predicted'])
sn.heatmap(confusion_matrix, annot=True) | No | 5 | 80 | Visualization | heatmap | 10,712,817 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker"] | 19 | A |
3,364 | b"from sklearn.metrics import accuracy_score,classification_report\n\nprint(accuracy_score(y_test,y_pred).round(4)*100,'\\n')\n\nprint(pd.crosstab(y_test,y_pred),'\\n')\n\nprint(classification_report(y_test,y_pred),'\\n')" | No | 5 | 49 | Model_Evaluation | compute_test_metric | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,365 | X_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 |
3,366 | test_predict = XGB_Classifier.predict(test_to_pred) | No | 5 | 48 | Model_Evaluation | predict_on_test | 10,712,817 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 4 | 4 | [{"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", "Exception Handling Checker", "Memory Release Checker", "Unit Testing Checker"] | 19 | A |
3,367 | test.reset_index(inplace = True)
test.head() | No | 5 | 61 | Data_Transform | rename_columns | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,368 | predict = test['EventId'] | No | 3 | 21 | Data_Transform | prepare_x_and_y | 10,712,817 | 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"] | 19 | A |
3,369 | predict = pd.concat([predict,test_predict], axis=1) | No | 5 | 11 | Data_Transform | concatenate | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,370 | predict.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 |
3,371 | predict.tail(200) | No | 5 | 41 | Debug | show_table | 10,712,817 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 4 | 4 | [{"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", "Exception Handling Checker", "Memory Release Checker", "Unit Testing Checker"] | 19 | A |
3,372 | sb.countplot(predict.Class) | No | 5 | 33 | Visualization | distribution | 10,712,817 | 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"] | 19 | A |
3,373 | # 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
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.... | No | 5 | 88 | Debug | list_files | null | 1 | A | 0 | 2 | 3 | 0 | 0 | 7 | 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 13"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 0 | A |
3,374 | train_data = pd.read_csv('/kaggle/input/forest-cover-type-prediction/train.csv')
train_data.head() | Yes | 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 |
3,375 | test_data = pd.read_csv('/kaggle/input/forest-cover-type-prediction/test.csv')
test_data.head() | Yes | 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 |
3,376 | import seaborn as sns
plt.figure(figsize=(15,10))
sns.countplot(train['Cover_Type'])
plt.xlabel("Type of Cpver", fontsize=12)
plt.ylabel("Rows Count", fontsize=12)
plt.show()' | No | 4 | 81 | Visualization | relationship | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,377 | # Bivariate EDA
pd.crosstab(train.Soil_Type31, train.Cover_Type) | 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 |
3,378 | #Convert dummy features back to categorical
x = train.iloc[:,15:55]
y = train.iloc[:,11:15]
y = pd.DataFrame(y)
x = pd.DataFrame(x)
s2 = pd.Series(x.columns[np.where(x!=0)[1]])
s3 = pd.Series(y.columns[np.where(y!=0)[1]])
train['soil_type'] = s2
train['Wilderness_Area'] = s3
train.head() | Yes | 4 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 9 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,379 | # Create a new dataset exluding dummies variable for Mutivariate EDA
df_viz = train.iloc[:, 0:15]
df_viz = df_viz.drop(['Wilderness_Area1', 'Wilderness_Area2', 'Wilderness_Area3',
'Wilderness_Area4'], axis = 1)
df_viz.head() | Yes | 3 | 10 | Data_Transform | drop_column | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,380 | train_data['Slope'].plot(kind='hist') | No | 5 | 33 | Visualization | distribution | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,381 | test_data['Elevation'].plot(kind='hist') | No | 5 | 33 | Visualization | distribution | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,382 | train_data['Cover_Type'].value_counts()#from results it is visible that nothing is over sampled or under sampled | No | 5 | 72 | EDA | count_values | 9,991,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": "Cross Valida... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Column Selection Checker"] | 4 | B |
3,383 | from sklearn.model_selection import train_test_split | No | 5 | 22 | Environment | import_modules | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 0 | A |
3,384 | X_train, X_val, y_train,y_val = train_test_split(X,y,random_state=40) | No | 5 | 13 | Data_Transform | split | 9,991,645 | 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"}] | [] | 4 | B |
3,385 | rfc=RandomForestClassifier(n_estimators=70) | 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 |
3,386 | rfc.fit(X_train,y_train) | 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 |
3,387 | submission = pd.DataFrame(data=predict,columns=['Cover_Type'])
submission.head() | No | 3 | 12 | Data_Transform | create_dataframe | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,388 | submission['Id'] = test_data['Id']
submission.set_index('Id',inplace=True) | No | 5 | 55 | Data_Export | prepare_output | 9,991,645 | 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"] | 4 | A |
3,389 | submission.to_csv('Submission.csv') | 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 |
3,390 | import pandas as pd
import numpy as np
from sklearn.metrics import confusion_matrix
from sklearn.metrics import f1_score
from sklearn.metrics import accuracy_score
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_sq... | No | 5 | 22 | Environment | import_modules | 10,348,843 | 1 | A | 0 | 0 | 0 | 0 | 0 | 21 | 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"] | 16 | A |
3,391 | filepath= '/kaggle/input/forest-cover-type-prediction/train.csv'
filepath1= '/kaggle/input/forest-cover-type-prediction/test.csv'
testdata= pd.read_csv(filepath1)
testdata2=testdata
traindata= pd.read_csv(filepath)
traindata.head() | No | 4 | 45 | Data_Extraction | load_from_csv | 10,348,843 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 5 | 4 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Dependent Threshold Checker", "Hardcoded file path", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness."] | 16 | B |
3,392 | #We remove the id column in both the training and testing datasets.
traindata=traindata.drop('Id',axis=1)
testdata=testdata.drop('Id',axis=1) | No | 5 | 10 | Data_Transform | drop_column | 10,348,843 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Dependent Threshold Checker"] | 16 | B |
3,393 | #working with numeric features (They are all numerical features)
numeric_features = traindata.select_dtypes(include=[np.number])
numeric_features.dtypes | No | 5 | 70 | Debug | show_data_types | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,394 | #We will define the training and testing data here:
y=traindata['Cover_Type']
x=traindata.drop('Cover_Type',axis=1)
x_train, x_test, y_train, y_test = train_test_split(x, y, train_size=0.70,test_size=0.30, random_state=0) | No | 5 | 13 | Data_Transform | split | 10,348,843 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | 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 | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}] | ["Column Selection Checker", "Dependent Threshold Checker"] | 16 | B |
3,395 | ##Now we will run a few machine learning techiniques to see which one is the most applicable
#Linear Regression
linearRegressor = LinearRegression()
linearRegressor.fit(x_train, y_train)
y_predicted = linearRegressor.predict(x_test)
mse = mean_squared_error(y_test, y_predicted)
r = r2_score(y_test, y_predicted)
mae = ... | Yes | 4 | 7 | Model_Train | train_model | 10,348,843 | 1 | A | 0 | 0 | 0 | 0 | 0 | 9 | ok | 9 | 8 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | 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"}] | ["Dependent Threshold Checker", "Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 16 | B |
3,396 | # Random Forest
rf = RandomForestClassifier()
rf.fit(x_train,y_train);
y_predicted_r = rf.predict(x_test)
mse = mean_squared_error(y_test, y_predicted_r)
r = r2_score(y_test, y_predicted_r)
mae = mean_absolute_error(y_test,y_predicted_r)
print("Mean Squared Error:",mse)
print("R score:",r)
print("Mean Absolute Error:",... | Yes | 4 | 7 | Model_Train | train_model | 10,348,843 | 1 | A | 0 | 0 | 0 | 0 | 0 | 9 | ok | 11 | 9 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low, Randomness Control Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Randomness Control Checker", "severity": "low"}] | ["Dependent Threshold Checker", "Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 16 | B |
3,397 | # Decision Tree - CART
regressor = DecisionTreeRegressor(random_state = 0)
regressor.fit(x_train, y_train)
y_predicted_d = regressor.predict(x_test)
mse = mean_squared_error(y_test, y_predicted_d)
r = r2_score(y_test, y_predicted_d)
mae = mean_absolute_error(y_test,y_predicted_d)
print("Mean Squared Error:",mse)
print(... | Yes | 4 | 7 | Model_Train | train_model | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 9 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,398 | #Polynomial Regression
polynomial_features= PolynomialFeatures(degree=2)
x_poly = polynomial_features.fit_transform(x_train)
x_poly_test = polynomial_features.fit_transform(x_test)
model = LinearRegression()
model.fit(x_poly, y_train)
y_predicted_p = model.predict(x_poly_test)
mse = mean_squared_error(y_test, y_predict... | Yes | 4 | 7 | Model_Train | train_model | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 12 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,399 | #Ridge Regression
ridgereg = Ridge(normalize=True)
ridgereg.fit(x_train, y_train)
y_pred = ridgereg.predict(x_test)
mse = mean_squared_error(y_test, y_pred)
r = r2_score(y_test, y_pred)
mae = mean_absolute_error(y_test,y_pred)
print("Mean Squared Error:",mse)
print("R score:",r)
print("Mean Absolute Error:",mae) | Yes | 4 | 7 | Model_Train | train_model | 10,348,843 | 1 | A | 0 | 0 | 0 | 0 | 0 | 9 | ok | 9 | 8 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | 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"}] | ["Dependent Threshold Checker", "Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 16 | B |
3,400 | # LGBMClassifier
lgb_clf = LGBMClassifier(random_state=17)
lgb_clf.fit(x_train, y_train)
y_pred = lgb_clf.predict(x_test)
mse = mean_squared_error(y_test, y_pred)
r = r2_score(y_test, y_pred)
mae = mean_absolute_error(y_test,y_pred)
print("Mean Squared Error:",mse)
print("R score:",r)
print("Mean Absolute Error:",mae) | Yes | 4 | 7 | Model_Train | train_model | 10,348,843 | 1 | A | 0 | 0 | 0 | 0 | 0 | 9 | ok | 8 | 7 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Cross-validation not detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}] | ["Dependent Threshold Checker", "Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 16 | B |
3,401 | #GridSearchCV
param_grid = {'num_leaves': [7, 15, 31, 63],
'max_depth': [3, 4, 5, 6, -1]}
grid_searcher = GridSearchCV(estimator=lgb_clf, param_grid=param_grid,
cv=5, verbose=1, n_jobs=4)
grid_searcher.fit(x_train, y_train)
mse = mean_squared_error(y_test, y_pred)
r = r2_sco... | Yes | 4 | 6 | Hyperparam_Tuning | train_on_grid | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,402 | # Random Forest
rf = RandomForestClassifier()
rf.fit(x,y);
Prediction = rf.predict(testdata) | Yes | 4 | 7 | Model_Train | train_model | 10,348,843 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 11 | 9 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low, Randomness Control Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Randomness Control Checker", "severity": "low"}] | ["Dependent Threshold Checker", "Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 16 | B |
3,403 | predictionlist=Prediction.tolist()
Passengerid=testdata2['Id'].tolist()
output=pd.DataFrame(list(zip(Passengerid, predictionlist)),
columns=['Id','Cover_type'])
output.head()
output.to_csv('my_submission(ForestCoverTypePrediction).csv', index=False) | Yes | 4 | 25 | Data_Export | save_to_csv | 10,348,843 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | 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"] | 16 | A |
3,404 | train_data = pd.read_csv("/kaggle/input/forest-cover-type-prediction/train.csv")
train_data.shape | 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 |
3,405 | test_data = pd.read_csv("/kaggle/input/forest-cover-type-prediction/test.csv")
test_data.shape | 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 |
3,406 | train_data.columns
| No | 5 | 71 | Debug | show_columns | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,407 | test_data.columns | No | 5 | 71 | Debug | show_columns | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,408 | train_data['Cover_Type'].value_counts() | No | 5 | 72 | EDA | count_values | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,409 | from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test = train_test_split(X,y) | No | 5 | 13 | Data_Transform | split | null | 2 | B | 1 | 0 | 0 | 0 | 5 | 2 | 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"}] | [] | 0 | B |
3,410 | print(X_train.shape,y_train.shape)
print(X_test.shape,y_test.shape) | Yes | 4 | 14 | Data_Transform | filter | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,411 | from sklearn.neighbors import KNeighborsClassifier
knn = KNeighborsClassifier(n_neighbors=5)
knn.fit(X_train,y_train)
knn.score(X_test,y_test) | No | 3 | 7 | Model_Train | train_model | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | 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"] | 0 | B |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.