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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4,247 | plt.figure(figsize = (10,7))
tc = train.corr()
sns.heatmap(tc, annot = True, cmap = 'coolwarm', linecolor = 'white', linewidths=0.1) | No | 5 | 80 | Visualization | heatmap | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | 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 |
4,248 | #Convert to integer variables
columns=['season', 'holiday', 'workingday', 'weather']
for i in columns:
data[i] = data[i].apply(lambda x : int(x)) | No | 5 | 8 | Data_Transform | feature_engineering | 6,062,819 | 1 | A | 0 | 1 | 1 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,249 | #Convert string to datatime and create Hour, Month and Day of week
data['datetime'] = pd.to_datetime(data['datetime'])
data['Hour'] = data['datetime'].apply(lambda x:x.hour)
data['Month'] = data['datetime'].apply(lambda x:x.month)
data['Day of Week'] = data['datetime'].apply(lambda x:x.dayofweek) | No | 4 | 8 | Data_Transform | feature_engineering | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,250 | plt.figure(figsize = (8,4))
sns.lineplot(x = 'Month', y = 'count', data = data, estimator = np.average, hue = 'weather', palette = 'coolwarm')
plt.ylabel('Average Count')
plt.show() | No | 5 | 75 | Visualization | time_series | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,251 | data[data['weather'] == 4] | No | 5 | 14 | Data_Transform | filter | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,252 | fig, axes = plt.subplots(ncols = 2, figsize = (15,5), sharey = True)
sns.pointplot(x = 'Hour', y = 'count', data = data, estimator = np.average, hue = 'workingday', ax = axes[0], palette = 'muted')
sns.pointplot(x = 'Hour', y = 'count', data = data, estimator = np.average, hue = 'holiday', ax = axes[1], palette = 'mute... | No | 5 | 75 | Visualization | time_series | 6,062,819 | 1 | A | 0 | 1 | 1 | 0 | 0 | 6 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,253 | plt.figure(figsize = (10,4))
sns.pointplot(x = 'Hour', y = 'count', data = data, estimator=np.average, hue = 'Day of Week', palette='coolwarm') | No | 5 | 75 | Visualization | time_series | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,254 | sns.jointplot(x = 'atemp', y = 'count', data = data, kind = 'kde', cmap = 'plasma')
plt.show() | No | 3 | 33 | Visualization | distribution | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,255 | plt.figure(figsize = (8,4))
sns.pointplot(x = 'Hour', y = 'casual', data = data, estimator = np.average, color = 'blue')
sns.pointplot(x = 'Hour', y = 'registered', data = data, estimator = np.average, color = 'red')
plt.ylabel('Registered')
plt.show() | No | 5 | 75 | Visualization | time_series | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,256 | #Histogram for Windspeed
sns.set_style('darkgrid')
sns.distplot(data['windspeed'], bins = 100, color = 'purple') #Windspeed cannot be 0.
plt.show() | No | 5 | 33 | Visualization | distribution | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,257 | #Replacing 0s in windspeed with the mean value grouped by season
data['windspeed'] = data['windspeed'].replace(0, np.nan)
data['windspeed'] = data['windspeed'].fillna(data.groupby('weather')['season'].transform('mean'))
sns.distplot(data['windspeed'], bins = 100, color = 'red')
plt.show() | Yes | 3 | 17 | Data_Transform | correct_missing_values | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing Checker", "fix": "Write unit tests for data processing and model components.", "benefits": "Ensures code reliability and prevents bugs.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Excepti... | A | no applicable ML-specific findings | [] | ["Exception Handling Checker", "Unit Testing Checker"] | 7 | A |
4,258 | #Encoding cyclical features
data['Month_sin'] = data['Month'].apply(lambda x: np.sin((2*np.pi*x)/12))
data['Month_cos'] = data['Month'].apply(lambda x: np.cos((2*np.pi*x)/12))
data['Hour_sin'] = data['Hour'].apply(lambda x: np.sin((2*np.pi*(x+1))/24))
data['Hour_cos'] = data['Hour'].apply(lambda x: np.cos((2*np.pi*(x+1... | No | 5 | 8 | Data_Transform | feature_engineering | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,259 | #trainsforming target variable using log transformation
data['count'] = np.log(data['count']) | No | 5 | 8 | Data_Transform | feature_engineering | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,260 | #Converting Categorical to numerical - Removing Co-Linearity
data_ = pd.get_dummies(data=data, columns=['season', 'holiday', 'workingday', 'weather'])
train_ = data_[pd.notnull(data_['count'])].sort_values(by=["datetime"])
test_ = data_[~pd.notnull(data_['count'])].sort_values(by=["datetime"])' | No | 4 | 9 | Data_Transform | sort_values | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,261 | #Standardizing numerical variables
from sklearn.preprocessing import StandardScaler
cols = ['temp','atemp','humidity', 'windspeed', 'Month_sin', 'Month_cos', 'Hour_sin', 'Hour_cos', 'DayOfWeek_sin','DayOfWeek_cos']
features = data[cols]
#Standard Scaler
scaler = StandardScaler().fit(features.values)
data[cols] = scale... | Yes | 5 | 18 | Data_Transform | normalization | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | 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... | E | Cross Validation Checker=low, Data Leakage Checker=high, Inconsistent scaling methods=high, No random seed setting detected=low, Pipeline Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Data Leakage Checker", "severity": "high"}, {"type": "Inconsistent scaling methods", "severity": "high"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Pipeline 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"] | 7 | E |
4,262 | from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from sklearn import metrics | No | 5 | 22 | Environment | import_modules | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,263 | #train test split
X = train_[cols]
y = train_['count']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=101) | Yes | 5 | 13 | Data_Transform | split | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | 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 |
4,264 | lm = LinearRegression()
lm.fit(X_train, y_train)
print(lm.intercept_) | Yes | 5 | 7 | Model_Train | train_model | 6,062,819 | 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"] | 7 | B |
4,265 | plt.figure(figsize = (18,4))
coeff = pd.DataFrame(lm.coef_, index = X.columns, columns = ['Coefficient'])
sns.barplot(x = coeff.index, y = 'Coefficient', data = coeff, color = 'red') | No | 5 | 79 | Visualization | model_coefficients | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,266 | plt.figure(figsize = (8,4))
pred = lm.predict(X_test)
sns.scatterplot(x = y_test, y = pred)
plt.xlabel('Count')
plt.ylabel('Predictions')
plt.show() | No | 5 | 56 | Visualization | plot_predictions | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing Checker", "fix": "Write unit tests for data processing and model components.", "benefits": "Ensures code reliability and prevents bugs.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Excepti... | A | no applicable ML-specific findings | [] | ["Exception Handling Checker", "Unit Testing Checker"] | 7 | A |
4,267 | sns.distplot((y_test-pred),bins=100, color = 'gray')
plt.show() | No | 4 | 33 | Visualization | distribution | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,268 | print('RMSLE:', np.sqrt(metrics.mean_squared_log_error(np.exp(y_test), np.exp(pred)))) | No | 5 | 49 | Model_Evaluation | compute_test_metric | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,269 | from sklearn.linear_model import Ridge
#Assiging different sets of alpha values to explore which can be the best fit for the model.
temp_msle = {}
for i in np.linspace(0, 40, 20):
ridge = Ridge(alpha= i, normalize=True)
#fit the model.
ridge.fit(X_train, y_train)
## Predicting the target value based o... | Yes | 5 | 2 | Hyperparam_Tuning | find_best_params | 6,062,819 | 1 | A | 0 | 1 | 1 | 0 | 0 | 8 | 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"] | 7 | B |
4,270 | from sklearn.linear_model import Lasso
## Assiging different sets of alpha values to explore which can be the best fit for the model.
temp_msle = {}
for i in np.logspace(-10, -1, 20):
## Assigin each model.
lasso = Lasso(alpha= i, normalize=True, tol = 0.1)
## fit the model.
lasso.fit(X_train, y_trai... | Yes | 5 | 2 | Hyperparam_Tuning | find_best_params | 6,062,819 | 1 | A | 0 | 1 | 1 | 0 | 0 | 8 | 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"] | 7 | B |
4,271 | from sklearn.ensemble import RandomForestRegressor
rfr = RandomForestRegressor(n_estimators = 500)
rfr.fit(X_train, y_train) | Yes | 5 | 7 | Model_Train | train_model | 6,062,819 | 3 | C | 2 | 0 | 0 | 0 | 10 | 3 | ok | 6 | 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, Randomness Control Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Randomness Control Checker", "severity": "low"}] | ["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 7 | C |
4,272 | plt.figure(figsize = (8,4))
pred = rfr.predict(X_test)
sns.scatterplot(x = y_test, y = pred)
plt.xlabel('Count')
plt.ylabel('Predictions')
plt.show() | No | 5 | 56 | Visualization | plot_predictions | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing Checker", "fix": "Write unit tests for data processing and model components.", "benefits": "Ensures code reliability and prevents bugs.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Excepti... | A | no applicable ML-specific findings | [] | ["Exception Handling Checker", "Unit Testing Checker"] | 7 | A |
4,273 | sns.distplot((y_test-pred),bins=100, color = 'gray') | No | 3 | 33 | Visualization | distribution | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,274 | #RMSLE
print('RMSLE:', np.sqrt(metrics.mean_squared_log_error(np.exp(y_test), np.exp(pred)))) | No | 5 | 49 | Model_Evaluation | compute_test_metric | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 7 | A |
4,275 | #submission
new = test_[cols]
pred = rfr.predict(new)
submission = pd.DataFrame({'datetime':test['datetime'],'count':np.exp(pred)})
submission['count'] = submission['count'].astype(int)
submission.to_csv('submission.csv',index=False) | Yes | 4 | 25 | Data_Export | save_to_csv | 6,062,819 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Unit Testing Checker", "fix": "Write unit tests for data processing and model components.", "benefits": "Ensures code reliability and prevents bugs.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Excepti... | A | no applicable ML-specific findings | [] | ["Exception Handling Checker", "Unit Testing Checker"] | 7 | A |
4,276 | b"import pandas as pd\nimport numpy as np\n\nimport matplotlib as mpl\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\n# \n%matplotlib inline\n\n# \nmpl.rcParams['axes.unicode_minus']=False\n\nimport warnings\nwarnings.filterwarnings('ignore')" | Yes | 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 |
4,277 | train=pd.read_csv("../input/bike-sharing-demand/train.csv", parse_dates=["datetime"])
train.shape
| Yes | 4 | 45 | Data_Extraction | load_from_csv | 6,108,853 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/bike-sharing-demand/train.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 6"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 5 | A |
4,278 | test=pd.read_csv("../input/bike-sharing-demand/test.csv", parse_dates=["datetime"])
test.shape | Yes | 4 | 45 | Data_Extraction | load_from_csv | 6,108,853 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/bike-sharing-demand/test.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 6"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 5 | A |
4,279 | train["year"]=train["datetime"].dt.year
train["month"]=train["datetime"].dt.month
train["day"]=train["datetime"].dt.day
train["hour"]=train["datetime"].dt.hour
train["minute"]=train["datetime"].dt.minute
train["second"]=train["datetime"].dt.second
train["dayofweek"]=train["datetime"].dt.dayofweek
train.shape | Yes | 5 | 8 | Data_Transform | feature_engineering | 6,108,853 | 1 | A | 0 | 0 | 0 | 0 | 0 | 8 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
4,280 | test["year"]=test["datetime"].dt.year
test["month"]=test["datetime"].dt.month
test["day"]=test["datetime"].dt.day
test["hour"]=test["datetime"].dt.hour
test["minute"]=test["datetime"].dt.minute
test["second"]=test["datetime"].dt.second
test["dayofweek"]=test["datetime"].dt.dayofweek
test.shape | Yes | 5 | 8 | Data_Transform | feature_engineering | 6,108,853 | 1 | A | 0 | 0 | 0 | 0 | 0 | 8 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
4,281 | # widspeed 0 . =>
fig, axes = plt.subplots(nrows=2)
fig.set_size_inches(18,10)
plt.sca(axes[0])
plt.xticks(rotation=30, ha='right')
axes[0].set(ylabel='Count',title="train windspeed")
sns.countplot(data=train, x="windspeed", ax=axes[0])
plt.sca(axes[1])
plt.xticks(rotation=30, ha='right')
axes[1].set(ylabel... | No | 5 | 33 | Visualization | distribution | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,283 | b"# 0 .\ntrainWind0 = train.loc[train['windspeed'] == 0]\ntrainWindNot0 = train.loc[train['windspeed'] != 0]\nprint(trainWind0.shape)\nprint(trainWindNot0.shape)" | Yes | 4 | 14 | Data_Transform | filter | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,284 | # .
from sklearn.ensemble import RandomForestClassifier
def predict_windspeed(data):
# 0 .
dataWind0 = data.loc[data['windspeed'] == 0]
dataWindNot0 = data.loc[data['windspeed'] != 0]
# .
wCol = ["season", "weather", "humidity", "month", "temp", "year", "atemp"]
# 0 ... | Yes | 2 | 7 | Model_Train | train_model | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
4,285 | # 0 .
train = predict_windspeed(train)
# test = predict_windspeed(test)
# widspeed 0
fig, ax1 = plt.subplots()
fig.set_size_inches(18,6)
plt.sca(ax1)
# 30
plt.xticks(rotation=30, ha='right')
ax1.set(ylabel='Count',title="train windspeed")
sns.countplot(data=train, x="windspeed", ax=ax1)' | Yes | 5 | 56 | Visualization | plot_predictions | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,286 | # feature feature
# feature = ["temp","humidity","windspeed","atemp"]
# feature type category . weather 1,2,3,4 2=> .
# feature one-hot-encodding .
categorical_feature_names = ["season","holiday","workingday","weather",
"dayofweek","month","year","hour"]
for var in categorica... | No | 5 | 16 | Data_Transform | data_type_conversions | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,287 | # dateset
X_train = train[feature_names]
print(X_train.shape)
X_train.head()' | Yes | 4 | 41 | Debug | show_table | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,288 | X_test = test[feature_names]
print(X_test.shape)
X_test.head() | Yes | 4 | 41 | Debug | show_table | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,289 | label_name = "count"
y_train = train[label_name]
print(y_train.shape)
y_train.head() | Yes | 4 | 41 | Debug | show_table | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,290 | from sklearn.metrics import make_scorer
def rmsle(predicted_values, actual_values):
# .
predicted_values = np.array(predicted_values)
actual_values = np.array(actual_values)
# 1 .
log_predict = np.log(predicted_values + 1)
log_actual = np.log(actual_values + 1)
# .
... | No | 3 | 49 | Model_Evaluation | compute_test_metric | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
4,291 | from sklearn.model_selection import KFold
from sklearn.model_selection import cross_val_score
k_fold = KFold(n_splits=10, shuffle=True, random_state=0) | Yes | 5 | 84 | Other | not_enough_vertices | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 0 | A |
4,292 | from sklearn.ensemble import RandomForestRegressor
max_depth_list = []
# n_estimators ;; 100
model = RandomForestRegressor(n_estimators=100,
n_jobs=-1,
random_state=0)
model
' | Yes | 5 | 4 | Model_Train | choose_model_class | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
4,293 | %time score = cross_val_score(model, X_train, y_train, cv=k_fold, scoring=rmsle_scorer)
score = score.mean()
# 0
print("Score= {0:.5f}".format(score))' | No | 4 | 28 | Model_Train | compute_train_metric | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,294 | # , ( ) -
model.fit(X_train, y_train)' | No | 5 | 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 |
4,295 | #
predictions = model.predict(X_test)
print(predictions.shape)
predictions[0:10]' | Yes | 4 | 48 | Model_Evaluation | predict_on_test | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,296 | # .
fig,(ax1,ax2)= plt.subplots(ncols=2)
fig.set_size_inches(12,5)
sns.distplot(y_train,ax=ax1,bins=50)
ax1.set(title="train")
sns.distplot(predictions,ax=ax2,bins=50)
ax2.set(title="test")' | No | 4 | 33 | Visualization | distribution | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,297 | submission = pd.read_csv("../input/bike-sharing-demand/sampleSubmission.csv")
submission
submission["count"] = predictions
print(submission.shape)
submission.head() | Yes | 3 | 45 | Data_Extraction | load_from_csv | 6,108,853 | 1 | A | 0 | 0 | 0 | 1 | 0 | 5 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/bike-sharing-demand/sampleSubmission.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 6"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 5 | A |
4,298 | submission.to_csv("Score_{0:.5f}_sampleSubmission.csv".format(score), index=False) | No | 5 | 25 | Data_Export | save_to_csv | 6,108,853 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
4,299 | #carregar os dados
train = pd.read_csv('/kaggle/input/bike-sharing-demand/train.csv')
teste = pd.read_csv('/kaggle/input/bike-sharing-demand/test.csv') | No | 5 | 45 | Data_Extraction | load_from_csv | 6,536,533 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | 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."] | 6 | A |
4,300 | #verificando df treino
train.info() | No | 5 | 40 | Debug | show_table_attributes | 6,536,533 | 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"}] | [] | 6 | B |
4,301 | #Verificando o df de teste
teste.info() | No | 5 | 40 | Debug | show_table_attributes | 6,536,533 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
4,302 | #Transformando o dataframe original na coluna count
#vamos usar escala logaritimica
train['count'] = np.log(train['count'])
| No | 5 | 8 | Data_Transform | feature_engineering | 6,536,533 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 6 | A |
4,303 | train = train.append(teste) | No | 3 | 11 | Data_Transform | concatenate | 6,536,533 | 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"}] | [] | 6 | B |
4,304 | 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 |
4,305 | train['datetime'] = pd.to_datetime(train['datetime']) | No | 5 | 16 | Data_Transform | data_type_conversions | 6,536,533 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 6 | A |
4,306 | #crindo nova coluna usando data e hora
train['year'] = train['datetime'].dt.year
train['month'] = train['datetime'].dt.month
train['day'] = train['datetime'].dt.day
train['hour'] = train['datetime'].dt.hour
train['dayofweek'] = train['datetime'].dt.dayofweek
| No | 5 | 16 | Data_Transform | data_type_conversions | 6,536,533 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 6 | A |
4,307 | #separando o df de treino e teste
#primeiro teste
teste = train[train['count'].isnull()] | No | 5 | 13 | Data_Transform | split | 6,536,533 | 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"] | 6 | B |
4,308 | teste.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 |
4,309 | #separando o df de treino e teste
#segundo treino
treino = train[~train['count'].isnull()] | No | 4 | 13 | Data_Transform | split | 6,536,533 | 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"] | 6 | B |
4,310 | treino.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 |
4,311 | #Separando o df de treino em treino/validao (def = 75/25)
from sklearn.model_selection import train_test_split
treino, validacao = train_test_split(treino, random_state=42)' | No | 5 | 13 | Data_Transform | split | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
4,312 | print(treino.shape)
treino.head() | Yes | 4 | 41 | Debug | show_table | 6,536,533 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
4,313 | print(validacao.shape)
validacao.head()
| Yes | 4 | 41 | Debug | show_table | 6,536,533 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
4,314 | #importando
from sklearn.tree import DecisionTreeRegressor | No | 5 | 22 | Environment | import_modules | 6,536,533 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
4,315 | #instanciando objeto de decision tree
ad = DecisionTreeRegressor(random_state=42) | No | 5 | 4 | Model_Train | choose_model_class | 6,536,533 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
4,316 | #treinando o modelo
#informar as colunas de entrada e a coluna de resposta (target)
ad.fit(treino[usadas], treino['count']) | No | 5 | 7 | Model_Train | train_model | 6,536,533 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 5 | 5 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Column Selection Checker", "Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 6 | B |
4,317 | #prever os dados de validao
previsao = ad.predict(validacao[usadas])' | No | 5 | 48 | Model_Evaluation | predict_on_test | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,318 | #usando a metrica para validar os dados
from sklearn.metrics import mean_squared_error | No | 5 | 22 | Environment | import_modules | 6,536,533 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
4,319 | #instanciar o modelo
rf = RandomForestRegressor(random_state=42, n_jobs=1) | No | 5 | 4 | Model_Train | choose_model_class | 6,536,533 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"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"}] | A | no applicable ML-specific findings | [] | ["Verbose Mode Checker"] | 6 | A |
4,320 | #treinando o modelo
rf.fit(treino[usadas], treino['count']) | No | 5 | 7 | Model_Train | train_model | 6,536,533 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 5 | 5 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Column Selection Checker", "Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 6 | B |
4,321 | #Fazendo previses em cima dos dados de validao
preds = rf.predict(validacao[usadas])' | No | 5 | 48 | Model_Evaluation | predict_on_test | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,322 | #verificando o modelo com relao a mtrica
#importando a mtrica
from sklearn.metrics import mean_squared_error' | No | 5 | 22 | Environment | import_modules | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
4,323 | b"#aplicando a mtrica\nmean_squared_error(validacao['count'], preds) ** (1/2)\n#0.348204 do professor" | 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 |
4,324 | #vamos prever com base nos dados de treino
# como o modelo se comporta prevendo em cima de dados conhecidos
# o modelo ja esta treinado
treino_preds = rf.predict(treino[usadas])
mean_squared_error(treino['count'], treino_preds) ** (1/2) | No | 4 | 49 | Model_Evaluation | compute_test_metric | 6,536,533 | 1 | A | 0 | 0 | 0 | 1 | 0 | 2 | 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": "Unit Testing... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Exception Handling Checker", "Unit Testing Checker"] | 6 | A |
4,325 | b"#Gerando as previses para envio ao Kaggle\nteste['count'] = np.exp(rf.predict(teste[usadas]))" | Yes | 5 | 48 | Model_Evaluation | predict_on_test | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,326 | #visualizando o arquivo para envio
teste[['datetime','count']].head() | No | 4 | 48 | Model_Evaluation | predict_on_test | 6,536,533 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
4,327 | #gerando csv
teste[['datetime','count']].to_csv('rf.csv', index=False) | No | 5 | 25 | Data_Export | save_to_csv | 6,536,533 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
4,328 | from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error | No | 5 | 22 | Environment | import_modules | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 0 | A |
4,329 | b"# importando as bases \ntreino = pd.read_csv('/kaggle/input/bike-sharing-demand/train.csv') # trino dados do dia 1 ao dia 19\nteste = pd.read_csv('/kaggle/input/bike-sharing-demand/test.csv') # base de teste do dia 20 ao final do ms" | 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 |
4,330 | treino.shape, teste.shape | No | 5 | 58 | Debug | show_shape | 6,602,052 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
4,331 | display(treino.info())
display(teste.info()) | No | 5 | 40 | Debug | show_table_attributes | 6,602,052 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
4,333 | b"# Aplicar log na varivel de resposta\ntreino['count'] = np.log(treino['count'])" | No | 5 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,334 | # Juntando os dataframes para realizar as modificaes
# As observaes do teste ficaram com o campo count nulo
# Concatenando as bases para realizar as transformaes nas duas bases de uma vez s
treino = treino.append(teste)' | No | 5 | 11 | Data_Transform | concatenate | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,335 | b"# transformando o tipo da varivel datetime em datetime\ntreino['datetime'] = pd.to_datetime(treino['datetime'])" | No | 5 | 16 | Data_Transform | data_type_conversions | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,336 | # Criando novas colunas com a dada e hora (feature engeneering)
treino['year'] = treino['datetime'].dt.year
treino['month'] = treino['datetime'].dt.month
treino['day'] = treino['datetime'].dt.day
treino['dayofweek'] = treino['datetime'].dt.dayofweek
treino['hour'] = treino['datetime'].dt.hour
| No | 5 | 8 | Data_Transform | feature_engineering | 6,602,052 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 5 | A |
4,337 | # separando so dataframes
teste = treino[treino['count'].isnull()] | No | 5 | 13 | Data_Transform | split | 6,602,052 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 5 | A |
4,338 | treino = treino[~treino['count'].isnull()] | No | 5 | 14 | Data_Transform | filter | 6,602,052 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 5 | A |
4,339 | treino, validacao = train_test_split(treino, random_state=42) | No | 5 | 13 | Data_Transform | split | 6,602,052 | 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"}] | [] | 5 | B |
4,340 | display(treino.info())
display(validacao.info()) | No | 5 | 40 | Debug | show_table_attributes | 6,602,052 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
4,341 | b"# selecionando as variveis que sero utilizadas no treinamento\nnao_usadas = ['casual', 'registered', 'count', 'datetime']\n\n# Xriar a lista das colunas de entrada\nusadas = [c for c in treino.columns if c not in nao_usadas]" | No | 2 | 14 | Data_Transform | filter | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,342 | # Instanciando o modelo
random_forest = RandomForestRegressor(random_state=42, n_jobs=-1) | No | 5 | 4 | Model_Train | choose_model_class | 6,602,052 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"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 7"}] | A | no applicable ML-specific findings | [] | ["Verbose Mode Checker"] | 5 | A |
4,343 | # Treinando o modelo
random_forest.fit(treino[usadas], treino['count']) | No | 5 | 7 | Model_Train | train_model | 6,602,052 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 5 | 5 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Column Selection Checker", "Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 5 | B |
4,344 | # Prevendo os resultados
previsao = random_forest.predict(validacao[usadas]) | No | 5 | 48 | Model_Evaluation | predict_on_test | 6,602,052 | 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": "Unit Testing... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Exception Handling Checker", "Unit Testing Checker"] | 5 | A |
4,345 | # Avaliando o modelo com o SRMSLE (Square Root Mean Squared Log Error)
mean_squared_error(validacao['count'], previsao)**(1/2) | No | 5 | 49 | Model_Evaluation | compute_test_metric | 6,602,052 | 1 | A | 0 | 0 | 0 | 1 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Column Selection Checker"] | 5 | A |
4,346 | b"# Vamos prever com base nos dados de treino\n# como o modelo se comporta prevendo em cima de dados conhecidos\n# Verificar se est generalizando bem, caso o erro seja zero na base de treino, um forte sinal de overfitting\n\ntreino_preds = random_forest.predict(treino[usadas])\nmean_squared_error(treino['count'], trei... | No | 4 | 27 | Model_Train | predict_on_train | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,347 | b"# Gerando as previses para envio ao Kaggle\n\nteste['count'] = np.exp(random_forest.predict(teste[usadas]))" | No | 5 | 48 | Model_Evaluation | predict_on_test | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
4,348 | # Gerando o arquivo para submeter ao kaggle
teste[['datetime', 'count']].head() | No | 5 | 41 | Debug | show_table | 6,602,052 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.