Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
# Function that runs the requested algorithm and returns the accuracy metrics | |
def fit_ml_algo(algo, X_train, y_train, cv): | |
# One Pass | |
model = algo.fit(X_train, y_train) | |
acc = round(model.score(X_train, y_train) * 100, 2) | |
# Cross Validation | |
train_pred = model_selection.cross_val_predict(algo, | |
X_train, |
This file contains 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 CodelandUsernameValidation(strParam): | |
if (4<len(strParam)<25) or (strParam[0] != str) or strParam[-1] == "_": | |
return False | |
return True | |
# keep this function call here | |
print(CodelandUsernameValidation(input())) | |
""" |
This file contains 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 numpy as np | |
class Solution: | |
def areaEdge(self, h_w: int, Cuts: List[int]) -> int: | |
Cuts.insert(len(Cuts), h_w) | |
temp_list = Cuts[:-1] | |
temp_list.insert(0,0) | |
Cuts.sort() | |
temp_list.sort() |
This file contains 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
class Solution: | |
def reverse(self, x: int) -> int: | |
ex = str(x) | |
if ex[0] == "-": | |
ex2 = ex[1:] | |
print(ex2[::-1]) | |
if not((-2)**31 < int(ex2[::-1]) < 2**31 - 1): | |
return 0 | |
return ex[0] + str(int(ex2[::-1])) | |
else: |
This file contains 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 search(nums, target) -> int: | |
high = len(nums) - 1 | |
low, mid = 0, 0 | |
while low <= high: | |
mid = (high + low)// 2 | |
if nums[mid] < target: | |
low = mid + 1 | |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 val_curve_params(model, X, y, param_name, param_range, scoring = 'roc_auc', cv = 10): | |
train_score, test_score = validation_curve( | |
model, X = X, y = y, param_name = param_name, param_range = param_range, scoring = scoring, cv = cv) | |
mean_train_score = np.mean(train_score, axis = 1) | |
mean_test_score = np.mean(test_score, axis = 1) | |
plt.plot(param_range, mean_train_score, | |
label = 'Training Score', color = 'b') | |
plt.plot(param_range, mean_test_score, |
This file contains 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 plot_importance(model, features, num = len(X), save = False): | |
feature_imp = pd.DataFrame({'Value': model.feature_importances_, 'Feature': features.columns}) | |
plt.figure(figsize = (10, 10)) | |
sns.set(font_scale = 1) | |
sns.barplot(x = 'Value', y = 'Feature', | |
data = feature_imp.sort_values(by = 'Value', ascending = False)[0:num]) | |
plt.title('Features') | |
plt.tight_layout() | |
plt.show() | |
if save: |
This file contains 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
# Based on evan's prompt | |
# Shows the exit status of the last command if non-zero | |
# Uses "#" instead of "»" when running with elevated privileges | |
# local venv_prompt='$(virtualenv_prompt_info)' | |
# PROMPT='%{${fg_bold[blue]}%}$(virtualenv_prompt_info)' | |
PROMPT="%m %{${fg_bold[red]}%}::%{${fg[green]}%} %3~%{${reset_color}%} $(virtualenv_prompt_info)%(0?. . ${fg[red]}%? )%{${fg[blue]}%}» " | |
# PROMPT="%{${fg_bold[white]}%} %m %{${fg_bold[red]}%}:: %{${fg[green]}%}%3~%(0?. . %{${fg[red]}%}%? )%{${fg[blue]}%}$(virtualenv_prompt_info)» %{${reset_color}%}" | |
ZSH_THEME_VIRTUALENV_PREFIX="" | |
ZSH_THEME_VIRTUALENV_SUFFIX="" |
OlderNewer