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
| images = [img, edge_roberts, edge_prewitt, edge_sobel] | |
| names = ["input", "roberts", "prewitt", "sobel"] | |
| fig = plt.figure(figsize = (8, 8)) | |
| for i in range(4): | |
| fig.add_subplot(2, 2, i + 1) | |
| plt.title(names[i]) | |
| plt.imshow(images[i], cmap = 'gray') |
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 necessary modules | |
| from scipy.stats import randint | |
| from sklearn.tree import DecisionTreeClassifier | |
| from sklearn.model_selection import RandomizedSearchCV | |
| # Setup the parameters and distributions to sample from: param_dist | |
| param_dist = {"max_depth": [3, None], | |
| "max_features": randint(1, 9), | |
| "min_samples_leaf": randint(1, 9), | |
| "criterion": ["gini", "entropy"]} |
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
| cols = ['EducationField'] | |
| data = pd.get_dummies(data, columns = cols, prefix = cols) |
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.preprocessing import LabelEncoder | |
| le = LabelEncoder() | |
| data[category_cols] = data[category_cols].apply(le.fit_transform) | |
| data.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
| # gender : Female : 0, Male : 1 | |
| data['Gender'] = data['Gender'].map({'Female' : 1, 'Male' : 0}) | |
| data.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
| # lets scale the values. | |
| from sklearn.preprocessing import MinMaxScaler | |
| scaler = MinMaxScaler() | |
| data[numerical_cols] = scaler.fit_transform(data[numerical_cols]) |