This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def generate_color(magnitude): | |
| if magnitude <= 5: | |
| c_outline, c_fill = '#ffda79', '#ffda79' | |
| m_opacity, f_opacity = 0.2, 0.1 | |
| else: | |
| c_outline, c_fill = '#c0392b', '#e74c3c' | |
| m_opacity, f_opacity = 1, 1 | |
| return c_outline, c_fill, m_opacity, f_opacity | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| quake_map = folium.Map( | |
| location=[-16.495477, 174.9663341], | |
| zoom_start=5, | |
| tiles='Stamen Terrain', | |
| width=1024, | |
| height=600 | |
| ) | |
| for _, row in df.iterrows(): | |
| folium.CircleMarker( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| quake_map = folium.Map( | |
| location=[-16.495477, 174.9663341], | |
| zoom_start=6, | |
| tiles='Stamen Terrain', | |
| width=1024, | |
| height=600 | |
| ) | |
| quake_map |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import folium | |
| quake_map = folium.Map( | |
| location=[-16.495477, 174.9663341], | |
| zoom_start=6, | |
| width=1024, | |
| height=600 | |
| ) | |
| quake_map |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| df = pd.read_csv('quakes.csv') | |
| df.head() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sklearn.metrics import roc_auc_score, roc_curve | |
| y_test_int = y_test.replace({'Good': 1, 'Bad': 0}) | |
| auc_lr = roc_auc_score(y_test_int, probs_lr) | |
| fpr_lr, tpr_lr, thresholds_lr = roc_curve(y_test_int, probs_lr) | |
| auc_dt = roc_auc_score(y_test_int, probs_dt) | |
| fpr_dt, tpr_dt, thresholds_dt = roc_curve(y_test_int, probs_dt) | |
| auc_rf = roc_auc_score(y_test_int, probs_rf) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sklearn.linear_model import LogisticRegression | |
| from sklearn.tree import DecisionTreeClassifier | |
| from sklearn.ensemble import RandomForestClassifier | |
| from xgboost import XGBClassifier | |
| model_lr = LogisticRegression().fit(X_train, y_train) | |
| probs_lr = model_lr.predict_proba(X_test)[:, 1] | |
| model_dt = DecisionTreeClassifier().fit(X_train, y_train) | |
| probs_dt = model_dt.predict_proba(X_test)[:, 1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sklearn.model_selection import train_test_split | |
| X = df.drop('quality', axis=1) | |
| y = df['quality'] | |
| X_train, X_test, y_train, y_test = train_test_split( | |
| X, y, test_size=0.25, random_state=42 | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ax = df['quality'].value_counts().plot(kind='bar', figsize=(10, 6), fontsize=13, color='#087E8B') | |
| ax.set_title('Counts of Bad and Good vines', size=20, pad=30) | |
| ax.set_ylabel('Count', fontsize=14) | |
| for i in ax.patches: | |
| ax.text(i.get_x() + 0.19, i.get_height() + 100, str(round(i.get_height(), 2)), fontsize=15) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| df['quality'] = ['Good' if quality >= 7 else 'Bad' for quality in df['quality']] |