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,852
train = pd.read_csv('../input/bike-sharing-demand/train.csv') test = pd.read_csv('../input/bike-sharing-demand/test.csv')
No
5
45
Data_Extraction
load_from_csv
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,853
tt = train.append(test) tt = tt.reset_index().drop('index', axis=1) tt.head()
Yes
3
11
Data_Transform
concatenate
13,074,892
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"}]
[]
6
B
4,854
sns.distplot(train['count'])
No
5
33
Visualization
distribution
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,855
# Time processing # Add two columns, date and hour respectively temp = pd.DatetimeIndex(train['datetime']) train['year'] = temp.year train['date'] = temp.date train['hour'] = temp.hour # Categorical variables for the day of the week train['dayofweek'] = pd.DatetimeIndex(train.date).dayofweek
No
5
8
Data_Transform
feature_engineering
13,074,892
1
A
0
0
0
0
0
5
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
6
A
4,856
# The impact of each time period of the day on count sns.boxplot(train['hour'], train['count'])
No
5
75
Visualization
time_series
13,074,892
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
6
A
4,857
# The influence of the total days of the week on count sns.boxplot(train['dayofweek'], train['count'])
No
5
75
Visualization
time_series
13,074,892
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
6
A
4,858
# Changes in count for each day of the week sns.pointplot(x='hour', y='count', hue='dayofweek', data=train)
No
5
75
Visualization
time_series
13,074,892
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
6
A
4,859
# The impact of different months on count train['month'] = pd.to_datetime(train['datetime']).dt.month sns.boxplot(train['month'], train['count'])
Yes
5
81
Visualization
relationship
13,074,892
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
6
A
4,860
# The impact of holidays on count sns.pointplot(x='hour', y='count',hue='workingday', data=train)
No
5
75
Visualization
time_series
13,074,892
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
6
A
4,861
# The impact of weather on count sns.pointplot(x='hour', y='count', hue='weather', data=train)
No
5
75
Visualization
time_series
13,074,892
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
6
A
4,862
# The influence of season on count sns.pointplot(x='hour', y='count', hue='season', data=train)
No
5
75
Visualization
time_series
13,074,892
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
6
A
4,863
# Pearson coefficient cor=train[['temp', 'atemp', 'casual', 'registered', 'humidity','windspeed', 'count']].corr() sns.heatmap(cor, square=True, annot=True)
No
5
80
Visualization
heatmap
13,074,892
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"}]
[]
6
B
4,864
temp = pd.DatetimeIndex(tt['datetime']) tt['year'] = temp.year tt['hour'] = temp.hour tt = tt[['hour', 'year', 'workingday', 'holiday', 'season', 'weather', 'atemp', 'count']] # One-hot coding for discrete variables, such as color red, yellow, and blue coding as [[1,0,0], [0,1,0], [0,0,1]] tt = pd.get_dummies(tt, colum...
Yes
3
20
Data_Transform
categorify
13,074,892
1
A
0
0
0
0
0
9
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
6
A
4,865
# Extract the training set and test set from the processed data set, [0:10886] and [10886:] new_train = tt.iloc[:10886, :] # Pair count+1, then take the logarithm y = np.log1p(new_train['count']) new_test = tt.iloc[10886:, :].drop('count',axis=1) new_train.drop('count', axis=1, inplace=True) x = new_train x.head()
Yes
5
10
Data_Transform
drop_column
13,074,892
1
A
0
0
0
0
0
6
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,866
from sklearn.model_selection import train_test_split from sklearn.metrics import mean_squared_error from sklearn.model_selection import cross_val_score x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.3, random_state=3)
Yes
5
13
Data_Transform
split
13,074,892
1
A
0
0
0
0
0
4
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,867
from sklearn.linear_model import LinearRegression lmodel = LinearRegression() lmodel.fit(x, y) cross_val_score(lmodel, x, y, cv=5).mean()
Yes
4
7
Model_Train
train_model
13,074,892
1
A
0
0
0
0
0
4
ok
5
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 9"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "...
A
no applicable ML-specific findings
[]
["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
6
A
4,868
lmodel.fit(x_train, y_train) pre = lmodel.predict(x_test) mean_squared_error(y_test, pre)
Yes
3
7
Model_Train
train_model
13,074,892
1
A
0
0
0
0
0
3
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"]
6
B
4,869
from sklearn.ensemble import RandomForestRegressor from sklearn.model_selection import GridSearchCV rfr = RandomForestRegressor(random_state=50, max_features='sqrt', oob_score=True)
Yes
5
4
Model_Train
choose_model_class
13,074,892
2
B
1
0
0
0
5
3
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 9"}]
A
no applicable ML-specific findings
[]
["Verbose Mode Checker"]
6
B
4,870
# Parameter tuning - This step requires a lot of calculation para = {'n_estimators': np.arange(200, 241, 1)} rf = GridSearchCV(estimator=rfr, param_grid=para, cv=5) rf.fit(x, y)
Yes
5
6
Hyperparam_Tuning
train_on_grid
13,074,892
1
A
0
0
0
0
0
3
ok
5
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 9"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "...
A
no applicable ML-specific findings
[]
["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
6
A
4,871
rf.best_params_
No
5
2
Hyperparam_Tuning
find_best_params
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,872
rfr = RandomForestRegressor(n_estimators=227, random_state=50, max_features='sqrt',oob_score=True) cross_val_score(rfr, x, y, cv=5).mean()
No
4
28
Model_Train
compute_train_metric
13,074,892
1
A
0
0
0
0
0
2
ok
4
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 7"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "...
A
no applicable ML-specific findings
[]
["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
6
A
4,873
rfr.fit(x_train, y_train) pre = rfr.predict(x_test) mean_squared_error(y_test, pre)
Yes
3
7
Model_Train
train_model
13,074,892
1
A
0
0
0
0
0
3
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"]
6
B
4,874
rfr.fit(x,y)
No
5
7
Model_Train
train_model
13,074,892
1
A
0
0
0
0
0
1
ok
4
4
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear...
B
Cross Validation Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}]
["Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"]
6
B
4,875
co = rfr.predict(new_test) m = [] # Decrease the result by one and round up for i in (np.exp(co) - 1): n = round(i) m.append(n) predict = pd.DataFrame({'datetime': test['datetime'], 'count': m}) predict.to_csv('rfr.csv', index=False)
Yes
4
25
Data_Export
save_to_csv
13,074,892
1
A
0
1
1
0
0
7
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"]
6
B
4,876
import numpy as np import pandas as pd import matplotlib.pyplot as plt from pandas.plotting import register_matplotlib_converters register_matplotlib_converters()
Yes
5
23
Environment
set_options
13,343,252
1
A
0
0
0
0
0
5
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
4
A
4,877
# Example # Converts to log1p(count) # Print original count back using expm1 print('Test log and exp') test_count = 100 print('original value', test_count) x = np.log1p(test_count) # log (x+1) print('log1p', x) print('expm1', np.expm1(x)) # exp(x) - 1
No
3
8
Data_Transform
feature_engineering
null
1
A
0
0
0
0
0
6
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,878
df = pd.read_csv('../input/bike-sharing-demand/train.csv',parse_dates=['datetime'],index_col=0) df_test = pd.read_csv('../input/bike-sharing-demand/test.csv',parse_dates=['datetime'],index_col=0)
No
5
45
Data_Extraction
load_from_csv
13,343,252
1
A
0
0
0
0
0
2
ok
4
3
[{"detector": "general_ml", "framework": "General ML", "name": "Data loading detected without size checks or batch processing. Consider using generators or batch processing for large datasets.", "fix": "Not specified", "benefits": "Not specified", "location": ""}, {"detector": "general_ml", "framework": "General ML", "...
A
no applicable ML-specific findings
[]
["Data loading detected without size checks or batch processing. Consider using generators or batch processing for large datasets.", "Hardcoded file path", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness."]
4
A
4,879
# We need to convert datetime to numeric for training. # Let's extract key features into separate numeric columns def add_features(df): df['year'] = df.index.year df['month'] = df.index.month df['day'] = df.index.day df['dayofweek'] = df.index.dayofweek df['hour'] = df.index.hour
No
5
8
Data_Transform
feature_engineering
null
1
A
0
1
0
0
0
6
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,880
# Need to predict the missing data plt.title('Rental Count - Gaps') df['2011-01':'2011-02']['count'].plot() plt.show()
No
5
81
Visualization
relationship
13,343,252
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"]
4
A
4,881
# Rentals change hourly! plt.plot(df['2011-01-01']['count']) plt.xticks(fontsize=14, rotation=45) plt.xlabel('Date') plt.ylabel('Rental Count') plt.title('Hourly Rentals for Jan 01, 2011') plt.show()
No
5
81
Visualization
relationship
13,343,252
1
A
0
0
0
0
0
6
ok
1
1
[{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Column Selection Checker"]
4
A
4,882
# Seasonal plt.plot(df['2011-01']['count']) plt.xticks(fontsize=14, rotation=45) plt.xlabel('Date') plt.ylabel('Rental Count') plt.title('Jan 2011 Rentals (1 month)') plt.show()
No
5
75
Visualization
time_series
13,343,252
1
A
0
0
0
0
0
6
ok
1
1
[{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Column Selection Checker"]
4
A
4,883
group_hour = df.groupby(['hour']) average_by_hour = group_hour['count'].mean()
Yes
5
60
Data_Transform
groupby
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,884
plt.plot(average_by_hour.index,average_by_hour) plt.xlabel('Hour') plt.ylabel('Rental Count') plt.xticks(np.arange(24)) plt.grid(True) plt.title('Average Hourly Rental Count')
No
5
75
Visualization
time_series
13,343,252
1
A
0
0
0
0
0
6
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
4
A
4,885
# Year to year trend plt.plot(df['2011']['count'],label='2011') plt.plot(df['2012']['count'],label='2012') plt.xticks(fontsize=14, rotation=45) plt.xlabel('Date') plt.ylabel('Rental Count') plt.title('2011 and 2012 Rentals (Year to Year)') plt.legend() plt.show()
No
5
75
Visualization
time_series
13,343,252
1
A
0
0
0
0
0
8
ok
1
1
[{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Column Selection Checker"]
4
A
4,886
plt.plot(df['2011']['count'].map(np.log1p),label='2011') plt.plot(df['2012']['count'].map(np.log1p),label='2012') plt.xticks(fontsize=14, rotation=45) plt.xlabel('Date') plt.ylabel('Log(Rental Count)') plt.title('2011 and 2012 Rentals (Year to Year)') plt.legend() plt.show()
No
5
75
Visualization
time_series
null
1
A
0
0
0
0
0
8
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,887
plt.boxplot([df['count']], labels=['count']) plt.title('Box Plot - Count') plt.ylabel('Target') plt.grid(True)
No
3
33
Visualization
distribution
null
1
A
0
0
0
0
0
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,888
# Let's see how the data distribution changes with log1p # Evenly distributed plt.boxplot([df['count'].map(np.log1p)], labels=['log1p(count)']) plt.title('Box Plot - log1p(Count)') plt.ylabel('Target') plt.grid(True)
No
3
33
Visualization
distribution
null
1
A
0
0
0
0
0
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,889
df["count"] = df["count"].map(np.log1p)
No
5
8
Data_Transform
feature_engineering
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,890
group_year_month = df.groupby(['year','month'])
No
5
60
Data_Transform
groupby
13,343,252
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
4
A
4,891
average_year_month = group_year_month['count'].mean()
No
2
8
Data_Transform
feature_engineering
13,343,252
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"]
4
A
4,892
average_year_month
No
5
41
Debug
show_table
13,343,252
1
A
0
0
0
1
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
4
A
4,893
for year in average_year_month.index.levels[0]: plt.plot(average_year_month[year].index,average_year_month[year],label=year) plt.legend() plt.xlabel('Month') plt.ylabel('Count') plt.grid(True) plt.title('Average Monthly Rental Count for 2011, 2012') plt.show()
No
4
75
Visualization
time_series
13,343,252
1
A
0
1
1
0
0
8
ok
1
1
[{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Column Selection Checker"]
4
A
4,894
group_year_hour = df.groupby(['year','hour']) average_year_hour = group_year_hour['count'].mean() for year in average_year_hour.index.levels[0]: #print (year) #print(average_year_month[year]) plt.plot(average_year_hour[year].index,average_year_hour[year],label=year) plt.legend() plt.xlabel('Hour') ...
Yes
4
75
Visualization
time_series
13,343,252
1
A
1
1
1
0
5
10
ok
1
1
[{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Column Selection Checker"]
4
A
4,895
group_workingday_hour = df.groupby(['workingday','hour']) average_workingday_hour = group_workingday_hour['count'].mean()
Yes
5
60
Data_Transform
groupby
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,896
for workingday in average_workingday_hour.index.levels[0]: #print (year) #print(average_year_month[year]) plt.plot(average_workingday_hour[workingday].index,average_workingday_hour[workingday], label=workingday) plt.legend() plt.xlabel('Hour') plt.ylabel('Count') plt.xticks(np.arange(2...
No
4
75
Visualization
time_series
13,343,252
1
A
1
1
1
0
5
10
ok
1
1
[{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Column Selection Checker"]
4
A
4,897
# Let's look at correlation beween features and target df.corr()['count']
No
5
40
Debug
show_table_attributes
13,343,252
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
4
A
4,898
# Any relation between temperature and rental count? plt.scatter(x=df.temp,y=df["count"]) plt.grid(True) plt.xlabel('Temperature') plt.ylabel('Count') plt.title('Temperature vs Count') plt.show()'
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,899
# Any relation between humidity and rental count? plt.scatter(x=df.humidity,y=df["count"],label='Humidity') plt.grid(True) plt.xlabel('Humidity') plt.ylabel('Count') plt.title('Humidity vs Count') plt.show()'
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,900
# Save all data df.to_csv('bike_all.csv',index=True,index_label='datetime',columns=columns)
No
5
25
Data_Export
save_to_csv
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,901
# Training = 70% of the data # Validation = 30% of the data # Randomize the datset np.random.seed(5) l = list(df.index) np.random.shuffle(l) df = df.loc[l]
No
5
15
Data_Transform
randomize_order
null
1
A
0
0
0
0
0
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,902
rows = df.shape[0] train = int(.7 * rows) test = rows-train
No
4
13
Data_Transform
split
null
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,903
rows, train, test
No
5
41
Debug
show_table
null
1
A
0
0
0
3
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,904
columns
No
5
71
Debug
show_columns
null
1
A
0
0
0
1
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,905
# Write Training Set df.iloc[:train].to_csv('bike_train.csv' ,index=False,header=False ,columns=columns)
No
5
25
Data_Export
save_to_csv
null
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,906
# Write Validation Set df.iloc[train:].to_csv('bike_validation.csv' ,index=False,header=False ,columns=columns)
No
5
25
Data_Export
save_to_csv
null
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,907
# Test Data has only input features df_test.to_csv('bike_test.csv',index=True,index_label='datetime')
No
5
25
Data_Export
save_to_csv
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,908
print(','.join(columns))
No
3
71
Debug
show_columns
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,909
# Write Column List with open('bike_train_column_list.txt','w') as f: f.write(','.join(columns))
No
5
84
Other
not_enough_vertices
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,910
# Install xgboost in notebook instance. #### Command to install xgboost !pip install xgboost==0.90
No
5
87
Environment
install_modules
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,911
import sys import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.metrics import mean_squared_error, mean_absolute_error # XGBoost import xgboost as xgb
No
5
22
Environment
import_modules
13,343,252
1
A
0
0
0
0
0
6
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
4
A
4,912
column_list_file = 'bike_train_column_list.txt' train_file = 'bike_train.csv' validation_file = 'bike_validation.csv' test_file = 'bike_test.csv'
No
5
77
Other
define_variables
null
1
A
0
0
0
0
0
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,913
columns = '' with open(column_list_file,'r') as f: columns = f.read().split(',')
No
5
88
Debug
list_files
null
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,914
# Specify the column names as the file does not have column header df_train = pd.read_csv(train_file,names=columns) df_validation = pd.read_csv(validation_file,names=columns)
No
5
45
Data_Extraction
load_from_csv
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,915
X_train = df_train.iloc[:,1:] # Features: 1st column onwards y_train = df_train.iloc[:,0].ravel() # Target: 0th column X_validation = df_validation.iloc[:,1:] y_validation = df_validation.iloc[:,0].ravel()
No
5
21
Data_Transform
prepare_x_and_y
null
1
A
0
0
0
0
0
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,916
# XGBoost Training Parameter Reference: # https://github.com/dmlc/xgboost/blob/master/doc/parameter.md #regressor = xgb.XGBRegressor(max_depth=5,eta=0.1,subsample=0.7,num_round=150) regressor = xgb.XGBRegressor(max_depth=5,n_estimators=150)
No
5
4
Model_Train
choose_model_class
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,917
regressor
No
2
4
Model_Train
choose_model_class
null
1
A
0
0
0
1
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,918
regressor.fit(X_train,y_train, eval_set = [(X_train, y_train), (X_validation, y_validation)])
No
5
7
Model_Train
train_model
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,919
eval_result = regressor.evals_result()
No
5
28
Model_Train
compute_train_metric
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,920
training_rounds = range(len(eval_result['validation_0']['rmse']))
No
3
77
Other
define_variables
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,921
plt.scatter(x=training_rounds,y=eval_result['validation_0']['rmse'],label='Training Error') plt.scatter(x=training_rounds,y=eval_result['validation_1']['rmse'],label='Validation Error') plt.grid(True) plt.xlabel('Iteration') plt.ylabel('RMSE') plt.title('Training Vs Validation Error') plt.legend() plt.show()
No
4
35
Visualization
learning_history
null
1
A
0
0
0
0
0
8
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,922
xgb.plot_importance(regressor) plt.show()
No
5
79
Visualization
model_coefficients
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,923
# Verify Quality using Validation dataset # Compare actual vs predicted performance with dataset not seen by the model before df = pd.read_csv(validation_file,names=columns)
No
5
45
Data_Extraction
load_from_csv
13,343,252
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
4
A
4,924
X_test = df.iloc[:,1:] print(X_test[:5])
Yes
4
13
Data_Transform
split
13,343,252
1
A
0
0
0
0
0
2
ok
1
1
[{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Column Selection Checker"]
4
A
4,925
result = regressor.predict(X_test)
No
5
48
Model_Evaluation
predict_on_test
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,926
result[:5]
No
4
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,927
df['count_predicted'] = result
No
5
8
Data_Transform
feature_engineering
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,928
# Negative Values are predicted df['count_predicted'].describe()
No
5
40
Debug
show_table_attributes
13,343,252
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"]
4
A
4,929
df[df['count_predicted'] < 0]
No
5
14
Data_Transform
filter
13,343,252
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"]
4
A
4,930
df['count_predicted'].hist() plt.title('Predicted Count Histogram') plt.show()
No
5
33
Visualization
distribution
13,343,252
1
A
0
0
0
0
0
3
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"]
4
A
4,931
def adjust_count(x): if x < 0: return 0 else: return x
No
3
8
Data_Transform
feature_engineering
null
1
A
0
2
2
0
0
5
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,932
df['count_predicted'] = df['count_predicted'].map(adjust_count)
No
3
8
Data_Transform
feature_engineering
13,343,252
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"]
4
A
4,933
df['count'] = df['count'].map(np.expm1) df['count_predicted'] = df['count_predicted'].map(np.expm1)
No
5
8
Data_Transform
feature_engineering
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,934
# Actual Vs Predicted plt.plot(df['count'], label='Actual') plt.plot(df['count_predicted'],label='Predicted') plt.xlabel('Sample') plt.ylabel('Count') plt.xlim([100,150]) plt.title('Validation Dataset - Predicted Vs. Actual') plt.legend() plt.show()
No
4
56
Visualization
plot_predictions
null
1
A
0
0
0
0
0
8
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,935
# Over prediction and Under Prediction needs to be balanced # Training Data Residuals residuals = (df['count'] - df['count_predicted']) plt.hist(residuals) plt.grid(True) plt.xlabel('Actual - Predicted') plt.ylabel('Count') plt.title('Residuals Distribution') plt.axvline(color='r') plt.show()
Yes
5
33
Visualization
distribution
null
1
A
0
0
0
0
0
8
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,936
print("RMSE: {0:0.2f}".format(mean_squared_error(df['count'],df['count_predicted'])**.5))'
No
5
49
Model_Evaluation
compute_test_metric
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,937
# RMSlE - Root Mean Squared Log Error # RMSLE Metric is used by Kaggle for this competition # RMSE Cost Function - Magnitude of difference matters # RMSLE cost function - "Only Percentage difference matters" # Reference:Katerina Malahova, Khor SoonHin # https://www.slideshare.net/KhorSoonHin/rmsle-cost-function def...
No
5
84
Other
not_enough_vertices
13,343,252
1
A
0
3
2
0
0
6
ok
3
2
[{"detector": "framework_specific", "framework": "NumPy", "name": "Array Creation Efficiency", "fix": "Specify dtype when creating arrays.", "benefits": "Improves memory efficiency and avoids unnecessary conversions.", "location": "Line 16"}, {"detector": "framework_specific", "framework": "NumPy", "name": "Array Creat...
A
no applicable ML-specific findings
[]
["Array Creation Efficiency", "Missing function docstring"]
4
A
4,938
print('RMSLE') print(compute_rmsle(100,50), compute_rmsle(1000,500), compute_rmsle(10000,5000))
No
2
49
Model_Evaluation
compute_test_metric
13,343,252
1
A
0
0
0
0
0
4
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
4
A
4,939
print('RMSLE') print(compute_rmsle(100,25), compute_rmsle(1000,250), compute_rmsle(10000,2500))
No
2
49
Model_Evaluation
compute_test_metric
13,343,252
1
A
0
0
0
0
0
4
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
4
A
4,940
print('RMSE') print(mean_squared_error([100],[50])**.5, mean_squared_error([1000],[500])**.5, mean_squared_error([10000],[5000])**.5)
No
2
49
Model_Evaluation
compute_test_metric
13,343,252
1
A
0
0
0
0
0
4
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
4
A
4,941
print('RMSE') print(mean_squared_error([100],[25])**.5, mean_squared_error([1000],[250])**.5, mean_squared_error([10000],[2500])**.5)
No
2
49
Model_Evaluation
compute_test_metric
13,343,252
1
A
0
0
0
0
0
4
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
4
A
4,942
print("RMSLE: {0}".format(compute_rmsle(df['count'],df['count_predicted'])))'
No
5
49
Model_Evaluation
compute_test_metric
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,943
# Prepare Data for Submission to Kaggle df_test = pd.read_csv(test_file,parse_dates=['datetime'])
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
4,944
X_test = df_test.iloc[:,1:] # Exclude datetime for prediction
No
4
13
Data_Transform
split
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,945
np.expm1(result)
No
4
8
Data_Transform
feature_engineering
13,343,252
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
4
A
4,946
# Convert result to actual count df_test["count"] = np.expm1(result)
No
5
8
Data_Transform
feature_engineering
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,947
df_test[df_test["count"] < 0]
No
5
14
Data_Transform
filter
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,948
df_test[['datetime','count']].to_csv('predicted_count_log.csv',index=False)
No
5
25
Data_Export
save_to_csv
13,343,252
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
4
A
4,949
submission.iloc[1258:1269, 1]= submission.iloc[1258:1269, 1]*0.5 submission.iloc[4492:4515, 1]= submission.iloc[4492:4515, 1]*0.5 # submission.iloc[6308:6330, 1]= submission.iloc[6308:6330, 1]*0.5 submission.iloc[3041:3063, 1]= submission.iloc[3041:3063, 1]*0.5 # submission.iloc[6332:6354, 1]= submission.iloc[6332:635...
No
5
14
Data_Transform
filter
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,950
submission.drop("holiday",1,inplace=True) submission.to_csv("allrf2.csv", index=False)
No
5
25
Data_Export
save_to_csv
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
4,951
import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline
No
5
23
Environment
set_options
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null