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
package src.exercises | |
import scala.math._ | |
import BigInt.probablePrime | |
import util.Random | |
object chap01 { | |
// 1. In the Scala REPL, type 3. followed by the Tab key. What methods can be | |
// applied? | |
// => Do it in REPL. There are many methods including %, &, *, +, toByte, toChar etc. |
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
from azureml.core import Workspace, Environment | |
from azureml.core.conda_dependencies import CondaDependencies | |
from azureml.core import Image | |
ws = Workspace.from_config() | |
env = Environment(name = 'myenv') | |
conda_dep = CondaDependencies() | |
# Installs numpy version 1.17.0 conda package | |
conda_deps = ['blas=1.0', |
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
from hyperopt import hp | |
from hyperopt.pyll.stochastic import sample | |
space = hp.choice('label', [ | |
hp.uniform('sub_label_1', 0.3, 0.8), | |
hp.normal('sub_label_2', 0.5, 1.0), None, 0, 1, "anything" | |
]) | |
space = { | |
# None by default | |
'max_depth': hp.choice('max_depth', [None, np.arange(1, 300, 1,dtype=int)]), | |
# 2 by default |
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
CREATE TABLE accounts( | |
JE_ID serial PRIMARY KEY, | |
ACCOUNT_DR integer NOT NULL, | |
ACCOUNT_CR integer NOT NULL, | |
SUMM integer NOT NULL, | |
REVERSED integer NOT NULL, | |
USER_ID integer NOT NULL, | |
DATA integer NOT NULL, | |
DATE_DOC integer NOT NULL, | |
APPROVER_ID varchar(256) NOT NULL, |
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 os | |
import sqlite3 | |
import operator | |
from collections import OrderedDict | |
#path to user's history database (Chrome) | |
data_path = os.path.expanduser('~')+"/Library/Application Support/Google/Chrome/Default" | |
files = os.listdir(data_path) | |
history_db = os.path.join(data_path, 'history') | |
#querying the db |
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
package main | |
import ( | |
"bufio" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"net/http" | |
"os" | |
"os/signal" |
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 | |
from sklearn import linear_model | |
def desired_marketing_expenditure(marketing_expenditure, units_sold, desired_units_sold): | |
""" | |
:param marketing_expenditure: (list) A list of integers with the expenditure for each previous campaign. | |
:param units_sold: (list) A list of integers with the number of units sold for each previous campaign. | |
:param desired_units_sold: (integer) Target number of units to sell in the new campaign. | |
:returns: (float) Required amount of money to be invested. | |
""" |
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 itertools | |
def countPairs(arr): | |
# Write your code here | |
count = 0 | |
for i, j in itertools.combinations(arr, 2): | |
v = i & j | |
if v != 0 : | |
if (v % 2 == 0) | (v == 1): | |
count+=1 | |
return count |
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
# This is an application transferring csv data into database | |
# We choose a NoSQL database MongoDB since we have to store data and the logs of data GET requests# We prefer to choose PostgreSQL rather than MySQL(purely relation) or SQLite (no concurrency support) | |
import json | |
import csv | |
import pandas as pd | |
import os | |
from pymongo import MongoClient | |
cwd = os.path.dirname(__file__) | |
csvpath=os.path.join(cwd,'task_data.csv') |
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 matplotlib.pyplot as plt | |
def label_prop_test(model, kernel, params_list, X_train, X_test, y_train, y_test): | |
plt.figure(figsize=(20,10)) | |
n, g = 0, 0 | |
roc_scores = [] | |
if kernel == 'rbf': | |
for g in params_list: | |
lp = model(kernel=kernel, n_neighbors=n, gamma=g, max_iter=100000, tol=0.0001) | |
lp.fit(X_train, y_train) | |
roc_scores.append(roc_auc_score(y_test, lp.predict_proba(X_test), multi_class='ovo')) |
OlderNewer