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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7,481 | test = pd.read_csv(FOLDER+'test.csv')
test.head() | Yes | 4 | 45 | Data_Extraction | load_from_csv | 2,047,549 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 3 | A |
7,482 | import numpy as np
import pandas as pd
import sklearn
from matplotlib import pyplot as plt
from scipy import stats as st
import os
import matplotlib.colors as mcolors | No | 5 | 22 | Environment | import_modules | 2,056,678 | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 13"}] | A | no applicable ML-specific findings | [] | ["Import Checker"] | 27 | A |
7,483 | from sklearn.pipeline import make_pipeline
from sklearn.ensemble import BaggingRegressor
from sklearn.ensemble import RandomForestRegressor
from sklearn.neural_network import MLPRegressor
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.ensemble import AdaBoostRegressor
from sklearn.tree import Decis... | No | 5 | 22 | Environment | import_modules | 2,056,678 | 1 | A | 0 | 0 | 0 | 0 | 0 | 8 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 13"}] | A | no applicable ML-specific findings | [] | ["Import Checker"] | 27 | A |
7,484 | trainfilepath = "../input/atividade-3-pmr3508/train.csv"
testfilepath = "../input/atividade-3-pmr3508/test.csv" | No | 5 | 77 | Other | define_variables | 2,056,678 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 3 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 13"}, {"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path d... | A | no applicable ML-specific findings | [] | ["Hardcoded file path", "Import Checker"] | 27 | A |
7,485 | trainHouses = pd.read_csv(trainfilepath, sep=r'\\s*,\\s*', engine='python', na_values='?')<br>testHouses = pd.read_csv(testfilepath, sep=r'\\s*,\\s*', engine='python', na_values='?') | No | 5 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,486 | states = pd.read_csv("../input/averagestatecoordinates/states.csv", sep=r\'\\s*,\\s*\', engine=\'python\', na_values=\'?\')<br>states.head() | Yes | 4 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,487 | from sklearn.neighbors import KNeighborsClassifier<br><br>knn = KNeighborsClassifier(n_neighbors=3, p=2)<br><br>#knn.fit(states.drop("state", axis="columns"), states[\'state\'])<br>knn.fit(states[["latitude", "longitude"]], states[\'state\'])<br><br><br>#trainHouses["state"] = knn.predict(trainHouses.drop(trainHouses.c... | Yes | 3 | 7 | Model_Train | train_model | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
7,488 | apple = (37.33182, -122.03118)
SF = (37.783333, -122.416667)
#trainHouses["distance_to_apple"] = np.sqrt((trainHouses["latitude"] - miami[0])**2 + (trainHouses["longitude"] - miami[1])**2)
#d_to_apple = np.sqrt((trainHouses["latitude"] - apple[0])**2 + (trainHouses["longitude"] - apple[1])**2)
d_to_apple = getDistance... | Yes | 4 | 33 | Visualization | distribution | 2,056,678 | 1 | A | 2 | 0 | 0 | 0 | 10 | 12 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 13"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection ... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Import Checker"] | 27 | A |
7,489 | LA = (35.0569, -118.25)
Beverly_Hills = (34.073056, -118.399444)
#d_to_LA = np.sqrt((trainHouses["latitude"] - LA[0])**2 + (trainHouses["longitude"] - LA[1])**2)
d_to_LA = getDistanceFromLatLng(trainHouses["latitude"], trainHouses["longitude"], LA[0], LA[1])
#d_to_BH = np.sqrt((trainHouses["latitude"] - Beverly_Hills[... | Yes | 4 | 33 | Visualization | distribution | 2,056,678 | 1 | A | 2 | 0 | 0 | 0 | 10 | 12 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 13"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection ... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Import Checker"] | 27 | A |
7,490 | trainHouses["distance_to_SF"] = d_to_SF
#testHouses["distance_to_SF"] = np.sqrt((testHouses["latitude"] - SF[0])**2 + (testHouses["longitude"] - SF[1])**2)
testHouses["distance_to_SF"] = getDistanceFromLatLng(testHouses["latitude"], testHouses["longitude"], SF[0], SF[1])
trainHouses["distance_to_LA"] = d_to_LA
#testHou... | No | 5 | 8 | Data_Transform | feature_engineering | 2,056,678 | 2 | B | 3 | 0 | 0 | 0 | 15 | 8 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 13"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection ... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Import Checker"] | 27 | B |
7,491 | trainHouses.shape | No | 5 | 58 | Debug | show_shape | 2,056,678 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 13"}] | A | no applicable ML-specific findings | [] | ["Import Checker"] | 27 | A |
7,492 | trainHouses.head() | No | 5 | 41 | Debug | show_table | 2,056,678 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 13"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Import Checker"] | 27 | B |
7,493 | plt.hist(trainHouses["median_house_value"], bins=100)
plt.show() | No | 5 | 33 | Visualization | distribution | 2,056,678 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 13"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection ... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Import Checker"] | 27 | A |
7,494 | XtrainHouses = trainHouses.drop(["Id", "median_house_value"], axis="columns")
XtrainHousesB = trainHouses.drop(["Id", "median_house_value", "median_age", "total_rooms", "total_bedrooms", "population", "households"], axis="columns")
YtrainHouses = trainHouses["median_house_value"]
XtestHouses = testHouses.drop("Id", ax... | Yes | 4 | 10 | Data_Transform | drop_column | 2,056,678 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 5 | 5 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 13"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection ... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Column Selection Checker", "Import Checker"] | 27 | B |
7,495 | #a = trainHouses[trainHouses["median_house_value"].transform(lambda x: x<=500000)]
#a = trainHouses[trainHouses["median_house_value"] <=500000]
plt.hist(trainHouses[trainHouses["median_house_value"] <=500000]["median_house_value"], bins=100)
plt.show()
culledTrainHouses = trainHouses[trainHouses["median_house_value"] <... | Yes | 3 | 33 | Visualization | distribution | 2,056,678 | 1 | A | 1 | 0 | 0 | 0 | 5 | 5 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "General", "name": "Import Checker", "fix": "Use standard naming conventions for imported modules.", "benefits": "Improves code readability and maintainability.", "location": "Line 13"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection ... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Import Checker"] | 27 | A |
7,496 | import pandas as pd
import sklearn
import os
import numpy as np
import matplotlib.pyplot as plt
from sklearn.neighbors import KNeighborsRegressor
from sklearn.model_selection import cross_val_score
from sklearn.metrics import mean_squared_log_error
from sklearn import linear_model
from sklearn.ensemble import RandomFo... | Yes | 4 | 22 | Environment | import_modules | 2,062,116 | 1 | A | 0 | 0 | 0 | 0 | 0 | 12 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 11 | A |
7,497 | train_data = pd.read_csv('../input/train.csv',
engine='python')
test_data = pd.read_csv('../input/test.csv',
engine='python') | No | 5 | 45 | Data_Extraction | load_from_csv | 2,062,116 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 3 | 2 | [{"detector": "general_ml", "framework": "General ML", "name": "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "fix": "Not specified", "benefits": "Not specified", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name": "Har... | A | no applicable ML-specific findings | [] | ["Hardcoded file path", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness."] | 11 | A |
7,498 | train_data.head()
| No | 5 | 41 | Debug | show_table | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,499 | train_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 |
7,500 | 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 |
7,501 | Xtrain = train_data
Xtrain = Xtrain.drop('Id', axis=1)
Xtrain = Xtrain.drop('median_house_value', axis=1)
Ytrain = train_data['median_house_value'] | Yes | 4 | 21 | Data_Transform | prepare_x_and_y | 2,062,116 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 4 | 4 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Column Selection Checker"] | 11 | B |
7,502 | knn = KNeighborsRegressor(n_neighbors=10)
knn.fit(Xtrain, Ytrain)
scores = cross_val_score(knn, Xtrain, Ytrain, cv=10)
Ypred = knn.predict(Xtrain)
scores.mean() | Yes | 3 | 7 | Model_Train | train_model | 2,062,116 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 7 | 5 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Verbose Mode Checker", "fix": "Enable verbose mode for long training processes.", "benefits": "Provides better insights into model training progress.", "location": "Line 13"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": ... | B | No random seed setting detected=low | [{"type": "No random seed setting detected", "severity": "low"}] | ["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 | B |
7,503 | rmsle(Ytrain, Ypred) | No | 5 | 28 | Model_Train | compute_train_metric | 2,062,116 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 11 | A |
7,504 | reg = linear_model.Lasso(alpha = 0.1)
reg.fit(Xtrain, Ytrain)
scores = cross_val_score(reg, Xtrain, Ytrain, cv=10)
Ypred=reg.predict(Xtrain)
scores.mean() | Yes | 3 | 7 | Model_Train | train_model | 2,062,116 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 7 | 5 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Verbose Mode Checker", "fix": "Enable verbose mode for long training processes.", "benefits": "Provides better insights into model training progress.", "location": "Line 13"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": ... | B | No random seed setting detected=low | [{"type": "No random seed setting detected", "severity": "low"}] | ["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 | B |
7,505 | rid = linear_model.Ridge(alpha = 0.5)
rid.fit(Xtrain, Ytrain)
scores = cross_val_score(rid, Xtrain, Ytrain, cv=10)
Ypred = rid.predict(Xtrain)
scores.mean() | Yes | 3 | 7 | Model_Train | train_model | 2,062,116 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 7 | 5 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Verbose Mode Checker", "fix": "Enable verbose mode for long training processes.", "benefits": "Provides better insights into model training progress.", "location": "Line 13"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": ... | B | No random seed setting detected=low | [{"type": "No random seed setting detected", "severity": "low"}] | ["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 | B |
7,506 | bay = linear_model.BayesianRidge()
bay.fit(Xtrain, Ytrain)
scores = cross_val_score(bay, Xtrain, Ytrain, cv=10)
Ypred = bay.predict(Xtrain)
scores.mean() | Yes | 3 | 7 | Model_Train | train_model | 2,062,116 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 7 | 5 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Verbose Mode Checker", "fix": "Enable verbose mode for long training processes.", "benefits": "Provides better insights into model training progress.", "location": "Line 13"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": ... | B | No random seed setting detected=low | [{"type": "No random seed setting detected", "severity": "low"}] | ["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 | B |
7,507 | lars = linear_model.LassoLars(alpha = 0.1)
lars.fit(Xtrain, Ytrain)
scores = cross_val_score(lars, Xtrain, Ytrain, cv=10)
Ypred = lars.predict(Xtrain)
scores.mean() | Yes | 3 | 7 | Model_Train | train_model | 2,062,116 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 7 | 5 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Verbose Mode Checker", "fix": "Enable verbose mode for long training processes.", "benefits": "Provides better insights into model training progress.", "location": "Line 13"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": ... | B | No random seed setting detected=low | [{"type": "No random seed setting detected", "severity": "low"}] | ["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 | B |
7,508 | california_sea=[(41.990352, -124.216535),(41.936725, -124.199048),(41.862157, -124.220161),(41.758672, -124.240793),(41.730317, -124.162807),(41.672629, -124.139878),(41.722746, -124.151351),(41.671813, -124.136762),(41.618963, -124.109252),(41.470737, -124.072740),(41.383226, -124.066948),(41.308172, -124.094492),(41.... | No | 5 | 77 | Other | define_variables | 2,062,116 | 1 | A | 0 | 0 | 0 | 0 | 0 | 19 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 11 | A |
7,509 | train_data3 = train_data2<br>train_data3["rooms_per_household"] = train_data3["total_rooms"]/train_data3["households"]<br>train_data3["bedrooms_per_room"] = train_data3["total_bedrooms"]/train_data3["total_rooms"]<br>train_data3["population_per_household"] = train_data3["population"]/train_data3["households"]<br>train_... | No | 5 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,510 | d = 8
n = 100
boost = AdaBoostRegressor(DecisionTreeRegressor(max_depth=d),
n_estimators=n)
boost.fit(Xtrain3, Ytrain)
Ypred = boost.predict(Xtrain3)
boost_rmsle = rmsle(Ytrain, Ypred)
print('error =', boost_rmsle) | Yes | 3 | 7 | Model_Train | train_model | 2,062,116 | 1 | A | 0 | 0 | 0 | 0 | 0 | 8 | 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"}] | ["Exception Handling Checker", "Magic number", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 11 | B |
7,511 | from sklearn.model_selection import train_test_split
X_train, X_validation, y_train, y_validation = train_test_split(Xtrain3, Ytrain, train_size=0.7)
from catboost import CatBoostRegressor
model=CatBoostRegressor(iterations=200, depth=6, learning_rate=0.2, loss_function='RMSE')
model.fit(Xtrain3, Ytrain,eval_set=(X_v... | Yes | 2 | 7 | Model_Train | train_model | 2,062,116 | 1 | A | 1 | 0 | 0 | 0 | 5 | 8 | 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, 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"}] | ["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 | B |
7,512 | Xtest2 = test_data2.drop('Id', axis=1) | No | 5 | 10 | Data_Transform | drop_column | 2,062,116 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 11 | A |
7,513 | forest = RandomForestRegressor(max_depth=21, random_state=0, n_estimators=1000)
forest.fit(Xtrain3, Ytrain)
Ypred = forest.predict(Xtrain3)
forest_rmsle = rmsle(Ytrain, Ypred)
print('log error =', forest_rmsle)
prediction = forest.predict(Xtest2) | Yes | 3 | 7 | Model_Train | train_model | 2,062,116 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 9 | 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, Cross-validation not detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}] | ["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 | B |
7,514 | import numpy as np
import pandas as pd
import sklearn
import matplotlib.pyplot as plt
import os
print(os.listdir("../input"))
| No | 5 | 88 | Debug | list_files | 2,074,747 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 15"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 8 | A |
7,515 | train = pd.read_csv("../input/train.csv")
test = pd.read_csv("../input/test.csv")
Xtrain = train.drop(columns=["Id","median_house_value"])
Ytrain = train["median_house_value"]
| Yes | 3 | 45 | Data_Extraction | load_from_csv | 2,074,747 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 5 | 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 | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Column Selection Checker", "Hardcoded file path", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness."] | 8 | B |
7,516 | Xtrain.describe() | No | 5 | 40 | Debug | show_table_attributes | 2,074,747 | 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"}] | [] | 8 | B |
7,517 | YPredict.describe() | No | 5 | 40 | Debug | show_table_attributes | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,518 | pd.DataFrame({"Id":ID_list,"median_house_value":YPredict}).to_csv("pred_R.csv",index=False) | No | 5 | 25 | Data_Export | save_to_csv | 2,074,747 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 8 | A |
7,519 | import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings("ignore") | No | 5 | 23 | Environment | set_options | 2,076,170 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
7,520 | data = pd.read_csv("../input/atividade-3-pmr3508/train.csv")
data.head() | Yes | 4 | 45 | Data_Extraction | load_from_csv | 2,076,170 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/atividade-3-pmr3508/train.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 7"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 6 | A |
7,521 | 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 |
7,522 | newData = data.drop(["Id","latitude","longitude"],axis=1) | No | 5 | 10 | Data_Transform | drop_column | 2,076,170 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
7,523 | newData["avg_rooms"] = newData.total_rooms/newData.households
newData["avg_bedrooms"] = newData.total_bedrooms/newData.households
newData["avg_inhabitants"] = newData.population/newData.households | No | 5 | 8 | Data_Transform | feature_engineering | 2,076,170 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 6 | A |
7,524 | from sklearn.neighbors import KNeighborsRegressor
from sklearn.model_selection import GridSearchCV | No | 5 | 22 | Environment | import_modules | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 0 | A |
7,525 | knn = KNeighborsRegressor()
knn.get_params() | Yes | 4 | 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 |
7,526 | param_grid = {"n_neighbors":[i for i in range(1,31)],"weights":["uniform","distance"],"p":[1,2]}
grid = GridSearchCV(knn,param_grid,cv=10) | Yes | 4 | 5 | Hyperparam_Tuning | define_search_space | 2,076,170 | 2 | B | 1 | 0 | 0 | 0 | 5 | 2 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Verbose Mode Checker", "fix": "Enable verbose mode for long training processes.", "benefits": "Provides better insights into model training progress.", "location": "Line 8"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "... | A | no applicable ML-specific findings | [] | ["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 6 | B |
7,527 | grid.fit(xTrain,yTrain)
print(grid.best_estimator_)
print(grid.best_score_) | No | 5 | 6 | Hyperparam_Tuning | train_on_grid | 2,076,170 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 4 | 4 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 6 | B |
7,528 | ridge = Ridge()
ridge.get_params() | Yes | 4 | 4 | Model_Train | choose_model_class | 2,076,170 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
7,529 | param_grid2 = {"alpha":np.linspace(0.5,10.5,101).tolist()}
grid2 = GridSearchCV(ridge,param_grid2,cv=10) | Yes | 4 | 5 | Hyperparam_Tuning | define_search_space | 2,076,170 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Verbose Mode Checker", "fix": "Enable verbose mode for long training processes.", "benefits": "Provides better insights into model training progress.", "location": "Line 8"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "... | A | no applicable ML-specific findings | [] | ["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 6 | A |
7,530 | grid2.fit(xTrain,yTrain)
print(grid2.best_estimator_)
print(grid2.best_score_) | No | 5 | 6 | Hyperparam_Tuning | train_on_grid | 2,076,170 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 4 | 4 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 6 | B |
7,531 | from sklearn.linear_model import Lasso | 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 |
7,532 | lasso = Lasso()
lasso.get_params() | Yes | 4 | 4 | Model_Train | choose_model_class | 2,076,170 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
7,533 | param_grid3 = {"alpha":np.linspace(0.5,5.5,51).tolist(),"normalize":[True,False]}
grid3 = GridSearchCV(lasso,param_grid3,cv=10) | Yes | 4 | 5 | Hyperparam_Tuning | define_search_space | 2,076,170 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 3 | 3 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Verbose Mode Checker", "fix": "Enable verbose mode for long training processes.", "benefits": "Provides better insights into model training progress.", "location": "Line 8"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "... | A | no applicable ML-specific findings | [] | ["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 6 | A |
7,534 | grid3.fit(xTrain,yTrain)
print(grid3.best_estimator_)
print(grid3.best_score_) | No | 5 | 6 | Hyperparam_Tuning | train_on_grid | 2,076,170 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 4 | 4 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 6 | B |
7,535 | testRaw = pd.read_csv("../input/atividade-3-pmr3508/test.csv")
ID_list = testRaw.Id.tolist()
testRaw["avg_rooms"] = testRaw.total_rooms/testRaw.households
testRaw["avg_bedrooms"] = testRaw.total_bedrooms/testRaw.households
testRaw["avg_inhabitants"] = testRaw.population/testRaw.households
testData = testRaw.drop(["Id",... | Yes | 3 | 8 | Data_Transform | feature_engineering | 2,076,170 | 1 | A | 0 | 0 | 0 | 0 | 0 | 7 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path d... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Hardcoded file path"] | 6 | A |
7,536 | knn.fit(xTrain,yTrain)
pred_knn = knn.predict(testData).tolist() | Yes | 4 | 7 | Model_Train | train_model | 2,076,170 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 9 | 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, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 6 | B |
7,537 | pd.DataFrame({"Id":ID_list,"median_house_value":pred_knn}).to_csv("pred_knn.csv",index=False) | No | 5 | 25 | Data_Export | save_to_csv | 2,076,170 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
7,538 | ridge.fit(xTrain,yTrain)
pred_ridge = ridge.predict(testData).tolist() | Yes | 4 | 7 | Model_Train | train_model | 2,076,170 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 9 | 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, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 6 | B |
7,539 | pd.DataFrame({"Id":ID_list,"median_house_value":pred_ridge}).to_csv("pred_ridge.csv",index=False) | No | 5 | 25 | Data_Export | save_to_csv | 2,076,170 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
7,540 | lasso.fit(xTrain,yTrain)
pred_lasso = lasso.predict(testData).tolist() | Yes | 4 | 7 | Model_Train | train_model | 2,076,170 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 9 | 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, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 6 | B |
7,541 | pd.DataFrame({"Id":ID_list,"median_house_value":pred_lasso}).to_csv("pred_lasso.csv",index=False) | No | 5 | 25 | Data_Export | save_to_csv | 2,076,170 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
7,542 | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from geopy.distance import distance
from geopy.distance import vincenty
from sklearn.metrics import make_scorer
from sklearn.model_selection import cross_validate
from sklearn.preprocessing import MinMaxScaler
from sklearn.mode... | No | 5 | 22 | Environment | import_modules | 2,076,816 | 1 | A | 0 | 0 | 0 | 0 | 0 | 15 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 11 | A |
7,543 | Train = pd.read_csv("../input/californianhouses/train.csv",<br> sep=r\'\\s*,\\s*\',<br> engine=\'python\',<br> na_values="")<br>Test = pd.read_csv("../input/californianhouses/test.csv",<br> sep=r\'\\s*,\\s*\',<br> engine=\'python\',<br> na_values="") | 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 |
7,544 | Train.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 |
7,545 | # Id no um critrio para estimar a varivel desejada<br>Train = Train.drop(columns=['Id']) | No | 5 | 10 | Data_Transform | drop_column | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,546 | plt.title('Matriz de correlao')<br>sns.heatmap(mcorr) | No | 5 | 80 | Visualization | heatmap | null | 1 | A | 0 | 0 | 0 | 1 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,547 | scaler = MinMaxScaler()
selected_columns = ['median_income', 'total_rooms','population','median_age']
SC = scaler.fit_transform(Train[selected_columns])
x_train, x_test, y_train, y_test = train_test_split(SC, Train['median_house_value'], test_size=0.20) | Yes | 4 | 18 | Data_Transform | normalization | 2,076,816 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 10 | 10 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Pipeline Che... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low, Pipeline Checker=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": "Pipeline Checker", "severity": "low"}, {"type": "Randomness Control Checker", "severity": "low"}] | ["Column Selection Checker", "Exception Handling Checker", "Potential data leakage: Preprocessing applied before train-test split (module-level code)", "Unit Testing Checker", "Verbose Mode Checker"] | 11 | B |
7,548 | def rmsle(y_test, y_pred):
return np.sqrt(np.mean((np.log(y_pred+1) - np.log(y_test+1))**2))
reg = LinearRegression()
scorer = make_scorer(rmsle, greater_is_better=False)
reg.fit(x_train, y_train)
y_pred = reg.predict(x_test)
print("RMSLE: " + str(rmsle(y_pred, y_test))) | Yes | 3 | 7 | Model_Train | train_model | null | 1 | A | 0 | 1 | 0 | 0 | 0 | 7 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,549 | param_grid = dict(n_neighbors=list(range(1,15)))
neigh = KNeighborsClassifier()
grid_obj = GridSearchCV(neigh, param_grid, scoring=scorer, cv=5)
grid_obj.fit(x_train, y_train)
grid_obj.best_params_ | Yes | 3 | 7 | Model_Train | train_model | null | 1 | A | 1 | 0 | 0 | 0 | 5 | 5 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,550 | neigh = KNeighborsClassifier(n_neighbors=1)
neigh.fit(x_train, y_train)
y_pred = neigh.predict(x_test)
print("RMSLE: " + str(rmsle(y_pred, y_test))) | Yes | 3 | 7 | Model_Train | train_model | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,551 | las = Lasso()
param_grid = dict(alpha=np.divide(list(range(1,100)),100))
grid_obj = GridSearchCV(las, param_grid, scoring=scorer, cv=5)
grid_obj.fit(x_train, y_train)
grid_obj.best_params_ | Yes | 2 | 7 | Model_Train | train_model | null | 1 | A | 1 | 0 | 0 | 0 | 5 | 5 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,552 | las = Lasso(alpha=0.21)
las.fit(x_train, y_train)
y_pred = las.predict(x_test)
print("RMSLE: " + str(rmsle(y_pred, y_test))) | Yes | 3 | 7 | Model_Train | train_model | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,553 | rfc = RandomForestClassifier(n_estimators=50, max_depth=35, random_state=0)
rfc.fit(x_train, y_train)
y_pred = rfc.predict(x_test)
print("RMSLE: " + str(rmsle(y_pred, y_test)))
| Yes | 3 | 7 | Model_Train | train_model | 2,076,816 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 8 | 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, Cross-validation not detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}] | ["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 | B |
7,554 | dfTest = Test.drop(['longitude', 'latitude', 'households', 'total_bedrooms'], axis=1)
dfTest.head() | Yes | 4 | 10 | Data_Transform | drop_column | 2,076,816 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 11 | A |
7,555 | dfTest.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 |
7,556 | selected_model = rfc
x_val_test = scaler.transform(dfTest[selected_columns])
y_val_test = selected_model.predict(x_val_test)
dfSave = pd.DataFrame(data={"Id" : dfTest["Id"], "median_house_value" : y_val_test})
pd.DataFrame(dfSave[["Id", "median_house_value"]], columns = ["Id", "median_house_value"]).to_csv("Output.csv"... | Yes | 3 | 25 | Data_Export | save_to_csv | 2,076,816 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 5 | 4 | [{"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... | B | No random seed setting detected=low | [{"type": "No random seed setting detected", "severity": "low"}] | ["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker"] | 11 | B |
7,557 | # Importao das bibliotecas <br>import numpy as np<br>import pandas as pd<br>import matplotlib.pyplot as plt<br>%matplotlib inline<br>import warnings <br>import math<br>import seaborn as sns<br> | No | 5 | 23 | Environment | set_options | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,558 | #Lendo a base de treino<br>traindata = pd.read_csv("../input/california-houses/train.csv",<br> sep=r\'\\s*,\\s*\',<br> engine=\'python\',<br> na_values="?") | 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 |
7,559 | #Modificando a visalizao da base de treino<br>traindata.iloc[0:20,:] | No | 5 | 14 | Data_Transform | filter | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,560 | traindata = traindata.drop(columns = ['Id']) | No | 5 | 10 | Data_Transform | drop_column | 2,077,355 | 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 |
7,561 | traindata.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 |
7,562 | # Grficos de barra das variveis <br>traindata.hist(bins=50, figsize=(20,20))<br>plt.show() | No | 5 | 33 | Visualization | distribution | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,563 | plt.figure(figsize=(6,6))<br>plt.title('Matriz de correlao')<br>sns.heatmap(traindata.corr(), annot=True, linewidths=0.1) | No | 5 | 80 | Visualization | heatmap | null | 1 | A | 0 | 0 | 0 | 1 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,564 | knn_trainX = traindata[["longitude","total_rooms","total_bedrooms","population","households","median_income"]]
| No | 5 | 12 | Data_Transform | create_dataframe | 2,077,355 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 4 | A |
7,565 | from sklearn.neighbors import KNeighborsRegressor
neighbor = KNeighborsRegressor(n_neighbors=2)
neighbor.fit(knn_trainX,trainY)
knn_predict = neighbor.predict(knn_trainX)
df_knn = pd.DataFrame({'Y_real':trainY[:],'Y_pred':knn_predict[:]})
print(rmsle(df_knn.Y_real,df_knn.Y_pred)) | Yes | 2 | 7 | Model_Train | train_model | 2,077,355 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | 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, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 4 | B |
7,566 | def rooms_pop(row):<br> row['rooms_pop'] = row['total_rooms'] / row['population'] <br> return row<br>traindata = traindata.apply(rooms_pop, axis=1)<br>traindata = traindata.drop(['population'], axis=1)<br>plt.figure(figsize=(6,6))<br>plt.title('Matriz de correlao')<br>sns.heatmap(traindata.corr(), annot=True, lin... | Yes | 3 | 80 | Visualization | heatmap | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,567 | def age_rooms(row):<br> row['age_rooms'] = row['median_age'] / row['total_rooms'] <br> return row<br>traindata = traindata.apply(age_rooms, axis=1)<br>traindata = traindata.drop(['median_age'], axis=1)<br>plt.figure(figsize=(6,6))<br>plt.title('Matriz de correlao')<br>sns.heatmap(traindata.corr(), annot=True, lin... | Yes | 3 | 80 | Visualization | heatmap | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,568 | traindata = traindata.drop(columns = ['latitude','longitude']) | No | 5 | 10 | Data_Transform | drop_column | 2,077,355 | 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 |
7,569 | newknn_trainX = traindata[["per_capita","total_bedrooms","rooms_pop","households","age_rooms"]]<br>neighbor = KNeighborsRegressor(n_neighbors=2)<br>neighbor.fit(newknn_trainX,trainY) <br>knn_predict = neighbor.predict(newknn_trainX)<br>df_knn = pd.DataFrame({\'Y_real\':trainY[:],\'Y_pred\':knn_predict[:]})<br>print(rms... | Yes | 2 | 7 | Model_Train | train_model | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,570 | x_val_test = testX<br>y_val_test = neighbor.predict(x_val_test)<br><br>dfSave = pd.DataFrame(data={"Id" : testdata["Id"], "median_house_value" : y_val_test})<br>dfSave[\'Id\'] = dfSave[\'Id\'].astype(int)<br>pd.DataFrame(dfSave[["Id", "median_house_value"]], columns = ["Id", "median_house_value"]).to_csv("Output.csv", ... | Yes | 3 | 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 |
7,571 | %matplotlib inline<br><br>from matplotlib import pyplot as plt<br>import pandas as pd<br>import numpy as np<br><br>import os<br><br>df = pd.read_csv("../input/atividade-3-pmr3508/train.csv",<br> sep=r\'\\s*,\\s*\',<br> engine=\'python\',<br> na_values="?")<br>df = df.replace(np.nan,\' \', regex=Tru... | No | 3 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
7,572 | df.describe() | No | 5 | 40 | Debug | show_table_attributes | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,573 | X["coord"] = X["latitude"].map(str) + ', ' + X["longitude"].map(str) | No | 5 | 8 | Data_Transform | feature_engineering | 2,077,825 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
7,574 | cities = pd.DataFrame(address.Id)<br>cities = cities.set_index(\'Id\')<br>cities[\'city\'] = \'\'<br><br>for index, row in address.iterrows():<br> city = row[\'location\'][-2]<br> row_id = row[\'Id\']<br> cities.at[row_id, \'city\'] = city.lstrip(\' \')<br><br>cities.to_csv("cities.csv", index=False) | Yes | 4 | 25 | Data_Export | save_to_csv | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,575 | cities = pd.read_csv("../input/california-prices/cities.csv",<br> sep=r\'\\s*"\\s*\',<br> engine=\'python\')<br>X[\'cities\'] = cities[\'city\'] | Yes | 4 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
7,576 | calPrices = pd.read_csv("../input/california-prices/calif.csv",<br> sep=r\'\\s*,\\s*\\s*"\',<br> engine=\'python\')<br><br><br>calPrices = calPrices.replace(\'---\',\' \', regex=True)<br>calPrices.columns = [col.replace(\'"\', \'\') for col in calPrices.columns]<br>calPrices = calPrices.filter([\'Region N... | Yes | 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 |
7,577 | calPrices.head() | No | 5 | 41 | Debug | show_table | 2,077,825 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
7,578 | X['people_pb'] = X.population/X.total_bedrooms
X['people_ph'] = X.population/X.households
X['income_pr'] = X.median_income/X.total_rooms | No | 5 | 8 | Data_Transform | feature_engineering | 2,077,825 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
7,579 | X = X.replace('', np.NaN)
X = X.replace(' ', np.NaN)
X = X.dropna()
X = X.drop(['Id','longitude','latitude','coord'], axis = 1) | Yes | 4 | 17 | Data_Transform | correct_missing_values | 2,077,825 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
7,580 | X_train = X.filter(['median_age', 'total_rooms','total_bedrooms', 'population', 'households', 'median_income', 'city_price', 'people_pb','people_ph', 'income_pr'], axis = 1)
X_train.describe() | Yes | 4 | 14 | Data_Transform | filter | 2,077,825 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}] | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | [] | 7 | B |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.