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,515 | %pylab inline
pylab.figure(figsize=(8, 3))
pylab.subplot(1,2,1)
pylab.grid(True)
pylab.xlim(-100,1100)
pylab.ylim(-100,1100)
pylab.scatter(train_labels, grid_cv.best_estimator_.predict(train_data), alpha=0.5, color = 'red')
pylab.scatter(test_labels, grid_cv.best_estimator_.predict(test_data), alpha=0.5, color = 'blue... | No | 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 |
3,516 | from sklearn.ensemble import GradientBoostingRegressor
gbr = GradientBoostingRegressor(n_estimators=200, learning_rate=0.9, max_depth = 4)
estimator = pipeline.Pipeline(steps = [
('feature_processing', pipeline.FeatureUnion(transformer_list = transformer_list)),
('model_fitting', gbr)
]
)
estimator... | Yes | 4 | 49 | Model_Evaluation | compute_test_metric | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
3,517 | %pylab inline
pylab.figure(figsize=(8, 3))
pylab.subplot(1,2,1)
pylab.grid(True)
pylab.xlim(-100,1100)
pylab.ylim(-100,1100)
pylab.scatter(train_labels, grid_cv.best_estimator_.predict(train_data), alpha=0.5, color = 'red')
pylab.scatter(test_labels, grid_cv.best_estimator_.predict(test_data), alpha=0.5, color = 'blue... | No | 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 |
3,518 | real_test_data = pd.read_csv("../input/test.csv")
real_test_data_ids = real_test_data["datetime"]
real_test_data.head() | No | 4 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,519 | real_test_data.datetime = real_test_data.datetime.apply(pd.to_datetime)
real_test_data['month'] = real_test_data.datetime.apply(lambda x : x.month)
real_test_data['hour'] = real_test_data.datetime.apply(lambda x : x.hour)
real_test_data.head() | No | 4 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,520 | real_test_data = real_test_data.drop(['datetime'], axis = 1) | No | 5 | 10 | Data_Transform | drop_column | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,521 | real_test_predictions = estimator.predict(real_test_data) | 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 |
3,522 | submission.to_csv('bike_predictions.csv', index=False) | No | 5 | 25 | Data_Export | save_to_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,523 | # This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load in
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O... | No | 5 | 88 | Debug | list_files | null | 1 | A | 0 | null | 0 | 0 | 0 | null | invalid_python | 0 | 0 | [] | null | invalid_python | [] | [] | 0 | null |
3,524 | # load train_set&test_set
train=pd.read_csv("../input/train.csv")
test=pd.read_csv("../input/test.csv")
test['casual']=0
test['registered']=0
test['count']=0
#remove Outlier piont
train = train[np.abs(train["count"]-train["count"].mean())<=(3*train["count"].std())] ' | 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,525 | #create a union data
union_data=pd.concat([train,test],ignore_index=True) | No | 5 | 11 | Data_Transform | concatenate | 604,509 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 8 | A |
3,526 | #add date columns
union_data['day']=pd.to_datetime(union_data.datetime).dt.day
union_data['year']=pd.to_datetime(union_data.datetime).dt.year
union_data['month']=pd.to_datetime(union_data.datetime).dt.month
union_data['weekday']=pd.to_datetime(union_data.datetime).dt.weekday
union_data['date']=pd.to_datetime(union_data... | Yes | 4 | 16 | Data_Transform | data_type_conversions | 604,509 | 1 | A | 0 | 1 | 0 | 0 | 0 | 10 | 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"] | 8 | A |
3,528 | #add day_type columns
union_data['day_type']=0
union_data['day_type'][(union_data['holiday']==0)& (union_data['workingday']==0)]='weekend'
union_data['day_type'][(union_data['holiday']==0)& (union_data['workingday']==1)]='workingday'
union_data['day_type'][(union_data['holiday']==1)]='holiday'
| No | 5 | 20 | Data_Transform | categorify | 604,509 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 4 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Chain Indexing", "fix": "Use single indexing or .loc[], .iloc[] methods.", "benefits": "Enhances code readability and prevents performance issues.", "location": "Line 11"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Chain Indexi... | A | no applicable ML-specific findings | [] | ["Chain Indexing", "Column Selection Checker"] | 8 | A |
3,529 | #create train set
train=union_data[:10739] | No | 4 | 13 | Data_Transform | split | 604,509 | 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"] | 8 | A |
3,530 | #windspeed counts
plt.figure(figsize=(100,5))
g=sns.factorplot(x='windspeed',y='count',data=train,col='year',kind='bar',estimator=sum,ci=None,size=10,aspect=1) | No | 5 | 33 | Visualization | distribution | 604,509 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 8 | A |
3,531 | #season trend
g=sns.factorplot(x='season',y='count',data=train,col='year',kind='bar',estimator=sum,ci=None,size=10,aspect=1) | No | 5 | 33 | Visualization | distribution | 604,509 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 8 | A |
3,532 | #month trend
g=sns.factorplot(x='month',y='count',data=train,col='year',kind='bar',estimator=sum,ci=None,size=10,aspect=1) | No | 5 | 75 | Visualization | time_series | 604,509 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 8 | A |
3,533 | #day trend
g=sns.factorplot(x='day',y='count',data=train,col='year',kind='bar',estimator=sum,ci=None,size=10,aspect=1) | No | 5 | 75 | Visualization | time_series | 604,509 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 8 | A |
3,534 | #weekday trend
g=sns.factorplot(x='weekday',y='count',data=train,col='year',kind='bar',estimator=sum,ci=None,size=10,aspect=1) | No | 5 | 75 | Visualization | time_series | 604,509 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 8 | A |
3,535 | #hour trend
g=sns.factorplot(x='hour',y='count',data=train,col='year',kind='bar',estimator=sum,ci=None,size=10,aspect=1) | No | 5 | 75 | Visualization | time_series | 604,509 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 8 | A |
3,536 | #weather analyse
g=sns.factorplot(x='weather',y='count',data=train,col='year',kind='bar',estimator=sum,ci=None,size=10,aspect=1) | No | 5 | 33 | Visualization | distribution | 604,509 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 8 | A |
3,537 | #workingday analyse
g=sns.factorplot(x='workingday',y='count',data=train,col='year',kind='bar',estimator=sum,ci=None,size=10,aspect=1) | No | 5 | 33 | Visualization | distribution | 604,509 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 8 | A |
3,538 | #tempture analyse
g=sns.factorplot(x='temp',y='count',data=train,col='year',kind='bar',estimator=sum,ci=None,size=10,aspect=1) | No | 5 | 33 | Visualization | distribution | 604,509 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 8 | A |
3,539 | from sklearn import tree
clf = tree.tree.DecisionTreeRegressor(max_depth=4,criterion='mse',min_samples_leaf=800)
clf = clf.fit(train['hour'].reshape(-1,1),np.ravel(train['count']))
import graphviz
dot_data = tree.export_graphviz(clf, out_file=None,feature_names=['hour'],
filled=True, ... | No | 3 | 7 | Model_Train | train_model | 604,509 | 1 | A | 1 | 0 | 0 | 1 | 5 | 9 | ok | 7 | 7 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Column Selection Checker", "Exception Handling Checker", "Unit Testing Checker", "Verbose Mode Checker"] | 8 | B |
3,540 | train_X.columns | No | 5 | 71 | Debug | show_columns | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,541 | regr = RandomForestRegressor(n_estimators=300)
regr.fit(train_X.loc[:,'year_month':], np.ravel(train_y))
reg=GradientBoostingRegressor(n_estimators=2000, learning_rate=0.01,max_depth=4)
reg.fit(train_X.loc[:,'year_month':], np.ravel(train_y))
| No | 5 | 7 | Model_Train | train_model | 604,509 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 12 | 8 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Validation Checker", "fix": "Implement cross-validation techniques for robust model evaluation.", "benefits": "Enhances model performance and reduces overfitting.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLear... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low, Randomness Control Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Randomness Control Checker", "severity": "low"}] | ["Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 8 | B |
3,542 | np.exp(regr.predict(test_X.loc[:,'year_month':]))-1
| No | 5 | 55 | Data_Export | prepare_output | 604,509 | 1 | A | 0 | 0 | 0 | 1 | 0 | 1 | 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"] | 8 | A |
3,543 | np.exp(reg.predict(test_X.loc[:,'year_month':]))-1 | No | 5 | 48 | Model_Evaluation | predict_on_test | 604,509 | 1 | A | 0 | 0 | 0 | 1 | 0 | 1 | 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"] | 8 | A |
3,544 | union_data['count'][10739:]=np.exp(reg.predict(test_X.loc[:,'year_month':]))-1 | No | 5 | 8 | Data_Transform | feature_engineering | 604,509 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 4 | 4 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Chain Indexing", "fix": "Use single indexing or .loc[], .iloc[] methods.", "benefits": "Enhances code readability and prevents performance issues.", "location": "Line 9"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Select... | A | no applicable ML-specific findings | [] | ["Chain Indexing", "Column Selection Checker", "Exception Handling Checker", "Unit Testing Checker"] | 8 | A |
3,545 | submission=pd.DataFrame({
"datetime": union_data[10739:].datetime,
"count": union_data[10739:]['count']
})
submission.to_csv('bike_predictions_gbm_separate_without_fe.csv', index=False)' | No | 5 | 25 | Data_Export | save_to_csv | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,546 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sn
from datetime import datetime
from scipy import stats | Yes | 4 | 22 | Environment | import_modules | 687,363 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
3,547 | trainData = pd.read_csv('../input/train.csv')
testData = pd.read_csv('../input/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 |
3,548 | trainData.head(2) | No | 5 | 41 | Debug | show_table | 687,363 | 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 |
3,549 | fig, axes = plt.subplots(figsize=(15, 4), ncols=2, nrows=1)
sn.distplot(trainData["count"],ax=axes[0])
plt.plot(pd.rolling_mean(trainData['count'], 100))
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 |
3,550 | trainData['logcount'] = trainData['count'].apply(lambda x: np.log1p(x))
fig, axes = plt.subplots(figsize=(15, 8))
sn.distplot(trainData["logcount"], ax=axes)' | 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,551 | trainData['date'] = trainData.datetime.apply(lambda x : x.split()[0])
trainData['hour'] = trainData.datetime.apply(lambda x : x.split()[1].split(":")[0])
trainData['weekday'] = trainData.date.apply(lambda dateString : datetime.strptime(dateString, '%Y-%m-%d').weekday())
trainData['month'] = trainData.date.apply(lambda ... | No | 5 | 8 | Data_Transform | feature_engineering | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,552 | import xgboost as xgb
X = trainData.drop(['count', 'datetime', 'registered', 'casual', 'date', 'logcount'], axis=1).values
Y = trainData['logcount'].values
testX = testData.drop(['datetime', 'date'], axis=1).values
trainMatrix = xgb.DMatrix(X, label=Y)
max_depth = 5
min_child_weight = 8
subsample = 0.9
num_estimato... | Yes | 2 | 25 | Data_Export | save_to_csv | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,553 | fig, axes = plt.subplots(nrows=1,ncols=2)
fig.set_size_inches(15, 8)
sn.boxplot(data=trainData, y='count', x='season', ax=axes[0])
sn.boxplot(data=trainData, y='count', x='workingday', ax=axes[1])
axes[0].set(xlabel='season', ylabel='count')
axes[1].set(xlabel='workingday', ylabel='count') | No | 5 | 33 | Visualization | distribution | 687,363 | 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"] | 6 | A |
3,554 | fix, axes = plt.subplots(figsize=(15, 10))
sn.boxplot(data=trainData, y='count', x='hour', ax=axes) | No | 5 | 75 | Visualization | time_series | 687,363 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
3,555 | corrMat = trainData.corr()
mask = np.array(corrMat)
mask[np.tril_indices_from(mask)] = False
fig, ax= plt.subplots(figsize=(20, 10))
sn.heatmap(corrMat, mask=mask,vmax=1., square=True,annot=True) | No | 5 | 80 | Visualization | heatmap | 687,363 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 3 | 3 | [{"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 8"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Sele... | B | Cross Validation Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}] | ["Array Creation Efficiency", "Column Selection Checker"] | 6 | B |
3,556 | fig, axes = plt.subplots(nrows=4, ncols=1, figsize=(15, 15))
meanMonthly = pd.DataFrame(trainData.groupby('month')['count'].mean()).reset_index().sort_values(by='count', ascending=False)
sn.barplot(data=meanMonthly, x='month', y='count', ax=axes[0])
axes[0].set(xlabel='month', ylabel='count')
hoursSeasonly = pd.DataF... | No | 5 | 75 | Visualization | time_series | 687,363 | 1 | A | 0 | 0 | 0 | 0 | 0 | 13 | ok | 4 | 4 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}] | ["Column Selection Checker"] | 6 | B |
3,557 | X = trainData.drop(['date', 'temp', 'casual', 'registered', 'logcount', 'datetime', 'count'], axis=1)
season_df = pd.get_dummies(trainData['season'], prefix='s', drop_first=True)
weather_df = pd.get_dummies(trainData['weather'], prefix='w', drop_first=True)
hour_df = pd.get_dummies(trainData['hour'], prefix='h', drop_... | Yes | 4 | 20 | Data_Transform | categorify | 687,363 | 1 | A | 0 | 0 | 0 | 0 | 0 | 27 | 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 |
3,558 | clf=xgb.XGBRegressor(max_depth=8,min_child_weight=6,gamma=0.4,colsample_bytree=0.6,subsample=0.6)
clf.fit(X,Y)
pred = clf.predict(testX)
pred = np.expm1(pred)
submission = pd.DataFrame({
"datetime": timeColumn,
"count": pred
})
submission.to_csv('XGBwithFE.csv', index=False)' | Yes | 4 | 25 | Data_Export | save_to_csv | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,559 | from sklearn.ensemble import GradientBoostingRegressor
from sklearn.model_selection import GridSearchCV
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import make_scorer
| No | 5 | 22 | Environment | import_modules | 687,363 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 6 | A |
3,560 | def loss_func(truth, prediction):
truth = np.expm1(truth)
prediction = np.expm1(prediction)
log1 = np.array([np.log(x + 1) for x in truth])
log2 = np.array([np.log(x + 1) for x in prediction])
return np.sqrt(np.mean((log1 - log2)**2)) | No | 5 | 84 | Other | not_enough_vertices | 687,363 | 1 | A | 0 | 1 | 0 | 0 | 0 | 6 | ok | 4 | 3 | [{"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 10"}, {"detector": "framework_specific", "framework": "NumPy", "name": "Array Creat... | C | Missing Axis Specification=medium | [{"type": "Missing Axis Specification", "severity": "medium"}] | ["Array Creation Efficiency", "Missing function docstring"] | 6 | C |
3,561 | b"param_grid = {\n 'n_estimators': [50, 80, 100, 120],\n 'max_depth': [None, 1, 2, 5],\n 'max_features': ['sqrt', 'log2', 'auto']\n}\n\nscorer = make_scorer(loss_func, greater_is_better=False)\n\nregr = RandomForestRegressor(random_state=42)\n\nrfr = GridSearchCV(regr, param_grid, cv=4, scoring=scorer, n_jobs=... | No | 4 | 2 | Hyperparam_Tuning | find_best_params | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,562 | pred = rfr.predict(testX)
pred = np.expm1(pred)
submission = pd.DataFrame({
"datetime": timeColumn,
"count": pred
})
submission.to_csv('RandomForest.csv', index=False)' | 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 |
3,563 | b"#\n#param_grid = {\n# 'learning_rate': [0.1, 0.01, 0.001, 0.0001],\n# 'n_estimators': [100, 1000, 1500, 2000, 4000],\n# 'max_depth': [1, 2, 3, 4, 5, 8, 10]\n#}\n#\n#scorer = make_scorer(loss_func, greater_is_better=False)\n#\n#gb = GradientBoostingRegressor(random_state=42)\n#\n#gbr = GridSearchCV(gb, param_... | No | 5 | 7 | Model_Train | train_model | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,564 | pred = gbr.predict(testX)
pred = np.expm1(pred)
submission = pd.DataFrame({
"datetime": timeColumn,
"count": pred
})
submission.to_csv('GradientBoost.csv', index=False)' | 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 |
3,565 | df = pd.read_csv('../input/train.csv')
df.head() | No | 4 | 45 | Data_Extraction | load_from_csv | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,566 | def null_percentage(column):
df_name = column.name
nans = np.count_nonzero(column.isnull().values)
total = column.size
frac = nans / total
perc = int(frac * 100)
print('%d%% of values or %d missing from %s column.' % (perc, nans, df_name))
def check_null(df, columns):
for col in columns:
... | No | 5 | 39 | EDA | count_missing_values | null | 1 | A | 0 | 3 | 1 | 0 | 0 | 11 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,567 | def process_features(df):
# Get month, day of month, and time of day.
months = ['January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December']
df['month'] = df.datetime.apply(lambda x: months[int(x[5:7]) - 1])
df['day'] = df.... | 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,568 | df = process_features(pd.read_csv('../input/train.csv')) | No | 4 | 45 | Data_Extraction | load_from_csv | 883,641 | 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 6"}] | A | no applicable ML-specific findings | [] | ["Hardcoded file path"] | 5 | A |
3,569 | #Ridership by Month
plt.figure('Daily rides by Day of Week', figsize=(10, 26))
plt.suptitle('Daily Rides by Day of Week', fontsize=20)
plt.subplot(311)
sns.boxplot(x='day_of_week', y='count', data=df)
plt.title('All Riders', fontsize=16)
plt.subplot(312)
sns.boxplot(x='day_of_week', y='casual', data=df)
plt.title('Ca... | No | 5 | 75 | Visualization | time_series | 883,641 | 1 | A | 0 | 0 | 0 | 0 | 0 | 12 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
3,570 | #Ridership by Season
plt.figure('Daily rides by Season', figsize=(10, 20))
plt.suptitle('Daily Rides by Season', fontsize=20)
plt.subplot(311)
sns.boxplot(x='real_seasons', y='count', hue='weekend', data=df)
plt.title('All Riders', fontsize=16)
plt.subplot(312)
sns.boxplot(x='real_seasons', y='casual', hue='weekend',... | No | 5 | 33 | Visualization | distribution | 883,641 | 1 | A | 0 | 0 | 0 | 0 | 0 | 12 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
3,571 | #Ridership by Season
plt.figure('Daily rides by Month', figsize=(10, 20))
plt.suptitle('Daily Rides by Month', fontsize=20)
plt.subplot(311)
sns.boxplot(x='month', y='count', hue='weekend', data=df)
plt.title('All Riders', fontsize=16)
plt.subplot(312)
sns.boxplot(x='month', y='casual', hue='weekend', data=df)
plt.ti... | No | 5 | 75 | Visualization | time_series | 883,641 | 1 | A | 0 | 0 | 0 | 0 | 0 | 12 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
3,572 | plt.figure('Wind by month')
sns.boxplot(x='month', y='windspeed', data=df)
plt.title('Windspeed by Month', fontsize=20)
plt.show() | No | 5 | 75 | Visualization | time_series | 883,641 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
3,573 | df.weather.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,574 | plt.figure('Weather and Ridership', figsize=(10, 20))
plt.suptitle('Weather and Ridership', fontsize=20)
plt.subplot(311)
sns.boxplot(x='weather', y='count', data=df)
plt.title('All Riders', fontsize=14)
plt.subplot(312)
sns.boxplot(x='weather', y='casual', data=df)
plt.title('Casual Riders', fontsize=14)
plt.subplot(3... | Yes | 5 | 33 | Visualization | distribution | 883,641 | 1 | A | 0 | 0 | 0 | 0 | 0 | 12 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
3,575 | def corr_heatmap(df, title):
plt.figure('heatmap', figsize=(15,15))
plt.suptitle(plt.title(title, fontsize=30))
df_corr = df.corr()
sns.heatmap(df_corr, vmax=0.6, square=True, annot=False, cmap='Blues')
plt.yticks(rotation = 0)
plt.xticks(rotation = 90)
plt.show()
corr_heatmap(pd.get_du... | No | 5 | 80 | Visualization | heatmap | 883,641 | 1 | A | 0 | 1 | 0 | 0 | 0 | 9 | ok | 1 | 1 | [{"detector": "general_ml", "framework": "General ML", "name": "Missing docstring for function: corr_heatmap. Consider adding documentation for parameters and return values.", "fix": "Not specified", "benefits": "Not specified", "location": "Line 6"}] | A | no applicable ML-specific findings | [] | ["Missing function docstring"] | 5 | A |
3,576 | import pandas as pd
df = process_features(pd.read_csv('../input/train.csv'))
df_submit = process_features(pd.read_csv('../input/test.csv'))
def clean_weather(df):
df.loc[df['weather'] == 4, 'weather'] = 3
return df
df = clean_weather(df)
df_test = clean_weather(df_submit) | Yes | 4 | 45 | Data_Extraction | load_from_csv | 883,641 | 1 | A | 0 | 1 | 0 | 0 | 0 | 8 | ok | 5 | 4 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "general_ml", "framework": "General ML", "name": "Magic number detected... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Hardcoded file path", "Magic number", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness."] | 5 | A |
3,577 | remove_columns = ['season',
#'holiday',
'workingday',
#'weather',
#'temp',
'atemp',
#'humidity',
'windspeed',
#'month',
'day',
#'hou... | No | 5 | 77 | Other | define_variables | 883,641 | 1 | A | 2 | 0 | 0 | 0 | 10 | 8 | ok | 0 | 0 | [] | A | no applicable ML-specific findings | [] | [] | 5 | A |
3,578 | # Strip unwanted features
df_train = df.drop(remove_columns, axis=1)
df_targets = df_train[target_labels]
df_train = df_train.drop(target_labels, axis=1)
df_submit = df_test.drop(remove_columns, axis=1)
print(df_train.columns)
print(df_submit.columns)
df_train = pd.get_dummies(df_train)
df_submit = pd.get_dummies(df... | Yes | 3 | 13 | Data_Transform | split | 883,641 | 1 | A | 1 | 0 | 0 | 0 | 5 | 18 | ok | 15 | 12 | [{"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 26"}, {"detector": "framework_specific", "framework": "NumPy", "name": "Array Creat... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low, Pipeline Checker=low, Randomness Control Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Pipeline Checker", "severity": "low"}, {"type": "Randomness Control Checker", "severity": "low"}] | ["Array Creation Efficiency", "Column Selection Checker", "Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Potential data leakage: Preprocessing applied before train-test split (module-level code)", "Unit Testing Chec... | 5 | B |
3,579 | print(X_train.shape)
print(y_train.shape) | No | 5 | 58 | Debug | show_shape | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,580 | def rmsle(y_true,y_pred):
assert len(y_true) == len(y_pred)
return np.square(np.log(y_pred + 1) - np.log(y_true + 1)).mean() ** 0.5 | No | 5 | 84 | Other | not_enough_vertices | 883,641 | 1 | A | 0 | 1 | 0 | 0 | 0 | 3 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "NumPy", "name": "Missing Axis Specification", "fix": "Specify axis in array operations.", "benefits": "Improves performance and avoids unexpected behaviour.", "location": "Line 8"}] | C | Missing Axis Specification=medium | [{"type": "Missing Axis Specification", "severity": "medium"}] | [] | 5 | C |
3,581 | from sklearn.ensemble import RandomForestRegressor
rf = RandomForestRegressor(n_estimators=5, n_jobs=-1)
rf.fit(X_train, y_train)
y_pred = rf.predict(X_test)
y_pred[y_pred < 0] = 1
print('RMSLE of predicting total count: %.4f' % rmsle(y_test[:,2], y_pred[:,2]))
print('RMSLE combining casual and registered predictions:... | No | 4 | 49 | Model_Evaluation | compute_test_metric | 883,641 | 1 | A | 2 | 0 | 0 | 0 | 10 | 7 | ok | 11 | 9 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low, Randomness Control Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Randomness Control Checker", "severity": "low"}] | ["Column Selection Checker", "Exception Handling Checker", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker", "Verbose Mode Checker"] | 5 | B |
3,582 | b"count0 = 0\ncount1 = 0\nfor (a,b) in zip(np.sum(y_pred[:,0:2].astype(int), axis=1), y_pred[:,2].astype(int)):\n #print(a, b)\n if abs(a - b) == 0:\n count0 +=1\n if abs(a - b) <= 1:\n count1 +=1\nprint('Exact: %d' % count0)\nprint('Within one: %d ' % count1)\nprint('Total: %d ' % y_pred.shape[0... | No | 5 | 53 | Other | something_strange | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 0 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,583 | import lightgbm as lgb
X_t, X_e, y_t, y_e = train_test_split(X_train, y_train[:,2], test_size=0.15)
print(y_t.shape)
print(y_e.shape)
lgb_train = lgb.Dataset(X_t, y_t)
lgb_eval = lgb.Dataset(X_e, y_e, reference=lgb_train)
params = {
'objective': 'regression',
'metric': 'l2_root',
'num_leaves': 43,
'max... | Yes | 3 | 49 | Model_Evaluation | compute_test_metric | 883,641 | 1 | A | 0 | 0 | 0 | 0 | 0 | 21 | ok | 7 | 7 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Cross Valida... | B | Cross Validation Checker=low, Cross-validation not detected=low, No random seed setting detected=low, Randomness Control Checker=low | [{"type": "Cross Validation Checker", "severity": "low"}, {"type": "Cross-validation not detected", "severity": "low"}, {"type": "No random seed setting detected", "severity": "low"}, {"type": "Randomness Control Checker", "severity": "low"}] | ["Column Selection Checker", "Exception Handling Checker", "Unit Testing Checker"] | 5 | B |
3,584 | submission = pd.read_csv('../input/sampleSubmission.csv')
submission['count'] = np.array(rf.predict(df_submit))[:,2]
print(submission.head())
submission.to_csv('submission.csv', index=False) | No | 3 | 25 | Data_Export | save_to_csv | 883,641 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 6 | 6 | [{"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 7"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Sele... | A | no applicable ML-specific findings | [] | ["Array Creation Efficiency", "Column Selection Checker", "Exception Handling Checker", "Hardcoded file path", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness.", "Unit Testing Checker"] | 5 | A |
3,585 | # This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load in
import numpy as np# linear algebra
import pandas as pd # data processing, CSV file I/O ... | No | 5 | 22 | Environment | import_modules | 1,264,566 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker"] | 12 | A |
3,586 | df=pd.read_csv("../input/train.csv")
df.head()
print (df.shape)
testdf=pd.read_csv("../input/test.csv")
print (testdf.shape)
testdf.head() | No | 4 | 45 | Data_Extraction | load_from_csv | 1,264,566 | 1 | A | 0 | 0 | 0 | 0 | 0 | 6 | ok | 4 | 3 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}, {"detector": "general_ml", "framework": "Genera... | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker", "Hardcoded file path", "No error handling detected in data processing. Consider adding try-except blocks or validation checks for robustness."] | 12 | A |
3,587 | def missingvalues(df):
miss=df.isnull().sum()
misspercent=100*df.isnull().sum()/len(df)
misvaltable=pd.concat([miss,misspercent],axis=1)
misvaltable=misvaltable.rename(columns={0:"missing values",1:"missing percent"})
return misvaltable
df.dtypes.value_counts()
| No | 4 | 37 | EDA | count_data_types | 1,264,566 | 1 | A | 0 | 1 | 0 | 0 | 0 | 7 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}, {"detector": "general_ml", "framework": "Genera... | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker", "Missing function docstring"] | 12 | A |
3,588 | categoryweather=df.groupby("holiday").nunique()
print(categoryweather)
df1=pd.get_dummies(df['weather'])
df1.head()' | No | 3 | 20 | Data_Transform | categorify | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,589 | import matplotlib.pyplot as plt
df.head() | No | 4 | 41 | Debug | show_table | 1,264,566 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker"] | 12 | A |
3,590 | plt.figure(figsize=(20,20))
plt.subplot(4,2,1)
plt.hist(df["season"])
plt.xlabel("season")
plt.ylabel("count")
plt.subplot(4,2,2)
plt.hist(df["holiday"])
plt.xlabel("holiday")
plt.ylabel("count")
plt.subplot(4,2,3)
plt.hist(df["workingday"])
plt.xlabel("workingday")
plt.ylabel("count")
plt.subplot(4,2,4)
plt.hist(df["w... | No | 5 | 33 | Visualization | distribution | 1,264,566 | 1 | A | 0 | 0 | 0 | 0 | 0 | 34 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Th... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Dependent Threshold Checker"] | 12 | A |
3,591 | testdf.columns | No | 5 | 71 | Debug | show_columns | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,592 | l=[ 'season', 'holiday', 'workingday', 'weather', 'temp',
'atemp', 'humidity', 'windspeed']
dftarget=df[["casual","registered","count"]].copy()
dftarget.head()
' | No | 4 | 21 | Data_Transform | prepare_x_and_y | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,593 | dfnew=df.copy()
dfnew.drop(["registered","casual","count"],axis=1,inplace=True)
dfnew.head() | No | 4 | 10 | Data_Transform | drop_column | 1,264,566 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 2 | 2 | [{"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 14"}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold ... | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker", "InPlace Checker"] | 12 | A |
3,594 | import matplotlib.pyplot as plt
df2=pd.concat([dfnew,testdf])
print(df2.shape)
print(df.shape) | No | 4 | 11 | Data_Transform | concatenate | 1,264,566 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker"] | 12 | A |
3,595 | import matplotlib.pyplot as plt1
plt1.figure(figsize=(20,20))
plt1.subplot(4,2,1)
plt1.hist(df2["season"])
plt1.xlabel("season")
plt1.ylabel("count")
plt1.subplot(4,2,2)
plt1.hist(df2["holiday"])
plt1.xlabel("holiday")
plt1.ylabel("count")
plt1.subplot(4,2,3)
plt1.hist(df2["workingday"])
plt1.xlabel("workingday")
plt1.... | No | 5 | 33 | Visualization | distribution | 1,264,566 | 1 | A | 0 | 0 | 0 | 0 | 0 | 35 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Th... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Dependent Threshold Checker"] | 12 | A |
3,596 | df=pd.read_csv("../input/train.csv")
df1=pd.get_dummies(df['weather'])
df1=df1.rename(columns={1:"clear",2:"misty",3:"snow",4:"heavy snow"})
df=df.drop(["weather"],axis=1)
df=pd.concat([df,df1],axis=1)
df.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,597 | df1=pd.get_dummies(df2["weather"])
df2.drop(["weather"],axis=1,inplace=True)
df2=pd.concat([df2,df1],axis=1)
df2.head()
| Yes | 4 | 10 | Data_Transform | drop_column | 1,264,566 | 1 | A | 0 | 0 | 0 | 0 | 0 | 4 | ok | 3 | 3 | [{"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 14"}, {"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker"... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Dependent Threshold Checker", "InPlace Checker"] | 12 | A |
3,598 | #df2=df2.drop(["weather"],axis=1)
df2=df2.rename(columns={1:"clear",2:"misty",3:"snow",4:"heavy snow"})
df2.head() | No | 4 | 61 | Data_Transform | rename_columns | 1,264,566 | 2 | B | 1 | 0 | 0 | 0 | 5 | 2 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker"] | 12 | B |
3,599 | df1=pd.get_dummies(df2["season"])
#df2=df2.drop(["season"],axis=1,inplace=True)
#df1.head()
df3=pd.concat([df2,df1],axis=1)
#df2.head()
df3=df3.rename(columns={1:"spring",2:"summer",3:"fall",4:"winter"})
df3.head() | Yes | 4 | 11 | Data_Transform | concatenate | 1,264,566 | 1 | A | 1 | 0 | 0 | 0 | 5 | 4 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Th... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Dependent Threshold Checker"] | 12 | A |
3,600 | df3.shape | No | 5 | 58 | Debug | show_shape | null | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,601 | df.shape
df0=pd.get_dummies(df["season"])
df4=pd.concat([df,df0],axis=1)
df4=df4.rename(columns={1:"spring",2:"summer",3:"fall",4:"winter"})
df4.head() | Yes | 4 | 11 | Data_Transform | concatenate | 1,264,566 | 1 | A | 0 | 0 | 0 | 0 | 0 | 5 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Th... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Dependent Threshold Checker"] | 12 | A |
3,602 | df4.groupby("spring").describe() | No | 5 | 40 | Debug | show_table_attributes | 1,264,566 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker"] | 12 | A |
3,603 | df4.groupby("fall")["registered"].describe() | No | 5 | 40 | Debug | show_table_attributes | 1,264,566 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker"] | 12 | A |
3,604 | df4["weekend"]=[abs(1-abs(x-y)) for x,y in zip(df4["workingday"],df4["holiday"]) ]
df4.head() | No | 4 | 41 | Debug | show_table | 1,264,566 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Th... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Dependent Threshold Checker"] | 12 | A |
3,605 | print(df4.groupby("weekend")["datetime"].nunique())
print(df4.groupby("holiday")["datetime"].nunique())
print(df4.groupby("workingday")["datetime"].nunique()) | No | 5 | 54 | EDA | count_unique_values | 1,264,566 | 1 | A | 0 | 0 | 0 | 0 | 0 | 3 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker"] | 12 | A |
3,606 | df4.groupby("weekend")['registered',"count","casual"].describe()' | No | 5 | 40 | Debug | show_table_attributes | null | 1 | A | 0 | null | 0 | 0 | 0 | null | no_ml_import | 0 | 0 | [] | null | no_ml_import | [] | [] | 0 | null |
3,607 | df3["weekend"]=[abs(1-abs(x-y)) for x,y in zip(df3["workingday"],df3["holiday"]) ] | No | 5 | 8 | Data_Transform | feature_engineering | 1,264,566 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Th... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Dependent Threshold Checker"] | 12 | A |
3,608 | df3.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,609 | df4.head(25) | No | 5 | 41 | Debug | show_table | 1,264,566 | 1 | A | 0 | 0 | 0 | 0 | 0 | 1 | ok | 1 | 1 | [{"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Threshold Checker", "fix": "Use threshold-independent metrics alongside threshold-dependent ones.", "benefits": "Provides a comprehensive evaluation of model performance.", "location": ""}] | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker"] | 12 | A |
3,610 | df4["time"]=pd.to_datetime(df4["datetime"])
df4.head() | No | 4 | 16 | Data_Transform | data_type_conversions | 1,264,566 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Th... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Dependent Threshold Checker"] | 12 | A |
3,611 | df4["hours"]=df4["time"].dt.hour
df4.head() | No | 5 | 8 | Data_Transform | feature_engineering | 1,264,566 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Th... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Dependent Threshold Checker"] | 12 | A |
3,612 | df3["time"]=pd.to_datetime(df3["datetime"])
df3.head() | No | 5 | 16 | Data_Transform | data_type_conversions | 1,264,566 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Th... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Dependent Threshold Checker"] | 12 | A |
3,613 | df3["hours"]=df3["time"].dt.hour
df3.head() | No | 4 | 8 | Data_Transform | feature_engineering | 1,264,566 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 2 | 2 | [{"detector": "framework_specific", "framework": "Pandas", "name": "Column Selection Checker", "fix": "Select necessary columns after importing DataFrame.", "benefits": "Clarifies data usage and improves performance.", "location": ""}, {"detector": "framework_specific", "framework": "ScikitLearn", "name": "Dependent Th... | A | no applicable ML-specific findings | [] | ["Column Selection Checker", "Dependent Threshold Checker"] | 12 | A |
3,614 | df4.drop(["time"],axis=1,inplace=True)
df3.drop(["time"],axis=1,inplace=True) | No | 5 | 10 | Data_Transform | drop_column | 1,264,566 | 1 | A | 0 | 0 | 0 | 0 | 0 | 2 | ok | 3 | 2 | [{"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 13"}, {"detector": "framework_specific", "framework": "Pandas", "name": "InPlace Checker", "fix": ... | A | no applicable ML-specific findings | [] | ["Dependent Threshold Checker", "InPlace Checker"] | 12 | A |
3,615 | df4.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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.