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 numpy as np | |
| from sklearn.preprocessing import QuantileTransformer | |
| from sklearn.metrics._scorer import _BaseScorer | |
| class FuncScorer(_BaseScorer): | |
| def _score(self, method_caller, estimator, X, y_true, sample_weight=None): | |
| """Evaluate predicted target values for X relative to y_true. | |
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 random | |
| import time | |
| import multiprocessing as mp | |
| import itertools as it | |
| # just an example generator to prove lazy access by printing when it generates | |
| def get_counter(limit=10): | |
| for i in range(limit): | |
| for j in range(limit): | |
| print(f"YIELDED: {i},{j}") |
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 itertools | |
| my_dict = {'A':['D','E'],'B':['F','G','H'],'C':['I','J']} | |
| keys, values = zip(*my_dict.items()) | |
| permutations_dicts = [dict(zip(keys, v)) for v in itertools.product(*values)] | |
| # this will provide you a list of dicts with the permutations: | |
| print(permutations_dicts) | |
| #[{'A':'D', 'B':'F', 'C':'I'}, |
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
| static void PrintTypes(LambdaExpression expr) | |
| { | |
| Console.WriteLine(expr); | |
| ConstantExpression cexpr = expr.Body as ConstantExpression; | |
| if (cexpr != null) | |
| { | |
| Console.WriteLine("\t{0}", cexpr.Type); | |
| return; | |
| } | |
| BinaryExpression bexpr = expr.Body as BinaryExpression; |
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
| using System; | |
| using System.Collections.Concurrent; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Threading.Tasks; | |
| namespace Extensions | |
| { | |
| public static class Extensions | |
| { |
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
| public static string FindUpperFileOrFolder(string name, DirectoryInfo dir = null) | |
| { | |
| dir = dir ?? new DirectoryInfo(Directory.GetCurrentDirectory()); | |
| var dirInfo = dir.GetDirectories(name).FirstOrDefault(); | |
| var fileInfo = dir.GetFiles(name).FirstOrDefault(); | |
| if (fileInfo == null && dirInfo == null) | |
| { | |
| return FindUpperFileOrFolder(name, dir.Parent); | |
| } |
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 matplotlib.pyplot as plt | |
| fig, (ax1, ax2, ax3) = plt.subplots(ncols=3, figsize=(9, 5)) | |
| ax1.set_title('Before Scaling') | |
| sns.kdeplot(x['x1'], ax=ax1) | |
| sns.kdeplot(x['x2'], ax=ax1) | |
| ax2.set_title('After Robust Scaling') | |
| sns.kdeplot(robust_scaled_df['x1'], ax=ax2) | |
| sns.kdeplot(robust_scaled_df['x2'], ax=ax2) | |
| ax3.set_title('After Min-Max Scaling') |
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
| public IEnumerable<int[]> Permut(int[] arr){ | |
| while (true){ | |
| yield return arr; | |
| var j = arr.Length - 2; | |
| while (j >= 0 && arr[j] >= arr[j+1]) j--; | |
| if (j < 0) break; | |
| var l = arr.Length -1; | |
| while (arr[j] >= arr[l]) l--; |
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
| public IEnumerable<int[]> Permut(int[] arr){ | |
| while (true){ | |
| yield return arr; | |
| var j = arr.Length - 2; | |
| while (j >= 0 && arr[j] >= arr[j+1]) j--; | |
| if (j < 0) break; | |
| var l = arr.Length -1; | |
| while (arr[j] >= arr[l]) l--; |
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
| (New-Object System.Security.Principal.NTAccount("Security Group Name")).Translate([System.Security.Principal.SecurityIdentifier]).Value |
NewerOlder