Skip to content

Instantly share code, notes, and snippets.

View rpgd60's full-sized avatar

Rafael Portillo rpgd60

View GitHub Profile
@rpgd60
rpgd60 / visualize_classifier.py
Last active August 26, 2019 05:24
Helper function to visualize classifiers #randomforest #visualization
# Source: https://jakevdp.github.io/PythonDataScienceHandbook/05.08-random-forests.html
#
def visualize_classifier(model, X, y, ax=None, cmap='rainbow'):
ax = ax or plt.gca()
# Plot the training points
ax.scatter(X[:, 0], X[:, 1], c=y, s=30, cmap=cmap,
clim=(y.min(), y.max()), zorder=3)
ax.axis('tight')
ax.axis('off')
@rpgd60
rpgd60 / missing1.py
Last active August 21, 2019 16:31
[Data preparation - missing values] Tips to handle missing values to improve accuracy #pandas #pyplot
# Preliminary investigation
# Shape of training data (num_rows, num_columns)
print(X_train.shape)
# Number of missing values in each column of training data
missing_val_count_by_column = (X_train.isnull().sum())
print(missing_val_count_by_column[missing_val_count_by_column > 0])
# Result
'''