id
int64
0
7.95k
code_block
stringlengths
1
52.9k
too_long
stringclasses
2 values
marks
int64
1
5
graph_vertex_id
float64
1
88
graph_vertex_class
stringclasses
12 values
graph_vertex_subclass
stringclasses
70 values
kernel_id
float64
25.8k
14.7M
⌀
sqale_rating
float64
1
4
maintainability_rating
stringclasses
4 values
code_smells
int64
0
36
complexity
float64
0
15
⌀
cognitive_complexity
int64
0
33
bugs
int64
0
7
sqale_index
int64
0
125
ncloc
float64
0
101
⌀
mlscent_analysis_status
stringclasses
3 values
mlscent_smell_count
int64
0
31
mlscent_unique_smell_count
int64
0
12
mlscent_findings_json
stringlengths
2
7.76k
mlscent_ml_rating
stringclasses
5 values
mlscent_ml_rating_basis
stringclasses
52 values
mlscent_ml_findings_json
stringclasses
50 values
mlscent_ignored_findings_json
stringclasses
199 values
context_line_count
int64
0
33
combined_rating
stringclasses
5 values
3,718
df['month'] = df['datetime'].dt.month df.head()
No
4
8
Data_Transform
feature_engineering
2,165,156
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,719
df['week'] = df['datetime'].dt.week df.head()
No
5
8
Data_Transform
feature_engineering
2,165,156
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,720
df['hour'] = df['datetime'].dt.hour df.head()
No
4
8
Data_Transform
feature_engineering
2,165,156
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,721
df['year'] = df['datetime'].dt.year df.head()
No
4
8
Data_Transform
feature_engineering
2,165,156
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,722
df['day'] = df['datetime'].dt.day df.head()
No
4
8
Data_Transform
feature_engineering
2,165,156
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,723
df = df.drop(labels='datetime', axis=1) df.head()
No
4
10
Data_Transform
drop_column
2,165,156
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,724
fig, ax = plt.subplots(1, 2, figsize=(12, 4)) names = ['1', '2', '3', '4'] values = df['season'][df['year'] == 2011].value_counts() ax[0].bar(names, values) values = df['season'][df['year'] == 2012].value_counts() ax[1].bar(names, values) fig.suptitle('Seasons in 2011 & 2012');
No
5
33
Visualization
distribution
2,165,156
1
A
0
0
0
0
0
7
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,725
spring_2011 = int(df['season'][df['season'] == 1][df['year'] == 2011].value_counts()) summer_2011 = int(df['season'][df['season'] == 2][df['year'] == 2011].value_counts()) fall_2011 = int(df['season'][df['season'] == 3][df['year'] == 2011].value_counts()) winter_2011 = int(df['season'][df['season'] == 4][df['year'] == ...
No
5
72
EDA
count_values
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,726
fig, ax = plt.subplots(1, 2, figsize=(12, 4)) names = ['0', '1'] values = df['holiday'][df['year'] == 2011].value_counts() ax[0].bar(names, values) values = df['holiday'][df['year'] == 2012].value_counts() ax[1].bar(names, values) fig.suptitle('Holidays in 2011 & 2012');
No
5
33
Visualization
distribution
2,165,156
1
A
0
0
0
0
0
7
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,727
# metric to optimize from sklearn.metrics import mean_squared_error from sklearn.metrics import make_scorer scorer = make_scorer(lambda y_test, predictions: np.sqrt(mean_squared_error(y_test, predictions)))
Yes
5
84
Other
not_enough_vertices
null
1
A
0
0
0
0
0
3
ok
1
1
[{"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": ""}]
A
no applicable ML-specific findings
[]
["Unit Testing Checker"]
0
A
3,728
no_holiday_2011 = int(df['holiday'][df['holiday'] == 0][df['year'] == 2011].value_counts()) holiday_2011 = int(df['holiday'][df['holiday'] == 1][df['year'] == 2011].value_counts()) no_holiday_2012 = int(df['holiday'][df['holiday'] == 0][df['year'] == 2012].value_counts()) holiday_2012 = int(df['holiday'][df['holiday'] ...
No
5
72
EDA
count_values
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,729
training_set = pd.read_csv('../input/train.csv')
No
5
45
Data_Extraction
load_from_csv
1,813,404
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/train.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 10"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
9
A
3,730
training_set.head()
No
5
41
Debug
show_table
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,731
fig, ax = plt.subplots(1, 2, figsize=(12, 4)) names = ['0', '1'] values = df['workingday'][df['year'] == 2011].value_counts() ax[0].bar(names, values) values = df['workingday'][df['year'] == 2012].value_counts() ax[1].bar(names, values) fig.suptitle('Working day in 2011 & 2012');
No
4
33
Visualization
distribution
2,165,156
1
A
0
0
0
0
0
7
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,732
no_workingday_2011 = int(df['workingday'][df['workingday'] == 0][df['year'] == 2011].value_counts()) workingday_2011 = int(df['workingday'][df['workingday'] == 1][df['year'] == 2011].value_counts()) no_workingday_2012 = int(df['workingday'][df['workingday'] == 0][df['year'] == 2012].value_counts()) workingday_2012 = in...
No
5
72
EDA
count_values
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,733
fig, ax = plt.subplots(1, 2, figsize=(12, 4)) names_2011 = ['1', '2', '3'] names_2012 = ['1', '2', '3', '4'] values = df['weather'][df['year'] == 2011].value_counts() ax[0].bar(names_2011, values) values = df['weather'][df['year'] == 2012].value_counts() ax[1].bar(names_2012, values) fig.suptitle('Weather in 2011 &...
No
5
33
Visualization
distribution
2,165,156
1
A
0
0
0
0
0
8
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,734
weather_2011_1 = df['weather'][df['weather'] == 1][df['year'] == 2011].value_counts() weather_2011_2 = df['weather'][df['weather'] == 2][df['year'] == 2011].value_counts() weather_2011_3 = df['weather'][df['weather'] == 3][df['year'] == 2011].value_counts() weather_2012_1 = df['weather'][df['weather'] == 1][df['year']...
No
5
72
EDA
count_values
2,165,156
1
A
0
0
0
0
0
26
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,735
plt.hist(df['temp'][df['year'] == 2011], alpha=0.5, label='2011') plt.hist(df['temp'][df['year'] == 2012], alpha=0.5, label='2012') plt.legend(loc='upper right');
No
5
33
Visualization
distribution
2,165,156
1
A
0
0
0
0
0
3
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,736
training_set.plot(x = 'datetime', y = 'casual')
No
5
75
Visualization
time_series
1,813,404
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"}]
[]
9
B
3,737
training_set.plot(x = 'datetime', y = 'registered')
No
5
75
Visualization
time_series
1,813,404
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"}]
[]
9
B
3,738
plt.hist(df['atemp'][df['year'] == 2011], alpha=0.5, label='2011') plt.hist(df['atemp'][df['year'] == 2012], alpha=0.5, label='2012') plt.legend(loc='upper right');
No
5
33
Visualization
distribution
2,165,156
1
A
0
0
0
0
0
3
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,739
plt.hist(df['humidity'][df['year'] == 2011], alpha=0.5, label='2011') plt.hist(df['humidity'][df['year'] == 2012], alpha=0.5, label='2012') plt.legend(loc='upper right');
No
5
33
Visualization
distribution
2,165,156
1
A
0
0
0
0
0
3
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,740
plt.hist(df['windspeed'][df['year'] == 2011], alpha=0.5, label='2011') plt.hist(df['windspeed'][df['year'] == 2012], alpha=0.5, label='2012') plt.legend(loc='upper right');
No
5
33
Visualization
distribution
2,165,156
1
A
0
0
0
0
0
3
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,741
plt.hist(df['dow'][df['year'] == 2011], alpha=0.5, label='2011', bins=7) plt.hist(df['dow'][df['year'] == 2012], alpha=0.5, label='2012', bins=7) plt.legend(loc='upper right');
No
5
33
Visualization
distribution
2,165,156
1
A
0
0
0
0
0
3
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,742
plt.hist(df['month'][df['year'] == 2011], alpha=0.5, label='2011', bins=12) plt.hist(df['month'][df['year'] == 2012], alpha=0.5, label='2012', bins=12) plt.legend(loc='upper right');
No
5
75
Visualization
time_series
2,165,156
1
A
0
0
0
0
0
3
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,743
plt.hist(df['week'][df['year'] == 2011], alpha=0.5, label='2011', bins=52) plt.hist(df['week'][df['year'] == 2012], alpha=0.5, label='2012', bins=52) fig = plt.gcf() fig.set_size_inches(18.5, 10.5) plt.legend(loc='upper right');
No
5
33
Visualization
distribution
2,165,156
1
A
0
0
0
0
0
5
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,744
plt.hist(df['hour'][df['year'] == 2011], alpha=0.5, label='2011', bins=24) plt.hist(df['hour'][df['year'] == 2012], alpha=0.5, label='2012', bins=24) plt.legend(loc='upper right');
No
5
33
Visualization
distribution
2,165,156
1
A
0
0
0
0
0
3
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,745
plt.hist(df['day'][df['year'] == 2011], alpha=0.5, label='2011', bins=31) plt.hist(df['day'][df['year'] == 2012], alpha=0.5, label='2012', bins=31) fig = plt.gcf() fig.set_size_inches(18.5, 10.5) plt.legend(loc='upper right');
No
5
75
Visualization
time_series
2,165,156
1
A
0
0
0
0
0
5
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,746
names = ['2011', '2012'] values = df['year'].value_counts() plt.bar(names, values);
No
5
33
Visualization
distribution
2,165,156
1
A
0
0
0
0
0
3
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,747
count_2011 = df['year'][df['year'] == 2011].count() count_2012 = df['year'][df['year'] == 2012].count() print('2011: {}'.format(count_2011)) print('2012: {}'.format(count_2012))
No
5
72
EDA
count_values
2,165,156
1
A
0
0
0
0
0
4
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,748
cor_mat = df[:].corr() mask = np.array(cor_mat) mask[np.tril_indices_from(mask)] = False fig = plt.gcf() fig.set_size_inches(30,12) sns.heatmap(data=cor_mat, mask=mask, square=True, annot=True, cbar=True);
No
5
80
Visualization
heatmap
2,165,156
1
A
0
0
0
0
0
6
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
9
A
3,749
corr = training_set.corr() fig, ax = plt.subplots(figsize=(30, 30)) ax.matshow(corr) for (i, j), z in np.ndenumerate(corr): ax.text(j, i, '{:0.1f}'.format(z), ha='center', va='center', bbox=dict(boxstyle='round', facecolor='white', edgecolor='0.3')) plt.xticks(range(len(corr.columns)), corr.columns); ...
No
5
80
Visualization
heatmap
1,813,404
1
A
1
1
1
0
5
8
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"}]
[]
9
B
3,750
from sklearn.model_selection import train_test_split # Basic preprocessing which applies to all regression techniques (dependent variable: casual) data = training_set.drop(columns = ['datetime', 'atemp', 'registered', 'count']) X_train, X_test, y_train, y_test = train_test_split(data, data.casual, test_size=0.2, rand...
Yes
3
13
Data_Transform
split
1,813,404
1
A
0
0
0
0
0
5
ok
2
2
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name...
B
Cross Validation Checker=low, Cross-validation not detected=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}]
[]
9
B
3,751
# Preprocessing for linear regression from sklearn.preprocessing import OneHotEncoder from sklearn.preprocessing import MinMaxScaler scaler = MinMaxScaler() X_train_norm = scaler.fit_transform(X_train) X_test_norm = scaler.transform(X_test) one_hot = OneHotEncoder(categorical_features = [0, 1, 2, 3]) #season, holida...
Yes
4
20
Data_Transform
categorify
1,813,404
1
A
0
0
0
0
0
8
ok
13
9
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Pipeline Checker", "fix": "Use Pipelines for all scikit-learn estimators.", "benefits": "Prevents data leakage and ensures correct model evaluation.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross V...
D
Cross Validation Checker=low, Cross-validation not detected=low, Data Leakage Checker=high, No random seed setting detected=low, Pipeline Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "Data Leakage Checker", "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"]
9
D
3,752
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
3,753
from sklearn.model_selection import cross_val_score casual_model = Lasso() scores = cross_val_score(casual_model, X_train_norm, y_train, cv=5, scoring = scorer) scores
Yes
5
84
Other
not_enough_vertices
1,813,404
1
A
0
0
0
1
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"]
9
A
3,754
casual_model.fit(X_train_norm, y_train)
No
5
7
Model_Train
train_model
1,813,404
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"]
9
B
3,755
# Same thing for the second variable # Basic preprocessing which applies to all regression techniques (dependent variable: casual) data = training_set.drop(columns = ['datetime', 'atemp', 'casual', 'count']) X_train, X_test, y_train, y_test = train_test_split(data, data.registered, test_size=0.2, random_state = RANDOM...
Yes
4
13
Data_Transform
split
1,813,404
1
A
0
0
0
0
0
4
ok
2
2
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name...
B
Cross Validation Checker=low, Cross-validation not detected=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}]
[]
9
B
3,756
# Preprocessing for linear regression from sklearn.preprocessing import OneHotEncoder from sklearn.model_selection import train_test_split from sklearn.preprocessing import MinMaxScaler scaler = MinMaxScaler() X_train_norm = scaler.fit_transform(X_train) X_test_norm = scaler.transform(X_test) one_hot = OneHotEncoder...
Yes
4
20
Data_Transform
categorify
1,813,404
1
A
0
0
0
0
0
9
ok
13
9
[{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Pipeline Checker", "fix": "Use Pipelines for all scikit-learn estimators.", "benefits": "Prevents data leakage and ensures correct model evaluation.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross V...
D
Cross Validation Checker=low, Cross-validation not detected=low, Data Leakage Checker=high, No random seed setting detected=low, Pipeline Checker=low
[{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "Data Leakage Checker", "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"]
9
D
3,757
from sklearn.linear_model import Lasso from sklearn.model_selection import cross_val_score registered_model = Lasso() scores = cross_val_score(registered_model, X_train_norm, y_train, cv=5, scoring = scorer) scores
Yes
5
28
Model_Train
compute_train_metric
1,813,404
1
A
0
0
0
1
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"]
9
A
3,758
registered_model.fit(X_train_norm, y_train)
No
5
7
Model_Train
train_model
1,813,404
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"]
9
B
3,759
# Final prediction of the baseline models, as I am not going to tweak them, I will move directly to the test data test_dataset = pd.read_csv("../input/test.csv")
No
5
45
Data_Extraction
load_from_csv
1,813,404
1
A
0
0
0
0
0
1
ok
1
1
[{"detector": "general_ml", "framework": "General ML", "name": "Hardcoded file path detected: ../input/test.csv. Consider using configuration files or environment variables.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 12"}]
A
no applicable ML-specific findings
[]
["Hardcoded file path"]
9
A
3,760
test_data = test_dataset.drop(columns = ['datetime', 'atemp']) test_data = scaler.transform(test_data) test_data = one_hot.transform(test_data)
Yes
5
20
Data_Transform
categorify
1,813,404
1
A
0
0
0
0
0
3
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"]
9
B
3,761
casual = casual_model.predict(test_data) registered = registered_model.predict(test_data) total = casual + registered
No
4
48
Model_Evaluation
predict_on_test
null
1
A
0
0
0
0
0
3
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,762
test_dataset[test_dataset['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
3,763
test_dataset.loc[test_dataset['count'] < 0, 'count'] = 0
No
2
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
3,764
test_dataset[test_dataset['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
3,765
test_dataset[['datetime', 'count']].to_csv('result.csv', index = False)
No
4
25
Data_Export
save_to_csv
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,766
# Ignore the warnings import warnings warnings.filterwarnings('always') warnings.filterwarnings('ignore') # data visualisation and manipulation import numpy as np import pandas as pd import matplotlib.pyplot as plt from matplotlib import style import seaborn as sns import missingno as msno #configure # sets matplotli...
No
5
23
Environment
set_options
null
1
A
0
null
0
0
0
null
invalid_python
0
0
[]
null
invalid_python
[]
[]
0
null
3,767
train=pd.read_csv(r'../input/train.csv') test=pd.read_csv(r'../input/test.csv') df=train.copy() test_df=test.copy() df.head()
Yes
5
45
Data_Extraction
load_from_csv
null
1
A
0
0
0
0
0
5
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,768
df.columns.unique()
No
5
57
Debug
show_unique_values
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,769
df.isnull().sum()
No
5
39
EDA
count_missing_values
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,770
msno.matrix(df)
No
5
34
Visualization
missing_values
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,771
df.season.value_counts()
No
5
72
EDA
count_values
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,772
sns.factorplot(x='season',data=df,kind='count',size=5,aspect=1.5)
No
5
33
Visualization
distribution
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,773
df.holiday.value_counts() sns.factorplot(x='holiday',data=df,kind='count',size=5,aspect=1)
Yes
5
33
Visualization
distribution
2,200,876
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
3,774
df.workingday.value_counts() sns.factorplot(x='workingday',data=df,kind='count',size=5,aspect=1)
Yes
5
33
Visualization
distribution
2,200,876
1
A
0
0
0
0
0
2
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
3,775
# 1-> spring # 2-> summer # 3-> fall # 4-> winter sns.factorplot(x='weather',data=df,kind='count',size=5,aspect=1)
No
5
33
Visualization
distribution
2,200,876
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
3,776
sns.boxplot(data=df[['temp', 'atemp', 'humidity', 'windspeed', 'casual', 'registered', 'count']]) fig=plt.gcf() fig.set_size_inches(10,10)
No
5
33
Visualization
distribution
null
1
A
0
0
0
0
0
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,777
df.temp.unique() fig,axes=plt.subplots(2,2) axes[0,0].hist(x="temp",data=df,edgecolor="black",linewidth=2,color='#ff4125') axes[0,0].set_title("Variation of temp") axes[0,1].hist(x="atemp",data=df,edgecolor="black",linewidth=2,color='#ff4125') axes[0,1].set_title("Variation of atemp") axes[1,0].hist(x="windspeed",data=...
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
3,778
cor_mat= df[:].corr() mask = np.array(cor_mat) mask[np.tril_indices_from(mask)] = False fig=plt.gcf() fig.set_size_inches(30,12) sns.heatmap(data=cor_mat,mask=mask,square=True,annot=True,cbar=True)
No
5
80
Visualization
heatmap
null
1
A
0
0
0
0
0
6
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,779
season=pd.get_dummies(df['season'],prefix='season') df=pd.concat([df,season],axis=1) df.head() season=pd.get_dummies(test_df['season'],prefix='season') test_df=pd.concat([test_df,season],axis=1) test_df.head()
Yes
4
20
Data_Transform
categorify
2,200,876
1
A
0
0
0
0
0
6
ok
1
1
[{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Column Selection Checker"]
2
A
3,780
weather=pd.get_dummies(df['weather'],prefix='weather') df=pd.concat([df,weather],axis=1) df.head() weather=pd.get_dummies(test_df['weather'],prefix='weather') test_df=pd.concat([test_df,weather],axis=1) test_df.head()
Yes
4
20
Data_Transform
categorify
2,200,876
1
A
0
0
0
0
0
6
ok
1
1
[{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}]
A
no applicable ML-specific findings
[]
["Column Selection Checker"]
2
A
3,781
df.drop(['season','weather'],inplace=True,axis=1) df.head() test_df.drop(['season','weather'],inplace=True,axis=1) test_df.head()
Yes
4
10
Data_Transform
drop_column
2,200,876
1
A
0
0
0
0
0
4
ok
2
1
[{"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "Assign operations to a new DataFrame variable.", "benefits": "Prevents data loss and improves code clarity.", "location": "Line 3"}, {"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": "...
A
no applicable ML-specific findings
[]
["InPlace Checker"]
2
A
3,782
df["hour"] = [t.hour for t in pd.DatetimeIndex(df.datetime)] df["day"] = [t.dayofweek for t in pd.DatetimeIndex(df.datetime)] df["month"] = [t.month for t in pd.DatetimeIndex(df.datetime)] df['year'] = [t.year for t in pd.DatetimeIndex(df.datetime)] df['year'] = df['year'].map({2011:0, 2012:1}) df.head()'
Yes
4
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
3,783
test_df["hour"] = [t.hour for t in pd.DatetimeIndex(test_df.datetime)] test_df["day"] = [t.dayofweek for t in pd.DatetimeIndex(test_df.datetime)] test_df["month"] = [t.month for t in pd.DatetimeIndex(test_df.datetime)] test_df['year'] = [t.year for t in pd.DatetimeIndex(test_df.datetime)] test_df['year'] = test_df['yea...
Yes
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
3,784
df.drop('datetime',axis=1,inplace=True) df.head()
Yes
4
10
Data_Transform
drop_column
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,785
df.drop(['casual','registered'],axis=1,inplace=True) df.head()
Yes
4
10
Data_Transform
drop_column
null
1
A
0
0
0
0
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,786
sns.factorplot(x="hour",y="count",data=df,kind='bar',size=5,aspect=1.5)'
No
5
75
Visualization
time_series
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,787
sns.factorplot(x="month",y="count",data=df,kind='bar',size=5,aspect=1.5)'
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
3,788
sns.factorplot(x="year",y="count",data=df,kind='bar',size=5,aspect=1.5)'
No
5
75
Visualization
time_series
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,789
sns.factorplot(x="day",y='count',kind='bar',data=df,size=5,aspect=1)'
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
3,790
plt.scatter(x="temp",y="count",data=df,color='#ff4125')'
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
3,791
new_df=df.copy() new_df.temp.describe() new_df['temp_bin']=np.floor(new_df['temp'])//5 new_df['temp_bin'].unique() # now we can visualize as follows sns.factorplot(x="temp_bin",y="count",data=new_df,kind='bar')'
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
3,792
df.columns.to_series().groupby(df.dtypes).groups
No
3
40
Debug
show_table_attributes
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,793
x_train,x_test,y_train,y_test=train_test_split(df.drop('count',axis=1),df['count'],test_size=0.25,random_state=42)
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
3,794
models=[RandomForestRegressor(),AdaBoostRegressor(),BaggingRegressor(),SVR(),KNeighborsRegressor()] model_names=['RandomForestRegressor','AdaBoostRegressor','BaggingRegressor','SVR','KNeighborsRegressor'] rmsle=[] d={} for model in range (len(models)): clf=models[model] clf.fit(x_train,y_train) test_pred=cl...
Yes
3
7
Model_Train
train_model
null
1
A
0
1
1
1
0
11
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,795
rmsle_frame=pd.DataFrame(d) rmsle_frame
No
4
12
Data_Transform
create_dataframe
null
1
A
0
0
0
1
0
2
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,796
sns.factorplot(y='Modelling Algo',x='RMSLE',data=rmsle_frame,kind='bar',size=5,aspect=2)
No
4
33
Visualization
distribution
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,797
sns.factorplot(x='Modelling Algo',y='RMSLE',data=rmsle_frame,kind='point',size=5,aspect=2)
No
4
33
Visualization
distribution
null
1
A
0
0
0
0
0
1
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,798
no_of_test=[500] params_dict={'n_estimators':no_of_test,'n_jobs':[-1],'max_features':["auto",'sqrt','log2']} clf_rf=GridSearchCV(estimator=RandomForestRegressor(),param_grid=params_dict,scoring='neg_mean_squared_log_error') clf_rf.fit(x_train,y_train) pred=clf_rf.predict(x_test) print((np.sqrt(mean_squared_log_error(pr...
Yes
3
6
Hyperparam_Tuning
train_on_grid
null
1
A
0
null
0
0
0
null
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,799
clf_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
3,800
n_neighbors=[] for i in range (0,50,5): if(i!=0): n_neighbors.append(i) params_dict={'n_neighbors':n_neighbors,'n_jobs':[-1]} clf_knn=GridSearchCV(estimator=KNeighborsRegressor(),param_grid=params_dict,scoring='neg_mean_squared_log_error') clf_knn.fit(x_train,y_train) pred=clf_knn.predict(x_test) print((np....
Yes
4
6
Hyperparam_Tuning
train_on_grid
2,200,876
1
A
0
2
3
0
0
9
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
2
A
3,801
clf_knn.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
3,802
pred=clf_rf.predict(test_df.drop('datetime',axis=1)) d={'datetime':test['datetime'],'count':pred} ans=pd.DataFrame(d) ans.to_csv('answer.csv',index=False)
Yes
4
25
Data_Export
save_to_csv
null
1
A
0
0
0
0
0
4
no_ml_import
0
0
[]
null
no_ml_import
[]
[]
0
null
3,803
# train . train = pd.read_csv("../input/train.csv") # train . print(train.shape) # train 5 . train.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
3,804
# test test = pd.read_csv("../input/test.csv") # test . print(test.shape) # test 5 . test.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
3,805
# . # train["datetime"].dt.year # . # String . # Datetime . # datetime . train["datetime"] = pd.to_datetime(train["datetime"])'
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
3,806
# train . print(train.shape) # " " . train["datetime-year"] = train["datetime"].dt.year train["datetime-month"] = train["datetime"].dt.month train["datetime-day"] = train["datetime"].dt.day train["datetime-hour"] = train["datetime"].dt.hour train["datetime-minute"] = train["datetime"].dt.minute train["datet...
Yes
4
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
3,807
# test datetime Type String datetime . test["datetime"] = pd.to_datetime(test["datetime"])'
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
3,808
# train . print(test.shape) # datetime . test["datetime-year"] = test["datetime"].dt.year test["datetime-month"] = test["datetime"].dt.month test["datetime-day"] = test["datetime"].dt.day test["datetime-hour"] = test["datetime"].dt.hour test["datetime-minute"] = test["datetime"].dt.minute test["datetim...
Yes
4
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
3,809
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
3,810
sns.barplot(data=train, x="weather", y="count")
No
5
33
Visualization
distribution
2,719,562
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
3,811
sns.lmplot(data=train, x="temp", y="atemp")
No
5
33
Visualization
distribution
2,719,562
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
3,812
sns.distplot(train["windspeed"])
No
5
33
Visualization
distribution
2,719,562
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"]
3
A
3,813
sns.barplot(data=train, x="datetime-year", y="count")
No
5
75
Visualization
time_series
2,719,562
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
3,814
sns.barplot(data=train, x="datetime-month", y="count")
No
5
75
Visualization
time_series
2,719,562
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
3,815
sns.barplot(data=train, x="datetime-day", y="count")
No
5
75
Visualization
time_series
2,719,562
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
3,816
sns.barplot(data=train, x="datetime-hour", y="count")
No
5
75
Visualization
time_series
2,719,562
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A
3,817
sns.barplot(data=train, x="datetime-minute", y="count")
No
5
75
Visualization
time_series
2,719,562
1
A
0
0
0
0
0
1
ok
0
0
[]
A
no applicable ML-specific findings
[]
[]
3
A