markdown
stringlengths
0
1.02M
code
stringlengths
0
832k
output
stringlengths
0
1.02M
license
stringlengths
3
36
path
stringlengths
6
265
repo_name
stringlengths
6
127
Now if we change the `best` to something less than `10`
best = 9 for i in range(10): if i >= best: print("Excellent") break else: continue else: print("Couldn't find the best match")
Excellent
MIT
notebooks/01-05 Control Flow.ipynb
Mohitsharma44/ucsl17
Smart Queue Monitoring System - Retail Scenario OverviewNow that you have your Python script and job submission script, you're ready to request an **IEI Tank-870** edge node and run inference on the different hardware types (CPU, GPU, VPU, FPGA).After the inference is completed, the output video and stats files need t...
%env PATH=/opt/conda/bin:/opt/spark-2.4.3-bin-hadoop2.7/bin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/intel_devcloud_support import os import sys sys.path.insert(0, os.path.abspath('/opt/intel_devcloud_support')) sys.path.insert(0, os.path.abspath('/opt/intel'))
env: PATH=/opt/conda/bin:/opt/spark-2.4.3-bin-hadoop2.7/bin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/intel_devcloud_support
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
Step 0.1: (Optional-step): Original VideoIf you are curious to see the input video, run the following cell to view the original video stream we'll be using for inference.
import videoHtml videoHtml.videoHTML('Retail', ['original_videos/Retail.mp4'])
_____no_output_____
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
Step 1 : Inference on a VideoIn the next few cells, You'll submit your job using the `qsub` command and retrieving the results for each job. Each of the cells below should submit a job to different edge compute nodes.The output of the cell is the `JobID` of your job, which you can use to track progress of a job with `...
#Submit job to the queue cpu_job_id = !qsub queue_job.sh -d . -l nodes=1:tank-870:i5-6500te -F "/data/models/intel/person-detection-retail-0013/FP32/person-detection-retail-0013 CPU /data/resources/retail.mp4 /data/queue_param/retail.npy /output/results/retail/cpu 2" print(cpu_job_id[0])
qRXPc4Bbf9OekZQx8RsXgtXu45iJSSlt
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
Check Job StatusTo check on the job that was submitted, use `liveQStat` to check the status of the job.Column `S` shows the state of your running jobs.For example:- If `JOB ID`is in Q state, it is in the queue waiting for available resources.- If `JOB ID` is in R state, it is running.
import liveQStat liveQStat.liveQStat()
_____no_output_____
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
Get ResultsRun the next cell to retrieve your job's results.
import get_results get_results.getResults(cpu_job_id[0], filename='output.tgz', blocking=True)
getResults() is blocking until results of the job (id:qRXPc4Bbf9OekZQx8RsXgtXu45iJSSlt) are ready. Please wait...Success! output.tgz was downloaded in the same folder as this notebook.
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
Unpack your output files and view stdout.log
!tar zxf output.tgz !cat stdout.log
Total People in frame = 5 Number of people in queue = {1: 1, 2: 1} Total People in frame = 4 Number of people in queue = {1: 1, 2: 1} Total People in frame = 5 Number of people in queue = {1: 1, 2: 1} Total People in frame = 4 Number of people in queue = {1: 1, 2: 1} Total People in frame = 4 Number of people ...
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
View stderr.logThis can be used for debugging
!cat stderr.log
person_detect.py:48: DeprecationWarning: Reading network using constructor is deprecated. Please, use IECore.read_network() method instead self.model=IENetwork(self.model_structure, self.model_weights)
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
View Output VideoRun the cell below to view the output video. If inference was successfully run, you should see a video with bounding boxes drawn around each person detected.
import videoHtml videoHtml.videoHTML('Retail CPU', ['results/retail/cpu/output_video.mp4'])
_____no_output_____
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
Step 1.2: Submit to an Edge Compute Node with a CPU and IGPUIn the cell below, write a script to submit a job to an <a href="https://software.intel.com/en-us/iot/hardware/iei-tank-dev-kit-core">IEI Tank* 870-Q170 edge node with an Intel® Core i5-6500TE. The inference workload should run on the **Intel® HD Grap...
#Submit job to the queue gpu_job_id = !qsub queue_job.sh -d . -l nodes=1:tank-870:i5-6500te:intel-hd-530 -F "/data/models/intel/person-detection-retail-0013/FP16/person-detection-retail-0013 GPU /data/resources/retail.mp4 /data/queue_param/retail.npy /output/results/retail/gpu 2" print(gpu_job_id[0])
7IR3HnoBY5c5zoHANzetnnOvTyazyk3O
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
Check Job StatusTo check on the job that was submitted, use `liveQStat` to check the status of the job.Column `S` shows the state of your running jobs.For example:- If `JOB ID`is in Q state, it is in the queue waiting for available resources.- If `JOB ID` is in R state, it is running.
import liveQStat liveQStat.liveQStat()
_____no_output_____
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
Get ResultsRun the next cell to retrieve your job's results.
import get_results get_results.getResults(gpu_job_id[0], filename='output.tgz', blocking=True)
getResults() is blocking until results of the job (id:7IR3HnoBY5c5zoHANzetnnOvTyazyk3O) are ready. Please wait............................................Success! output.tgz was downloaded in the same folder as this notebook.
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
Unpack your output files and view stdout.log
!tar zxf output.tgz !cat stdout.log
Total People in frame = 5 Number of people in queue = {1: 1, 2: 1} Total People in frame = 4 Number of people in queue = {1: 1, 2: 1} Total People in frame = 5 Number of people in queue = {1: 1, 2: 1} Total People in frame = 4 Number of people in queue = {1: 1, 2: 1} Total People in frame = 4 Number of people ...
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
View stderr.logThis can be used for debugging
!cat stderr.log
person_detect.py:48: DeprecationWarning: Reading network using constructor is deprecated. Please, use IECore.read_network() method instead self.model=IENetwork(self.model_structure, self.model_weights)
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
View Output VideoRun the cell below to view the output video. If inference was successfully run, you should see a video with bounding boxes drawn around each person detected.
import videoHtml videoHtml.videoHTML('Retail GPU', ['results/retail/gpu/output_video.mp4'])
_____no_output_____
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
Step 1.3: Submit to an Edge Compute Node with an Intel® Neural Compute Stick 2In the cell below, write a script to submit a job to an <a href="https://software.intel.com/en-us/iot/hardware/iei-tank-dev-kit-core">IEI Tank 870-Q170 edge node with an Intel Core i5-6500te CPU. The inference workload should run on ...
#Submit job to the queue vpu_job_id = !qsub queue_job.sh -d . -l nodes=1:tank-870:i5-6500te:intel-ncs2 -F "/data/models/intel/person-detection-retail-0013/FP16/person-detection-retail-0013 MYRIAD /data/resources/retail.mp4 /data/queue_param/retail.npy /output/results/retail/vpu 2" print(vpu_job_id[0])
MuBdzZOs7DKMkjmgfIQWnGrnQ6Ilc2on
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
Check Job StatusTo check on the job that was submitted, use `liveQStat` to check the status of the job.Column `S` shows the state of your running jobs.For example:- If `JOB ID`is in Q state, it is in the queue waiting for available resources.- If `JOB ID` is in R state, it is running.
import liveQStat liveQStat.liveQStat()
_____no_output_____
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
Get ResultsRun the next cell to retrieve your job's results.
import get_results get_results.getResults(vpu_job_id[0], filename='output.tgz', blocking=True)
getResults() is blocking until results of the job (id:MuBdzZOs7DKMkjmgfIQWnGrnQ6Ilc2on) are ready. Please wait..........................Success! output.tgz was downloaded in the same folder as this notebook.
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
Unpack your output files and view stdout.log
!tar zxf output.tgz !cat stdout.log
Total People in frame = 5 Number of people in queue = {1: 1, 2: 1} Total People in frame = 4 Number of people in queue = {1: 1, 2: 1} Total People in frame = 5 Number of people in queue = {1: 1, 2: 1} Total People in frame = 4 Number of people in queue = {1: 1, 2: 1} Total People in frame = 4 Number of people ...
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
View stderr.logThis can be used for debugging
!cat stderr.log
person_detect.py:48: DeprecationWarning: Reading network using constructor is deprecated. Please, use IECore.read_network() method instead self.model=IENetwork(self.model_structure, self.model_weights)
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
View Output VideoRun the cell below to view the output video. If inference was successfully run, you should see a video with bounding boxes drawn around each person detected.
import videoHtml videoHtml.videoHTML('Retail VPU', ['results/retail/vpu/output_video.mp4'])
_____no_output_____
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
Step 1.4: Submit to an Edge Compute Node with IEI Mustang-F100-A10In the cell below, write a script to submit a job to an <a href="https://software.intel.com/en-us/iot/hardware/iei-tank-dev-kit-core">IEI Tank 870-Q170 edge node with an Intel Core™ i5-6500te CPU . The inference workload will run on the IEI Mus...
#Submit job to the queue fpga_job_id = !qsub queue_job.sh -d . -l nodes=1:tank-870:i5-6500te:iei-mustang-f100-a10 -F "/data/models/intel/person-detection-retail-0013/FP16/person-detection-retail-0013 HETERO:FPGA,CPU /data/resources/retail.mp4 /data/queue_param/retail.npy /output/results/retail/fpga 2" print(fpga_job_i...
klPhfgBWRQNWcmxC7NNmKQN374e7Pi0t
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
Check Job StatusTo check on the job that was submitted, use `liveQStat` to check the status of the job.Column `S` shows the state of your running jobs.For example:- If `JOB ID`is in Q state, it is in the queue waiting for available resources.- If `JOB ID` is in R state, it is running.
import liveQStat liveQStat.liveQStat()
_____no_output_____
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
Get ResultsRun the next cell to retrieve your job's results.
import get_results get_results.getResults(fpga_job_id[0], filename='output.tgz', blocking=True)
getResults() is blocking until results of the job (id:klPhfgBWRQNWcmxC7NNmKQN374e7Pi0t) are ready. Please wait..........................Success! output.tgz was downloaded in the same folder as this notebook.
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
Unpack your output files and view stdout.log
!tar zxf output.tgz !cat stdout.log
INTELFPGAOCLSDKROOT is not set Using script's current directory (/opt/altera/aocl-pro-rte/aclrte-linux64) aoc was not found, but aocl was found. Assuming only RTE is installed. AOCL_BOARD_PACKAGE_ROOT is set to /opt/intel/openvino/bitstreams/a10_vision_design_sg2_bitstreams/BSP/a10_1150_sg2. Using that. Adding ...
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
View stderr.logThis can be used for debugging
!cat stderr.log
person_detect.py:48: DeprecationWarning: Reading network using constructor is deprecated. Please, use IECore.read_network() method instead self.model=IENetwork(self.model_structure, self.model_weights)
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
View Output VideoRun the cell below to view the output video. If inference was successfully run, you should see a video with bounding boxes drawn around each person detected.
import videoHtml videoHtml.videoHTML('Retail FPGA', ['results/retail/fpga/output_video.mp4'])
_____no_output_____
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
***Wait!***Please wait for all the inference jobs and video rendering to complete before proceeding to the next step. Step 2: Assess PerformanceRun the cells below to compare the performance across all 4 devices. The following timings for the model are being comapred across all 4 devices:- Model Loading Time- Average I...
import matplotlib.pyplot as plt device_list=['cpu', 'gpu', 'fpga', 'vpu'] inference_time=[] fps=[] model_load_time=[] for device in device_list: with open('results/retail/'+device+'/stats.txt', 'r') as f: inference_time.append(float(f.readline().split("\n")[0])) fps.append(float(f.readline().split...
_____no_output_____
CC0-1.0
smart-queueing-system/Retail_Scenario.ipynb
jlgarcia75/move-mouse-pointer
MatrixTable TutorialIf you've gotten this far, you're probably thinking:- "Can't I do all of this in `pandas` or `R`?" - "What does this have to do with biology?"The two crucial features that Hail adds are _scalability_ and the _domain-specific primitives_ needed to work easily with biological data. Fear not! You've l...
import hail as hl from bokeh.io import output_notebook, show output_notebook() hl.utils.get_1kg('data/') mt = hl.read_matrix_table('data/1kg.mt') mt.describe()
_____no_output_____
MIT
hail/python/hail/docs/tutorials/07-matrixtable.ipynb
saponas/hail
There are a few things to note:- There is a single column field `s`. This is the sample ID from the VCF. It is also the column key.- There is a compound row key: `locus` and `alleles`. - `locus` has type `locus` - `alleles` has type `array`- GT has type `call`. That's a genotype call! Whereas table expressions cou...
mt.s.describe() mt.GT.describe()
_____no_output_____
MIT
hail/python/hail/docs/tutorials/07-matrixtable.ipynb
saponas/hail
MatrixTable operationsWe belabored the operations on tables because they all have natural analogs (sometimes several) on matrix tables. For example: - `count` => `count_{rows, cols}` (and `count` which returns both) - `filter` => `filter_{rows, cols, entries}` - `annotate` => `annotate_{rows, cols, entries}` (and glo...
mt.count() # (rows, cols)
_____no_output_____
MIT
hail/python/hail/docs/tutorials/07-matrixtable.ipynb
saponas/hail
Let's look at the first few row keys (variants) and column keys (sample IDs).
mt.rows().select().show() mt.s.show()
_____no_output_____
MIT
hail/python/hail/docs/tutorials/07-matrixtable.ipynb
saponas/hail
Let's investigate the genotypes and the call rate. Let's look at the first few genotypes:
mt.GT.show()
_____no_output_____
MIT
hail/python/hail/docs/tutorials/07-matrixtable.ipynb
saponas/hail
All homozygous reference, which is not surprising. Let's look at the distribution of genotype calls:
mt.aggregate_entries(hl.agg.counter(mt.GT.n_alt_alleles()))
_____no_output_____
MIT
hail/python/hail/docs/tutorials/07-matrixtable.ipynb
saponas/hail
Let's compute the overall call rate directly, and then plot the distribution of call rate per variant.
mt.aggregate_entries(hl.agg.fraction(hl.is_defined(mt.GT)))
_____no_output_____
MIT
hail/python/hail/docs/tutorials/07-matrixtable.ipynb
saponas/hail
Here's a nice trick: you can use an aggregator inside `annotate_rows` and it will aggregate over columns, that is, summarize the values in the row using the aggregator. Let's compute and plot call rate per variant.
mt2 = mt.annotate_rows(call_rate = hl.agg.fraction(hl.is_defined(mt.GT))) mt2.describe() p = hl.plot.histogram(mt2.call_rate, range=(0,1.0), bins=100, title='Variant Call Rate Histogram', legend='Call Rate') show(p)
_____no_output_____
MIT
hail/python/hail/docs/tutorials/07-matrixtable.ipynb
saponas/hail
Exercise: GQ vs DPIn this exercise, you'll use Hail to investigate a strange property of sequencing datasets.The `DP` field is the sequencing depth (the number of reads).Let's first plot a histogram of `DP`:
p = hl.plot.histogram(mt.DP, range=(0,40), bins=40, title='DP Histogram', legend='DP') show(p)
_____no_output_____
MIT
hail/python/hail/docs/tutorials/07-matrixtable.ipynb
saponas/hail
Now, let's do the same thing for GQ.The `GQ` field is the phred-scaled "genotype quality". The formula to convert to a linear-scale confidence (0 to 1) is `10 ** -(mt.GQ / 10)`. GQ is truncated to lie between 0 and 99.
p = hl.plot.histogram(mt.GQ, range=(0,100), bins=100, title='GQ Histogram', legend='GQ') show(p)
_____no_output_____
MIT
hail/python/hail/docs/tutorials/07-matrixtable.ipynb
saponas/hail
Basics of cluster analysis Import the relevant libraries
import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns sns.set() from sklearn.cluster import KMeans
_____no_output_____
Apache-2.0
15 - Advanced Statistical Methods in Python/7_K-Means Clustering/4_Clustering Categorical Data (2:50)/Categorical data.ipynb
olayinka04/365-data-science-courses
Load the data
data = pd.read_csv('3.01. Country clusters.csv') data
_____no_output_____
Apache-2.0
15 - Advanced Statistical Methods in Python/7_K-Means Clustering/4_Clustering Categorical Data (2:50)/Categorical data.ipynb
olayinka04/365-data-science-courses
Map the data
data_mapped = data.copy() data_mapped['Language']=data_mapped['Language'].map({'English':0,'French':1,'German':2}) data_mapped
_____no_output_____
Apache-2.0
15 - Advanced Statistical Methods in Python/7_K-Means Clustering/4_Clustering Categorical Data (2:50)/Categorical data.ipynb
olayinka04/365-data-science-courses
Select the features
x = data_mapped.iloc[:,1:4] x
_____no_output_____
Apache-2.0
15 - Advanced Statistical Methods in Python/7_K-Means Clustering/4_Clustering Categorical Data (2:50)/Categorical data.ipynb
olayinka04/365-data-science-courses
Clustering
kmeans = KMeans(2) kmeans.fit(x)
_____no_output_____
Apache-2.0
15 - Advanced Statistical Methods in Python/7_K-Means Clustering/4_Clustering Categorical Data (2:50)/Categorical data.ipynb
olayinka04/365-data-science-courses
Clustering results
identified_clusters = kmeans.fit_predict(x) identified_clusters data_with_clusters = data_mapped.copy() data_with_clusters['Cluster'] = identified_clusters data_with_clusters plt.scatter(data_with_clusters['Longitude'],data_with_clusters['Latitude'],c=data_with_clusters['Cluster'],cmap='rainbow') plt.xlim(-180,180) plt...
_____no_output_____
Apache-2.0
15 - Advanced Statistical Methods in Python/7_K-Means Clustering/4_Clustering Categorical Data (2:50)/Categorical data.ipynb
olayinka04/365-data-science-courses
COCO ReaderReader operator that reads a COCO dataset (or subset of COCO), which consists of an annotation file and the images directory.`DALI_EXTRA_PATH` environment variable should point to the place where data from [DALI extra repository](https://github.com/NVIDIA/DALI_extra) is downloaded. Please make sure that the...
from nvidia.dali.pipeline import Pipeline import nvidia.dali.ops as ops import nvidia.dali.types as types import numpy as np from time import time import os.path test_data_root = os.environ['DALI_EXTRA_PATH'] file_root = os.path.join(test_data_root, 'db', 'coco', 'images') annotations_file = os.path.join(test_data_roo...
_____no_output_____
ECL-2.0
docs/examples/general/data_loading/coco_reader.ipynb
a-sansanwal/DALI
Bounding boxes returned by the operator are lists of floats containing composed of **\[x, y, width, height]** (`ltrb` is set to `False` by default).
bboxes = bboxes_cpu.at(4) bboxes
_____no_output_____
ECL-2.0
docs/examples/general/data_loading/coco_reader.ipynb
a-sansanwal/DALI
Let's see the ground truth bounding boxes drawn on the image.
import matplotlib.pyplot as plt import matplotlib.patches as patches import random img_index = 4 img = images_cpu.at(img_index) H = img.shape[0] W = img.shape[1] fig,ax = plt.subplots(1) ax.imshow(img) bboxes = bboxes_cpu.at(img_index) labels = labels_cpu.at(img_index) categories_set = set() for label in labels: ...
_____no_output_____
ECL-2.0
docs/examples/general/data_loading/coco_reader.ipynb
a-sansanwal/DALI
![Callysto.ca Banner](https://github.com/callysto/curriculum-notebooks/blob/master/callysto-notebook-banner-top.jpg?raw=true)
from IPython.display import HTML HTML('''<script> code_show=true; function code_toggle() { if (code_show){ $('div.input').hide(); } else { $('div.input').show(); } code_show = !code_show } $( document ).ready(code_toggle); </script> The raw code for this IPython notebook is by default hidden for easier reading...
_____no_output_____
CC0-1.0
_sources/curriculum-notebooks/Mathematics/PatternsAndRelations/patterns-and-relations.ipynb
mlamoureux/CallystoJBook
Patterns & Relations $\mid$ Grade 7 $\mid$ Math $\mid$IntroductionIn this notebook we will learn what an ordered pair is and how we can use a table of values to represent them. We will work with simple linear equations (relations) and tabulate values for them. We will also learn what a plane and coordinate plane are an...
%matplotlib inline style = {'description_width': 'initial'} @interact(x_value=widgets.IntSlider(value=0, min=0, max=5, step=1, description='Value for x', disabled=False, continuous_update=False, orientation='horizontal', re...
_____no_output_____
CC0-1.0
_sources/curriculum-notebooks/Mathematics/PatternsAndRelations/patterns-and-relations.ipynb
mlamoureux/CallystoJBook
**Question**Knowing that the linear relation is $y = x + 3$, what is the value for y, when $x = 2$? Use the widget above to help you find the answer.
s = {'description_width': 'initial'} from ipywidgets import interact_manual def question_q(answer): if answer=="Select option": print("Click on the correct value for y.") elif answer=="5": ret="Correct!" return ret elif answer != "5" or answer != "Select Option": ...
_____no_output_____
CC0-1.0
_sources/curriculum-notebooks/Mathematics/PatternsAndRelations/patterns-and-relations.ipynb
mlamoureux/CallystoJBook
**Question**Using the correct answer above, what is the corresponding ordered pair? Recall that an ordered pair is of the form $(x,y)$.
s = {'description_width': 'initial'} from ipywidgets import interact_manual def question_q(answer): if answer=="Select option": print("Click on the correct ordered pair (x,y).") elif answer=="(2,5)": ret="Correct!" return ret elif answer != "(2,5)" or answer != "Select ...
_____no_output_____
CC0-1.0
_sources/curriculum-notebooks/Mathematics/PatternsAndRelations/patterns-and-relations.ipynb
mlamoureux/CallystoJBook
Memorizing all different values for $x$ and $y$ is unnecessary. We can organize the $x,y$ values along with the corresponding pairs $(x,y)$ in a table as follows.
### Create dataframe #df_num_rows = int(dropdown_widget.value) grid_features = { 'fullWidthRows': False, 'syncColumnCellResize': True, 'forceFitColumns': True, 'rowHeight': 40, 'enableColumnReorder': True, 'enableTextSelectionOn...
_____no_output_____
CC0-1.0
_sources/curriculum-notebooks/Mathematics/PatternsAndRelations/patterns-and-relations.ipynb
mlamoureux/CallystoJBook
Once we compute a few ordered pairs, we can represent them visually. We define the following two concepts. Definition. A **plane** is a flat surface that extends infinitely in all directions.
point = np.array([1, 1, 1]) normal = np.array([0, 0, 1]) # a plane is a*x+b*y+c*z+d=0 # [a,b,c] is the normal. Thus, we have to calculate # d and we're set d = -point.dot(normal) # create x,y xx, yy = np.meshgrid(range(10), range(10)) # calculate corresponding z z = (-normal[0] * xx - normal[1] * yy - d) * 1. /n...
_____no_output_____
CC0-1.0
_sources/curriculum-notebooks/Mathematics/PatternsAndRelations/patterns-and-relations.ipynb
mlamoureux/CallystoJBook
Definition. A **coordinate plane** is a plane formed by a horizontal number line (the x-axis) and a vertical number line (the y-axis) that intersect at a point called the origin. We can plot points on the coordinate plane. We use ordered pairs to encode information on where points are located. Recall that an ordered p...
fig = plt.figure(figsize=(16,5)) ax1 = fig.add_subplot(1, 3, 1) ax2 = fig.add_subplot(1, 3, 2) ax3 = fig.add_subplot(1, 3, 3) ax2.set_xticks(np.arange(-5,6)),ax2.set_yticks(np.arange(-5,6)) ax2.set_xlim(0,5) ax2.set_ylim(0,5) ax1.axis("Off"),ax2.axis("On"),ax3.axis("Off") ax2.axhline(y=0, color='blue') ax2.axvline(x=0,...
_____no_output_____
CC0-1.0
_sources/curriculum-notebooks/Mathematics/PatternsAndRelations/patterns-and-relations.ipynb
mlamoureux/CallystoJBook
Notice why the order matters. Indeed, if we consider the pair $(4,1)$ we see that it is different.
fig = plt.figure(figsize=(16,5)) ax1 = fig.add_subplot(1, 3, 1) ax2 = fig.add_subplot(1, 3, 2) ax3 = fig.add_subplot(1, 3, 3) ax2.set_xticks(np.arange(-5,6)),ax2.set_yticks(np.arange(-5,6)) ax2.set_xlim(0,5) ax2.set_ylim(0,5) ax1.axis("Off"),ax2.axis("On"),ax3.axis("Off") ax2.axhline(y=0, color='blue') ax2.axvline(x=0,...
_____no_output_____
CC0-1.0
_sources/curriculum-notebooks/Mathematics/PatternsAndRelations/patterns-and-relations.ipynb
mlamoureux/CallystoJBook
Let us take the table we computed previously for the relation$$y = x +3$$along with the ordered pairs we computed. We can then represent the ordered pairs in the coordinate plane. **Activity**Use the widget below to see the relationship between the different ordered pairs and the points on the coordinate plane.
%matplotlib inline @interact(x_value=widgets.IntSlider(value=0, min=0, max=5, step=1, description='Value for x', disabled=False, continuous_update=False, orientation='horizontal', readout=True, readout_format='d'...
_____no_output_____
CC0-1.0
_sources/curriculum-notebooks/Mathematics/PatternsAndRelations/patterns-and-relations.ipynb
mlamoureux/CallystoJBook
ConclusionFrom this graph we conclude that the relation between $x$ and $y$ is linear. This makes sense given the equation is of the form $$y = ax + b$$where $a,b$ are integers and in this particular case, $a = 1, b =3$. Points which are of interest are the intersection between $y$ and the x-axis as well as $x$ and th...
# Create button and dropdown widget def rerun_cell( b ): display(Javascript('IPython.notebook.execute_cell_range(IPython.notebook.get_selected_index()+1,IPython.notebook.get_selected_index()+2)')) style = {'description_width': 'initial'} number_of_cat = 13 dropdown_options = [ str(i+1) for i in range(numbe...
_____no_output_____
CC0-1.0
_sources/curriculum-notebooks/Mathematics/PatternsAndRelations/patterns-and-relations.ipynb
mlamoureux/CallystoJBook
Practice AreaExerciseWe will repeat a similar exercise as above, only this time, we will use a different linear relation. $$y = 2x +4$$Let us begin by building a simple table. Answer the questions below to complete a similar table. Question 1Knowing that $y = 2x + 4$, what is the value of $y$ when $x = 3$? In other wo...
s = {'description_width': 'initial'} from ipywidgets import interact_manual def question_q(answer): if answer=="Select option": print("Click on the correct value of y.") elif answer=="10": ret="Correct!" return ret elif answer != "10" or answer != "Select Option": ...
_____no_output_____
CC0-1.0
_sources/curriculum-notebooks/Mathematics/PatternsAndRelations/patterns-and-relations.ipynb
mlamoureux/CallystoJBook
Question 2Knowing that $y = 2x + 4$, what is the value of $y$ when $x=0$?
s = {'description_width': 'initial'} from ipywidgets import interact_manual def question_p(answer): if answer=="Select option": print("Click on the correct value of y.") elif answer=="4": ret="Correct!" return ret elif answer != "4" or answer != "Select Option": ...
_____no_output_____
CC0-1.0
_sources/curriculum-notebooks/Mathematics/PatternsAndRelations/patterns-and-relations.ipynb
mlamoureux/CallystoJBook
Question 3What is the ordered pair obtained when $x = 2$?
s = {'description_width': 'initial'} from ipywidgets import interact_manual def question_s(answer): if answer=="Select option": print("Click on the correct ordered pair (x,y)") elif answer=="(2,8)": ret="Correct!" return ret elif answer != "(2,8)" or answer != "Select O...
_____no_output_____
CC0-1.0
_sources/curriculum-notebooks/Mathematics/PatternsAndRelations/patterns-and-relations.ipynb
mlamoureux/CallystoJBook
Question 4Using the information on the table and the widget below, identify and select what ordered pairs belong to the relation$$y = 2x + 4$$Select one of the four following options. The correct answer will plot all points, the incorrect answer will print a message.
def plot_answer(relation): x_values = np.array([0,1,2,3,4]) y_values = relation["Coef1"]*x_values + relation["Coef2"] fig = plt.figure() plt.subplots_adjust(left=14, bottom=0.2, right=16, top=1.5, wspace=0.1, hspace=0.2) ax2 = fig.add_subplot(1, 1, 1) ax2.set_xticks(np.arange(-...
_____no_output_____
CC0-1.0
_sources/curriculum-notebooks/Mathematics/PatternsAndRelations/patterns-and-relations.ipynb
mlamoureux/CallystoJBook
Question 5: ConclusionsWhat can you conclude from the table above? Use the following statements to guide your answer and add any other observations you make. | Statement ||-----------||The relation between $x$ and $y$ is linear||There is an intersection between the y-axis and $x$ at the ordered pair ... ||There is an ...
emma1_text = widgets.Textarea( value='', placeholder='Write your answer here. Press Record Answer when you finish.', description='', disabled=False , layout=Layout(width='100%', height='75px') ) emma1_button = widgets.Button(button_style='info',description="Record Answer", layout=Layout(width='15%', height='30px')) d...
_____no_output_____
CC0-1.0
_sources/curriculum-notebooks/Mathematics/PatternsAndRelations/patterns-and-relations.ipynb
mlamoureux/CallystoJBook
ExperimentIn this section you will have an opportunity to explore linear relations parameterized by you, to create their respective tables of values and to plot the ordered pairs. In the end, use what you learned in this notebook to make observations about your findings.Recall that a linear equation is of the form$$y =...
def choose(a,b): print("Equation: " + str(a) + "x + " + str(b)) return [a,b] coeff = interact(choose,a=widgets.IntSlider(value=0, min=0, max=15, step=1, description='Value for a', disabled=False, continuous_update=False, orien...
_____no_output_____
CC0-1.0
_sources/curriculum-notebooks/Mathematics/PatternsAndRelations/patterns-and-relations.ipynb
mlamoureux/CallystoJBook
Interactive Example: Find the relation from a table of valuesWhat if, instead of knowing what the relation is, we are only given a table of values or a plot? If we know that the values belong to a linear relation, this along with the values is enough to determine what the relation is. Consider the table and the plotted...
def tabulate_to_eq(relation): x_values = np.array([0,1,2,3,4]) y_values = relation["Coef1"]*x_values + relation["Coef2"] ordered = [(x_values[i],y_values[i]) for i in range(len(x_values))] df_num_rows = len(x_values) empty_list = [ '' for i in range(df_num_rows) ] category_list = [ i+1 for i ...
_____no_output_____
CC0-1.0
_sources/curriculum-notebooks/Mathematics/PatternsAndRelations/patterns-and-relations.ipynb
mlamoureux/CallystoJBook
Can you determine what the equation is based on the ordered pairs? In the questions below we will walk towards the solution. Observation 1Using the table or the plot, find what the value of $y$ is when $x = 0$. Enter your answer in the box. When you think you have the correct answer, press the Run Interact button.
s = {'description_width': 'initial'} @interact_manual(answer =widgets.Textarea( value=' ', placeholder='Type something', description='Your Answer:', disabled=False, style=s)) def get_answer_one(answer): if "1" in answer: print("Correct!") else: print("HINT...
_____no_output_____
CC0-1.0
_sources/curriculum-notebooks/Mathematics/PatternsAndRelations/patterns-and-relations.ipynb
mlamoureux/CallystoJBook
Observation 2Recall that a linear relation is of the form $$y = ax + b$$Use this information along with the answer to Observation 1, to deduce the value of $b$.Enter your answer in the box below. When you think you have found an answer, press the Run Interact button.
s = {'description_width': 'initial'} @interact_manual(answer =widgets.Textarea( value=' ', placeholder='Type something', description='Your Answer:', disabled=False, style=s)) def get_answer_one(answer): if "1" in answer: print("Correct!") else: print("HINT...
_____no_output_____
CC0-1.0
_sources/curriculum-notebooks/Mathematics/PatternsAndRelations/patterns-and-relations.ipynb
mlamoureux/CallystoJBook
From the observation above, we determined that the value of $b = 1$, as $$y = ax + b$$and when $x =0$, we observe $y = 1$. Via algebraic manipulation, this means that $ 0 +b = 1$ which means $b = 1$. We now know our equation is of the form$$ y =ax + 1$$There is only one loose end. We want to get the value of $a$. Ob...
s = {'description_width': 'initial'} @interact_manual(answer =widgets.Textarea( value=' ', placeholder='Type something', description='Your Answer:', disabled=False, style=s)) def get_answer_one(answer): if "2" in answer: print("Correct!") else: print("HINT:...
_____no_output_____
CC0-1.0
_sources/curriculum-notebooks/Mathematics/PatternsAndRelations/patterns-and-relations.ipynb
mlamoureux/CallystoJBook
RecapObserve that all we needed to find the linear equation were the first two entries in the table. Indeed, we used Entry Number 1, x = 0, y = 1 to determine that b = 1. We then used this, along with Entry Number 2 x = 1, y = 3, to determine that a = 2. This yields to the linear equation $$y = 2x + 1$$Use the widget ...
@interact(x_value=widgets.IntSlider(value=0, min=0, max=4, step=1, description='Value for x', disabled=False, continuous_update=False, orientation='horizontal', readout=True, readout_format='d', style...
_____no_output_____
CC0-1.0
_sources/curriculum-notebooks/Mathematics/PatternsAndRelations/patterns-and-relations.ipynb
mlamoureux/CallystoJBook
Why do you think equations of the form$$y = ax + b$$are called "linear"? Use the box below to enter your answer.
emma1_text = w.Textarea( value='', placeholder='Write your answer here. Press Record Answer when you finish.', description='', disabled=False , layout=Layout(width='100%', height='75px') ) emma1_button = w.Button(button_style='info',description="Record Answer", layout=Layout(width='15%', height='30px')) display(emma...
_____no_output_____
CC0-1.0
_sources/curriculum-notebooks/Mathematics/PatternsAndRelations/patterns-and-relations.ipynb
mlamoureux/CallystoJBook
Python code til udregning af data fra ATP
#Imports
_____no_output_____
MIT
teaching_material/session_10/gruppe_17/Case 2 DOA.ipynb
tlh957/DO2021
Udregninger Alder for at kunne blive tilbudt tidlig pension
#Årgange født i 1955-1960 har adgang til at søge i 2021. #Man skal være fyldt 61 for at søge. print(2021-61, "kan anmode om tidlig pension") #Der indgår personer fra 6 1⁄2 årgange print(2021-66, "sidste år inden folkepension indtræder") #da personer født 1.halvår 1955 har nået folkepensionsalderen inden 1. januar...
1960 kan anmode om tidlig pension 1955 sidste år inden folkepension indtræder
MIT
teaching_material/session_10/gruppe_17/Case 2 DOA.ipynb
tlh957/DO2021
Forventede ansøgning
#Omkring 38.000 helårspersoner forventes at opnå ret til at gå på tidligt pension i 2022. #Det dækker over muligheden for at 1, 2 eller 3 år. #22.000 vil benytte sig af retten i 2022, 6000 fra beskæftigelse. ansøgning = 38100 #personer benyttelse = 22000 #benytter tidlig pension print("Det vil sige, at dem der afstå...
Det vil sige, at dem der afstår retten til tidlig pension er 16100 personer
MIT
teaching_material/session_10/gruppe_17/Case 2 DOA.ipynb
tlh957/DO2021
Personer med 44+ på arbejdsmarkedet
#Personer med 44+ år på arbejdsmarkedet har automatisk fuld anciennitet. automatisk_behandling = 1.7+7.1 berettiget = 33.9 procent = round(automatisk_behandling/berettiget*100) print(automatisk_behandling, "af de", round(automatisk_behandling/berettiget*100), "% af ansøgerne har automatisk fuld anciennitet er",...
8.799999999999999 af de 26 % af ansøgerne har automatisk fuld anciennitet er 9906 personer
MIT
teaching_material/session_10/gruppe_17/Case 2 DOA.ipynb
tlh957/DO2021
Manuel håndtering
#Personer der har 42 eller 43 års anciennitet på arbejdsmarkedet kræver manuel håndtering. resterende = 74 #74% af 38.100 ansøgere = 28.194 ansøgere kræver manuel håndtering print(round(ansøgning/100*resterende),"ansøgere kræver manuel håndtering")
28194 ansøgere kræver manuel håndtering
MIT
teaching_material/session_10/gruppe_17/Case 2 DOA.ipynb
tlh957/DO2021
Supplerende dokumentation
#Vi forventer, at 50% af ansøgerne der kræver manuel behandling indsender supplerende dokumentation. halvdelen = 2 manuel_håndtering = 28194 #50% af 28.194 = 14.097 personer. print(round(manuel_håndtering/halvdelen))
14097
MIT
teaching_material/session_10/gruppe_17/Case 2 DOA.ipynb
tlh957/DO2021
Uger i ansøgningsperioden
#Hvor mange uger er der i perioden d. 1. august – 31. december? antal_uger = 52 #uger uger_i_perioden = 31 #uger print(antal_uger-uger_i_perioden,"uger ansøgningsperioden")
21 uger ansøgningsperioden
MIT
teaching_material/session_10/gruppe_17/Case 2 DOA.ipynb
tlh957/DO2021
Arbejdstimer
#Hvor mange arbejdstimer er der behov for i perioden? #ATP har et erfaringsbaseret estimat for tidsforbruget ifm. manuel behandling af en typisk ansøgning, #svarende til 30 minutter. supplerende = 14097 #antal ansøgning der kræver halvtime = 2 #halv time print(supplerende/halvtime," antal arbejdstimer")
7048.5 antal arbejdstimer
MIT
teaching_material/session_10/gruppe_17/Case 2 DOA.ipynb
tlh957/DO2021
antal medarbejder
#Hvor mange timer om ugen er det rimeligt at sige at hver medarbejder bruger på sagsbehandling? #Der går også timer på administration, interne møder og andet. uger_ansøgning = 21 #uger årsværk_ATP = 1356 #timer procent_år = 40.38 #procent print(uger_ansøgning/antal_uger*100, "% af et år, af de 1356 timer =", round(års...
40.38461538461539 % af et år, af de 1356 timer = 548 timer 13 medarbejder
MIT
teaching_material/session_10/gruppe_17/Case 2 DOA.ipynb
tlh957/DO2021
Get Diabetes Prediction from Automated ML EndpointModify the code in the cell below to use the ***ENDPOINT*** and ***PRIMARY_KEY*** for your **auto-predict-diabetes** service. Then run the cell to submit new patient data and retrieve the predicted classifications.
endpoint = 'ENDPOINT' #Replace with your endpoint key = 'PRIMARY_KEY' #Replace with your key import json import requests #Features for a patient data = { "Inputs": { "data": [ {"PatientID": 1, "Pregnancies": 5, "PlasmaGlucose": 181.0, "DiastolicBloodPressure": 90.6, "TricepsThickne...
_____no_output_____
Apache-2.0
04 Build and operate machine learning solutions with Azure Databricks/mslearn-dp100/02 - Get AutoML Prediction.ipynb
raj713335/DP-100
Speed comparison between PyPairs and the R verison - PyPairsHere we ran the sandbag part of the original Pairs method on the oscope dataset for a growing subset of genes. Taking note of the required execution time. Single cored time is taken. For the result please see: [2.3 Differences in code - Python](./2.3%20Differ...
%%javascript $.getScript('https://kmahelona.github.io/ipython_notebook_goodies/ipython_notebook_toc.js') import sys code = "./../../code/" data = "./../../data/" sys.path.append(code) import pandas import pypairs as pairs from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot import plotly.graph_...
_____no_output_____
MIT
supplementary/notebooks/2. Python reimplementation/2.3 Differences in code - Python.ipynb
bebatut/pypairs
Loading Oscope Dataset
# Load matrix oscope_gencounts = pandas.read_csv(Path(data + "data/GSE64016_H1andFUCCI_normalized_EC_human.csv")) # Set index right oscope_gencounts.set_index("Unnamed: 0", inplace=True) # Subset sorted oscope_gencounts_sorted = oscope_gencounts.iloc[:, [oscope_gencounts.columns.get_loc(c) for c in oscope_gencounts.c...
Total number of genes in oscope dataset 19083
MIT
supplementary/notebooks/2. Python reimplementation/2.3 Differences in code - Python.ipynb
bebatut/pypairs
Running sandbag with increasing number of genes Notice: Long runtime, result stored in magic please see [Results](Results)
t = [] genes = [10,100,500,1000,5000,10000,19000] for g in tqdm(genes): sub = helper.random_subset(range(0, no_genes), g) subset = oscope_gencounts_sorted.iloc[sub, :] start = timeit.default_timer() oscope_marker_pairs = pairs.sandbag(x=subset, phases=annotation, fraction=0.65, processes=1, ve...
Stored 't' (list)
MIT
supplementary/notebooks/2. Python reimplementation/2.3 Differences in code - Python.ipynb
bebatut/pypairs
ResultsPython times are feched from store magic, R times were copied manually
%store -r t_python = t t_r = [0.01, 0.08, 1.49, 6.37, 180.56, 803.64, 2761.00] # Create traces trace0 = go.Scatter( x= [10,100,500,1000,5000,10000,19000], y= t_python, mode='markers+lines', marker=dict( symbol='circle', size=10, color='green', ), name='PyPairs' ) trace1 ...
_____no_output_____
MIT
supplementary/notebooks/2. Python reimplementation/2.3 Differences in code - Python.ipynb
bebatut/pypairs
CORD-19 Software MentionsA notebook to explore the dataset and output some lightly processed dataCollaborations Workshop 2021 HackDay Project "Habeas Corpus"https://github.com/softwaresaved/habeas-corpus Setup imports and files
import numpy as np import pandas as pd import csv import ast import collections import matplotlib.pyplot as plt from wordcloud import WordCloud CORD19_CSVFILE = '../data/cord-19/CORD19_software_mentions.csv' POPULARITY_CSVFILE = '../data/output/CORD19_software_popularity.csv'
_____no_output_____
MIT
notebooks/CORD-19-viewer.ipynb
dartar/habeas-corpus
Have a quick look at the data using pandas
df = pd.read_csv(CORD19_CSVFILE) df.head()
_____no_output_____
MIT
notebooks/CORD-19-viewer.ipynb
dartar/habeas-corpus
Load the data and extract the software mentions
software = [] with open(CORD19_CSVFILE, newline='') as csvfile: reader = csv.DictReader(csvfile) for row in reader: mentions = set(ast.literal_eval(row['software'])) for mention in mentions: software.append(mention) len(software)
_____no_output_____
MIT
notebooks/CORD-19-viewer.ipynb
dartar/habeas-corpus
Take a quick look at the statistics
occurrences = collections.Counter(software) len(occurrences) common_software = occurrences.most_common(20) common_software labels, ys = zip(*common_software) xs = np.arange(len(labels)) width = 1 plt.bar(xs, ys, width, align='center') plt.title('Frequency of software mentions in CORD-19 data') plt.xlabel('Software T...
_____no_output_____
MIT
notebooks/CORD-19-viewer.ipynb
dartar/habeas-corpus
Display the world cloud
wordcloud = WordCloud(max_font_size=50).generate_from_frequencies(occurrences) plt.figure(figsize=(15,8)) plt.imshow(wordcloud) plt.axis("off") plt.show()
_____no_output_____
MIT
notebooks/CORD-19-viewer.ipynb
dartar/habeas-corpus
Output the slightly processed data
with open(POPULARITY_CSVFILE, 'w', newline='') as csvfile: writer = csv.writer(csvfile) for row in occurrences.most_common(len(occurrences)): writer.writerow(row)
_____no_output_____
MIT
notebooks/CORD-19-viewer.ipynb
dartar/habeas-corpus
Practice Notebook: Methods and Classes The code below defines an *Elevator* class. The elevator has a current floor, it also has a top and a bottom floor that are the minimum and maximum floors it can go to. Fill in the blanks to make the elevator go through the floors requested.
class Elevator: def __init__(self, bottom, top, current): """Initializes the Elevator instance.""" self.bottom=bottom self.top=top self.current=current def __str__(self): """Information about Current floor""" return "Current floor: {}".format(self.current) def...
_____no_output_____
MIT
Crash Course on Python/WEEK 5/Methods and Classes/ utf-8''C1M5L2_Methods_and_Classes_V3.ipynb
atharvpuranik/Google-IT-Automation-with-Python-Professional-Certificate
This class is pretty empty and doesn't do much. To test whether your *Elevator* class is working correctly, run the code blocks below.
elevator.up() elevator.current #should output 1 elevator.down() elevator.current #should output 0 elevator.go_to(10) elevator.current #should output 10
_____no_output_____
MIT
Crash Course on Python/WEEK 5/Methods and Classes/ utf-8''C1M5L2_Methods_and_Classes_V3.ipynb
atharvpuranik/Google-IT-Automation-with-Python-Professional-Certificate
If you get a **NameError** message, be sure to run the *Elevator* class definition code block first. If you get an **AttributeError** message, be sure to initialize *self.current* in your *Elevator* class. Once you've made the above methods output 1, 0 and 10, you've successfully coded the *Elevator* class and its meth...
# Go to the top floor. Try to go up, it should stay. Then go down. elevator.go_to(10) elevator.up() elevator.down() print(elevator.current) # should be 9 # Go to the bottom floor. Try to go down, it should stay. Then go up. elevator.go_to(-1) elevator.down() elevator.down() elevator.up() elevator.up() print(elevator.cu...
9 1
MIT
Crash Course on Python/WEEK 5/Methods and Classes/ utf-8''C1M5L2_Methods_and_Classes_V3.ipynb
atharvpuranik/Google-IT-Automation-with-Python-Professional-Certificate
Now add the __str__ method to your *Elevator* class definition above so that when printing the elevator using the **print( )** method, we get the current floor together with a message. For example, in the 5th floor it should say "Current floor: 5"
elevator.go_to(5) print(elevator)
Current floor: 5
MIT
Crash Course on Python/WEEK 5/Methods and Classes/ utf-8''C1M5L2_Methods_and_Classes_V3.ipynb
atharvpuranik/Google-IT-Automation-with-Python-Professional-Certificate
PTN TemplateThis notebook serves as a template for single dataset PTN experiments It can be run on its own by setting STANDALONE to True (do a find for "STANDALONE" to see where) But it is intended to be executed as part of a *papermill.py script. See any of the experimentes with a papermill script to get started ...
%load_ext autoreload %autoreload 2 %matplotlib inline import os, json, sys, time, random import numpy as np import torch from torch.optim import Adam from easydict import EasyDict import matplotlib.pyplot as plt from steves_models.steves_ptn import Steves_Prototypical_Network from steves_utils.lazy_iterable_wr...
_____no_output_____
MIT
experiments/tuned_1v2/oracle.run2_limited/trials/9/trial.ipynb
stevester94/csc500-notebooks
Required ParametersThese are allowed parameters, not defaultsEach of these values need to be present in the injected parameters (the notebook will raise an exception if they are not present)Papermill uses the cell tag "parameters" to inject the real parameters below this cell.Enable tags to see what I mean
required_parameters = { "experiment_name", "lr", "device", "seed", "dataset_seed", "labels_source", "labels_target", "domains_source", "domains_target", "num_examples_per_domain_per_label_source", "num_examples_per_domain_per_label_target", "n_shot", "n_way", "n_q...
_____no_output_____
MIT
experiments/tuned_1v2/oracle.run2_limited/trials/9/trial.ipynb
stevester94/csc500-notebooks
Worksheet 0.1.2: Python syntax (`while` loops)This worksheet will invite you to tinker with the examples, as they are live code cells. Instead of the normal fill-in-the-blank style of notebook, feel free to mess with the code directly. Remember that -- to test things out -- the Sandbox is available to you as well.The ...
# Initialize starting number seconds = 10 # Start while loop while seconds > 0: print(seconds) seconds -= 1 print("Liftoff!")
10 9 8 7 6 5 4 3 2 1 Liftoff!
CC-BY-4.0
day-2/0_week-0-worksheet-while-loops.ipynb
allegheny-college-cmpsc-100-jan-2021/week-0
In the above block of code, we start by telling the program where to, well, start. Then we print that number followed by an instruction `seconds -= 1` to _decrement_ (decrease) that number by one _each time the loop runs_ (on each _iteration_). By the time we reach the end, the last run notices that `seconds == 0`, the...
name = input("What is your name: ") print("Hello, " + name + ".")
_____no_output_____
CC-BY-4.0
day-2/0_week-0-worksheet-while-loops.ipynb
allegheny-college-cmpsc-100-jan-2021/week-0
_Because we stored the result_ in `name`, we can use it -- whether that's to `print` it or test it:
if name == "The Professor": print("The Professor is in the house!") else: print("Oh, you're not the professor. Forget it.")
_____no_output_____
CC-BY-4.0
day-2/0_week-0-worksheet-while-loops.ipynb
allegheny-college-cmpsc-100-jan-2021/week-0
One thing of particular note:
# The identifier "str_value" is arbitrary here, no real significance str_value = input("Enter a numeric value of any kind: ") print(type(str_value))
_____no_output_____
CC-BY-4.0
day-2/0_week-0-worksheet-while-loops.ipynb
allegheny-college-cmpsc-100-jan-2021/week-0
No matter what we enter here, the result will always be a `string` type. That's because the Python language is rigged to do its best with _whatever_ a user writes in the prompt. This means handling characters/symbols (`!@^!%@$` -- I promise I'm not swearing here), letters (`a`,`b`,`c`), or numbers (either `integer` or ...
float_value = float(str_value) print(type(float_value))
_____no_output_____
CC-BY-4.0
day-2/0_week-0-worksheet-while-loops.ipynb
allegheny-college-cmpsc-100-jan-2021/week-0