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 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
| n_trials = 10000 | |
| n_candidates = 100 | |
| max_burn = int(0.66 * n_candidates) | |
| for T in range(1, max_burn, 5): | |
| global_maxes = [] | |
| diff_from_max = [] | |
| time_taken = [] | |
| final_choices = [] | |
| for i in range(n_trials): | |
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
| exper = setup( | |
| data = bike_yes, | |
| categorical_features = ["Seasons", "Holiday"], | |
| silent = True, | |
| ordinal_features = {"Hour": sorted_hours}, | |
| ignore_features = ["Functioning Day","Date"], | |
| target = 'Rented Bike Count', | |
| use_gpu = True, | |
| data_split_shuffle = False, | |
| fold_strategy = "timeseries", |
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
| acts = ["jogging","standing","downstairs","upstairs","walkfast","walkmod","walkslow","lying","sitting"] | |
| def create_windows(subjects): | |
| length = 100 | |
| stride = 50 | |
| sample = 10 | |
| framelist = [] | |
| targetlist = [] | |
| global acts | |
| for act in acts: | |
| for f in glob.glob(subjects + act): |
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 pycaret.datasets import get_data | |
| from pycaret.classification import * | |
| report["Scores"] = np.round(report["Scores"], 3) | |
| report.sort_values(by = "Scores", ascending = False, inplace = True) | |
| #report.index | |
| ga_feats = report.iloc[0]["Chosen Feats"] | |
| ename = setup(data = D[used_feats], target = "DEATH_EVENT", | |
| test_data = None, | |
| fold_strategy = "stratifiedkfold", | |
| fold_shuffle = 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
| scores = [] | |
| for i in range(len(report)): | |
| myfeats = report.iloc[i,1] ; print(myfeats) | |
| X = D[myfeats] ; y = y | |
| clf = LogisticRegression(solver = "liblinear", C = 6, tol = 1) | |
| #clf = RandomForestClassifier() | |
| rskf = RepeatedStratifiedKFold(n_splits = 10, n_repeats = 100) | |
| score = np.mean(cross_val_score(clf, X, y, cv = rskf, scoring = "roc_auc")) | |
| scores.append(score) |
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.feature_selection import * | |
| feat_list = [] | |
| all_scores = [] | |
| for i in range(10): | |
| np.random.seed(i) | |
| sfm = SelectFromModel(estimator = clf, threshold=None, prefit=False, | |
| norm_order=1, max_features = 12) | |
| sfm.fit(D[allfeats], y) | |
| modfeats = sfm.get_support() | |
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 * | |
| mcc = make_scorer(matthews_corrcoef) | |
| estimator = LogisticRegression(solver = "liblinear", C = 6, tol = 1, fit_intercept = True) | |
| from sklearn.model_selection import * | |
| report = pd.DataFrame() | |
| nofeats = [] | |
| chosen_feats = [] | |
| cvscore = [] | |
| rkf = RepeatedStratifiedKFold(n_repeats = 2, n_splits = 10) |
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
| covariates = trainx; target = trainy | |
| def lgb_trainer(num_leaves, learning_rate, | |
| max_depth, n_estimators, | |
| reg_lambda, | |
| #alpha, | |
| reg_alpha, | |
| subsample): | |
| lgb = LGBMRegressor(objective = "quantile", | |
| alpha = .95, |
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 getWeights(d,lags): | |
| # return the weights from the series expansion of the differencing operator | |
| # for real orders d and up to lags coefficients | |
| w=[1] | |
| for k in range(1,lags): | |
| w.append(-w[-1]*((d-k+1))/k) | |
| w=np.array(w).reshape(-1,1) | |
| return w | |
| def plotWeights(dRange, lags, numberPlots): |
NewerOlder