Unnamed: 0
int64
0
16k
text_prompt
stringlengths
149
45.7k
code_prompt
stringlengths
67
140k
900
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: TensorFlow Tutorial #01 Simple Linear Model by Magnus Erik Hvass Pedersen / GitHub / Videos on YouTube Introduction This tutorial demonstrates the basi...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import tensorflow as tf import numpy as np from sklearn.metrics import confusion_matrix Explanation: TensorFlow Tutorial #01 Simple Linear Model by Magnus Erik Hvass Pedersen / GitHub / Videos on YouTube Introduction This tutorial demonst...
901
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Python Basics with Numpy (optional assignment) Welcome to your first assignment. This exercise gives you a brief introduction to Python. Even if you've...
<ASSISTANT_TASK:> Python Code: ### START CODE HERE ### (≈ 1 line of code) test = "Hello World" ### END CODE HERE ### print ("test: " + test) Explanation: Python Basics with Numpy (optional assignment) Welcome to your first assignment. This exercise gives you a brief introduction to Python. Even if you've used Python be...
902
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Strings String is a Sequence A string is a sequence of characters. You can access the characters one at a time with the bracket operator Step1: The se...
<ASSISTANT_TASK:> Python Code: fruit = "pinapple" letter = fruit[1] Explanation: Strings String is a Sequence A string is a sequence of characters. You can access the characters one at a time with the bracket operator: End of explanation print(letter) Explanation: The second statement selects character number 1 from fr...
903
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: &larr; Back to Index Onset Detection Automatic detection of musical events in an audio signal is one of the most fundamental tasks in music information...
<ASSISTANT_TASK:> Python Code: x, fs = librosa.load('simpleLoop.wav', sr=44100) print x.shape Explanation: &larr; Back to Index Onset Detection Automatic detection of musical events in an audio signal is one of the most fundamental tasks in music information retrieval. Here, we will show how to detect an onset, the sta...
904
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: 1.20 合并多个字典或映射 有多个字典或映射 将他们从逻辑上合并为一个单一的映射后执行某些操作 比如 查找值或检查某些键是否存在 Step1: 一个 ChainMap 接受多个 dict 将他们在逻辑上变为一个 dict 然后 这些 dict 不是真的合并在一起了 ChainMap 类只是在内部创...
<ASSISTANT_TASK:> Python Code: a = {'x': 1, 'z': 3} b = {'y': 2, 'z': 4} # 需在两 dict 中执行查找操作 (先从 a 中找,若是找不到,再在 b 中找) from collections import ChainMap c = ChainMap(a,b) print(c['x']) print(c['y']) print(c['z']) Explanation: 1.20 合并多个字典或映射 有多个字典或映射 将他们从逻辑上合并为一个单一的映射后执行某些操作 比如 查找值或检查某些键是否存在 End of explanation len(c) list(c...
905
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: ClickForMarker Lets you create markers on each click Step1: Click on the map to see the effects LatLngPopup lets you create a simple popup at each cli...
<ASSISTANT_TASK:> Python Code: folium.Map().add_child(ClickForMarker()) Explanation: ClickForMarker Lets you create markers on each click End of explanation folium.Map().add_child(LatLngPopup()) Explanation: Click on the map to see the effects LatLngPopup lets you create a simple popup at each click End of explanation ...
906
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: ROC Curve Example Inspired by Step1: Import some data to play with Step2: Split the data and prepare data for ROC Curve Step3: Plot ROC Curve using ...
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt from sklearn import svm, datasets from sklearn.metrics import roc_curve, auc from sklearn.model_selection import train_test_split Explanation: ROC Curve Example Inspired by: http://scikit-learn.org/stable/auto_examples/model_selection/plo...
907
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Distributions of multiple numerical features with Seaborn When given a set of numerical features, it is desirable to plot all of them using for example...
<ASSISTANT_TASK:> Python Code: import string import pandas as pd import numpy as np import seaborn as sns Explanation: Distributions of multiple numerical features with Seaborn When given a set of numerical features, it is desirable to plot all of them using for example violinplots, to get a sense of their respective d...
908
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Decorators ONLY AFTER FP A decorator is the name used for a software design pattern. Decorators dynamically alter the functionality of a function, meth...
<ASSISTANT_TASK:> Python Code: # sandwich() # test = bread(ingredients(Cheese)) # test() # # bread_1 = ingredients(Cheese) # # print(bread_1) # # bread_1() def bread(test_funct): def hyderabad(): print("</''''''\>") test_funct() print("<\______/>") return hyderabad def ingredients(test_f...
909
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: ES-DOC CMIP6 Model Properties - Land MIP Era Step1: Document Authors Set document authors Step2: Document Contributors Specify document contributors ...
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'awi', 'awi-cm-1-0-hr', 'land') Explanation: ES-DOC CMIP6 Model Properties - Land MIP Era: CMIP6 Institute: AWI Source ID: AWI-CM-1-0-HR Topic: Land Sub-Topics: Soil,...
910
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: 请在环境变量中设置DB_URI指向数据库 Step1: 1. Single Day Analysis Step2: Portfolio Construction using EPS factor as alpha factor; short selling is forbiden; target ...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import os import numpy as np import pandas as pd from matplotlib import pyplot as plt from PyFin.api import * from alphamind.api import * from alphamind.strategy.strategy import Strategy, RunningSetting from alphamind.portfolio.meanvariancebuilder import target_vol_buil...
911
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Linear models for regression y_pred = x_test[0] * coef_[0] + ... + x_test[n_features-1] * coef_[n_features-1] + intercept_ Step1: Linear Regression $$...
<ASSISTANT_TASK:> Python Code: from sklearn.datasets import make_regression from sklearn.cross_validation import train_test_split X, y, true_coefficient = make_regression(n_samples=80, n_features=30, n_informative=10, noise=100, coef=True, random_state=5) X_train, X_test, y_train, y_test = train_test_split(X, y, random...
912
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Probing Image-Text Models This Colab evaluates pretrained image--text models (in a zero-shot way) with respect to fine-grained subject, verb, and objec...
<ASSISTANT_TASK:> Python Code: import numpy as np import sys import json import csv import pandas as pd import re import matplotlib.pyplot as plt import seaborn as sns csv.field_size_limit(sys.maxsize) Explanation: Probing Image-Text Models This Colab evaluates pretrained image--text models (in a zero-shot way) with re...
913
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Import Step1: file_path Step2: LSTM - Hyper Params Step3: vgg16 Step4: load_vgg16 Step5: File Info Step6: Text Reader def input_pipeline(filename...
<ASSISTANT_TASK:> Python Code: import tensorflow as tf from PIL import Image import numpy as np from scipy.misc import imread, imresize from imagenet_classes import class_names import os Explanation: Import End of explanation #File Path # filepath_input = "./data/run/" #input csv file path filepath_ckpt = "./ckpt/mod...
914
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Train Model with CPU Step1: Create Model Test/Validation Data Step2: Look at the Model Graph In Tensorboard Navigate to the Graph tab at this URL Ste...
<ASSISTANT_TASK:> Python Code: import tensorflow as tf from tensorflow.python.client import timeline import pylab import numpy as np %matplotlib inline %config InlineBackend.figure_format = 'retina' tf.logging.set_verbosity(tf.logging.INFO) tf.reset_default_graph() num_samples = 100000 from datetime import datetime ve...
915
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Copyright (c) 2018 Geosoft Inc. https Step1: Convert a grid from one format to another We will start with a common simple task, converting a grid from...
<ASSISTANT_TASK:> Python Code: import geosoft.gxpy.gx as gx import geosoft.gxpy.grid as gxgrid import geosoft.gxpy.utility as gxu from IPython.display import Image gxc = gx.GXpy() url = 'https://github.com/GeosoftInc/gxpy/raw/9.3/examples/tutorial/Grids%20and%20Images/' gxu.url_retrieve(url + 'elevation_surfer.GRD') Ex...
916
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: <table align="left"> <td> <a href="https Step1: Restart the Kernel Once you've installed the {packages}, you need to restart the notebook kernel...
<ASSISTANT_TASK:> Python Code: %pip install -U missing_or_updating_package --user Explanation: <table align="left"> <td> <a href="https://colab.research.google.com/github/GoogleCloudPlatform/ai-platform-samples/blob/main/notebooks/templates/ai_platform_notebooks_template.ipynb"> <img src="https://cloud.goog...
917
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: ISA Step1: Get layer data Step2: Get $p, T, \rho$ Step3: Note that the geopotential height can be provided as a numpy array Step4: If height is pro...
<ASSISTANT_TASK:> Python Code: # Import isa library from pyturb.gas_models import isa import numpy as np from matplotlib import pyplot as plt Explanation: ISA: Example of usage This Notebook serves as an example on how to use the Standard Atmosphere model provided with pyTurb. The isa functions can be found in the gas_...
918
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: ES-DOC CMIP6 Model Properties - Landice MIP Era Step1: Document Authors Set document authors Step2: Document Contributors Specify document contributo...
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'ipsl', 'sandbox-1', 'landice') Explanation: ES-DOC CMIP6 Model Properties - Landice MIP Era: CMIP6 Institute: IPSL Source ID: SANDBOX-1 Topic: Landice Sub-Topics: Gl...
919
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Plot 1 Step1: Description Step2: Load data and take a peak at it. Step3: Separate data into training, validation, and test sets. (This division is n...
<ASSISTANT_TASK:> Python Code: from IPython.display import display, HTML display(HTML('''<img src="image1.png",width=800,height=600>''')) Explanation: Plot 1: The predictive potential of rank difference End of explanation import numpy as np # numerical libraries import pandas as pd # for data analysis import matplotlib...
920
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Single Replica TIS This notebook shows how to run single replica TIS move scheme. This assumes you can load engine, network, and initial sample ...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import openpathsampling as paths import numpy as np import matplotlib.pyplot as plt import pandas as pd from openpathsampling.visualize import PathTreeBuilder, PathTreeBuilder from IPython.display import SVG, HTML def ipynb_visualize(movevis): Default settings to sh...
921
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Background Modeling When fitting a spectrum with a background, it is invalid to simply subtract off the background if the background is part of the dat...
<ASSISTANT_TASK:> Python Code: from threeML import * %matplotlib inline import warnings warnings.simplefilter('ignore') Explanation: Background Modeling When fitting a spectrum with a background, it is invalid to simply subtract off the background if the background is part of the data's generative model van Dyk et al. ...
922
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Estimating Trip Mode Choice This notebook illustrates how to re-estimate a single model component for ActivitySim. This process includes running Acti...
<ASSISTANT_TASK:> Python Code: import os import larch # !conda install larch -c conda-forge # for estimation import pandas as pd Explanation: Estimating Trip Mode Choice This notebook illustrates how to re-estimate a single model component for ActivitySim. This process includes running ActivitySim in estimation mode...
923
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Connect to Cloud SQL using the Cloud SQL Python Connector This notebook will be demonstrating how to connect and query data from a Cloud SQL database i...
<ASSISTANT_TASK:> Python Code: from google.colab import auth auth.authenticate_user() Explanation: Connect to Cloud SQL using the Cloud SQL Python Connector This notebook will be demonstrating how to connect and query data from a Cloud SQL database in an easy and efficient way all from within a jupyter style notebook! ...
924
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Примеры анализа данных аэрокосмической съемки Дмитрий Колесов (kolesov.dm@gmail.com) NextGIS О чем пойдет речь Что это за такие "Данные аэрокосмической...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd points = pd.read_csv('rand.txt') points.tail() y = points["class"] X = points[['r1', 'r2', 'r3', 'r4', 'r5', 'r6', 'r7', 'r8', 'r9', 'r10', 'r11']] # Разбиваем на обучающее и тестовое множества: from sklearn.model_selection import train_test_split X_...
925
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Example Step1: Now we should have a data/names directory which contains a number of text files, one for each year of data Step2: Let's take a quick l...
<ASSISTANT_TASK:> Python Code: # !curl -O http://www.ssa.gov/oact/babynames/names.zip # !mkdir -p data/names # !mv names.zip data/names/ # !cd data/names/ && unzip names.zip Explanation: Example: Names in the Wild This example is drawn from Wes McKinney's excellent book on the Pandas library, O'Reilly's Python for Data...
926
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Introduction to numerical simulations Step1: Now we will define the physical constants of our system, which will also establish the unit system we hav...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt Explanation: Introduction to numerical simulations: The 2 Body Problem Many problems in statistical physics and astrophysics require solving problems consisting of many particles at once (sometimes on the order of thous...
927
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: WARNING Step1: ================================ predict the mean and std of radius given those of the mass Step2: ================================ pr...
<ASSISTANT_TASK:> Python Code: import numpy as np import mr_forecast as mr import matplotlib.pyplot as plt %matplotlib inline Explanation: WARNING: "fitting_parameters.h5" need to be in the directory you are working on or there will be an error for importing mr_forecast in the next cell. If you don't want the file in t...
928
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Layout viewport Use the Layout class to create a variety of map views for comparison. For more information, run help(Layout). The first example sets a ...
<ASSISTANT_TASK:> Python Code: from cartoframes.auth import set_default_credentials set_default_credentials('cartoframes') Explanation: Layout viewport Use the Layout class to create a variety of map views for comparison. For more information, run help(Layout). The first example sets a common viewport for all maps whil...
929
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: ES-DOC CMIP6 Model Properties - Atmos MIP Era Step1: Document Authors Set document authors Step2: Document Contributors Specify document contributors...
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'test-institute-1', 'sandbox-1', 'atmos') Explanation: ES-DOC CMIP6 Model Properties - Atmos MIP Era: CMIP6 Institute: TEST-INSTITUTE-1 Source ID: SANDBOX-1 Topic: At...
930
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Analysis of Sealing Potential of Liner Captured Between Aluminum Rings Via Shrink Fit. First Objective Step1: ASME Pressure Vessel Code Equations This...
<ASSISTANT_TASK:> Python Code: # Import packages here: import math as m import numpy as np from IPython.display import Image import matplotlib.pyplot as plt # Properties of Materials (engineeringtoolbox.com, Cengel, Tian, DuPont, http://www.dtic.mil/dtic/tr/fulltext/u2/438718.pdf) # Coefficient of Thermal Expansion alp...
931
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 人脸生成(Face Generation) 在该项目中,你将使用生成式对抗网络(Generative Adversarial Nets)来生成新的人脸图像。 获取数据 该项目将使用以下数据集: - MNIST - CelebA 由于 CelebA 数据集比较复杂,而且这是你第一次使用 G...
<ASSISTANT_TASK:> Python Code: data_dir = './data' # FloydHub - Use with data ID "R5KrjnANiKVhLWAkpXhNBe" #data_dir = '/input' DON'T MODIFY ANYTHING IN THIS CELL import helper helper.download_extract('mnist', data_dir) helper.download_extract('celeba', data_dir) Explanation: 人脸生成(Face Generation) 在该项目中,你将使用生成式对抗网络(Gene...
932
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: AGREGACION DE DATOS DESDE EL DATASET DEL PROGRAMA DE INDICADORES DE GESTIÓN DE ORGANISMOS OPERADORES (PIGOO) En este documento se describen las conside...
<ASSISTANT_TASK:> Python Code: # Librerias utilizadas import pandas as pd import sys module_path = r'D:\PCCS\01_Dmine\Scripts' if module_path not in sys.path: sys.path.append(module_path) from SUN.asignar_sun import asignar_sun from SUN_integridad.SUN_integridad import SUN_integridad from SUN.CargaSunPrincipal impo...
933
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Tutorial for bulk Monte Carlo simulations in the structural-color package Copyright 2016, Vinothan N. Manoharan, Victoria Hwang, Annie Stephenson This ...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import structcol as sc import structcol.refractive_index as ri from structcol import montecarlo as mc from structcol import detector as det from structcol import phase_func_sphere as pfs import matplotlib.pyplot as plt import seaborn as sns import os ...
934
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Using Python as a Calculator Let's try some simple python commands Numbers The interpreter acts as a simple calculator Step1: With Python, use ** oper...
<ASSISTANT_TASK:> Python Code: 4 2 + 2 50 - 5*6 (50-5)*6 8/5 8//5 # Floor division discards the fractional part 8%5 # The % operator return the remainder of the division Explanation: Using Python as a Calculator Let's try some simple python commands Numbers The interpreter acts as a simple calculator: you can type an...
935
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: DCT-based Transform Coding of Images This code is provided as supplementary material of the lecture Quellencodierung. This code illustrates * Show basi...
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import matplotlib.image as mpimg from itertools import chain from scipy import fftpack import scipy as sp from ipywidgets import interactive, HBox, Label import ipywidgets as widgets %matplotlib inline Explanation: DCT-based Transform Cod...
936
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: Jupyter Notebook backend demo This example shows how vispy's low-level gloo interface can be used to display a WebGL canvas in a notebook. By de...
<ASSISTANT_TASK:> Python Code: import numpy as np import vispy import vispy.gloo as gloo from vispy import app from vispy.util.transforms import perspective, translate, rotate # load the vispy bindings manually for the notebook which enables webGL # %load_ext vispy n = 100 a_position = np.random.uniform(-1, 1, (n, 3))....
937
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Suggestions for lab exercises. Variables and assignment Exercise 1 Remember that $n! = n \times (n - 1) \times \dots \times 2 \times 1$. Compute $15!$,...
<ASSISTANT_TASK:> Python Code: fifteen_factorial = 15*14*13*12*11*10*9*8*7*6*5*4*3*2*1 print(fifteen_factorial) Explanation: Suggestions for lab exercises. Variables and assignment Exercise 1 Remember that $n! = n \times (n - 1) \times \dots \times 2 \times 1$. Compute $15!$, assigning the result to a sensible variable...
938
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Reinforcement Learning This IPy notebook acts as supporting material for Chapter 21 Reinforcement Learning of the book Artificial Intelligence Step1: ...
<ASSISTANT_TASK:> Python Code: from rl import * Explanation: Reinforcement Learning This IPy notebook acts as supporting material for Chapter 21 Reinforcement Learning of the book Artificial Intelligence: A Modern Approach. This notebook makes use of the implementations in rl.py module. We also make use of implementati...
939
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: Fitting a model to data with outliers using MCMC We are often faced with data with spurious outliers. For example, a light curve generated from ...
<ASSISTANT_TASK:> Python Code: def sinusoid(t, amp, period, phase): A generic sinusoidal curve. 'period' and 't' should have the same units (e.g., days), and phase should be in radians. Parameters ---------- t : array_like Array of times. amp :...
940
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Transfer Learning Most of the time you won't want to train a whole convolutional network yourself. Modern ConvNets training on huge datasets like Image...
<ASSISTANT_TASK:> Python Code: from urllib.request import urlretrieve from os.path import isfile, isdir from tqdm import tqdm vgg_dir = 'tensorflow_vgg/' # Make sure vgg exists if not isdir(vgg_dir): raise Exception("VGG directory doesn't exist!") class DLProgress(tqdm): last_block = 0 def hook(self, block_...
941
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Natural Language Processing (NLP) Overview corpus - collection of texts lexicon - collection of words (or sequences) we put into our index bag-of-words...
<ASSISTANT_TASK:> Python Code: from nltk.tokenize import TreebankWordTokenizer sentence = "How does nltk tokenize this sentence?" tokenizer = TreebankWordTokenizer() tokenizer.tokenize(sentence) Explanation: Natural Language Processing (NLP) Overview corpus - collection of texts lexicon - collection of words (or sequen...
942
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Web Scraping & Data Analysis with Selenium and Python Author Step1: Getting Data Step2: Store Data in a Python Dictionary Step3: Data before Clean ...
<ASSISTANT_TASK:> Python Code: %matplotlib inline from selenium import webdriver import os,time,json import pandas as pd from collections import defaultdict,Counter import matplotlib.pyplot as plt url = "http://www.imdb.com/list/ls061683439/" with open('./filmfare.json',encoding="utf-8") as f: datatbl = json.load(...
943
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Copyright 2021 The TF-Agents Authors. Step1: 网络 <table class="tfo-notebook-buttons" align="left"> <td> <a target="_blank" href="https Step2: 定义...
<ASSISTANT_TASK:> Python Code: #@title Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
944
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Deep Learning Assignment 5 The goal of this assignment is to train a Word2Vec skip-gram model over Text8 data. Step2: Download the data from the sourc...
<ASSISTANT_TASK:> Python Code: # These are all the modules we'll be using later. Make sure you can import them # before proceeding further. %matplotlib inline from __future__ import print_function import collections import math import numpy as np import os import random import tensorflow as tf import zipfile from matpl...
945
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: data checker this is just to verify the data for ms ssim net. Step1: everything looks good with c,s, cxs. now to check the down sampled images as well...
<ASSISTANT_TASK:> Python Code: import os os.environ['TF_CPP_MIN_LOG_LEVEL']='2' import numpy as np np.set_printoptions(threshold=np.nan) import tensorflow as tf import time import pandas as pd import matplotlib.pyplot as plt import progressbar data_path = 'https://raw.githubusercontent.com/michaelneuder/image_quality_a...
946
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Tutorial 17 - Navier Stokes equations Keywords Step1: 3. Affine Decomposition Step2: 4. Main program 4.1. Read the mesh for this problem The mesh was...
<ASSISTANT_TASK:> Python Code: from ufl import transpose from dolfin import * from rbnics import * Explanation: Tutorial 17 - Navier Stokes equations Keywords: exact parametrized functions, supremizer operator 1. Introduction In this tutorial, we will study the Navier-Stokes equations over the two-dimensional backward-...
947
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Object-oriented programming The big reveal So far we've been working with functions and packages of functions, as well as defining our own functions. ...
<ASSISTANT_TASK:> Python Code: x = 'Hi' x.lower() Explanation: Object-oriented programming The big reveal So far we've been working with functions and packages of functions, as well as defining our own functions. It turns out, though, that we've been working with objects all along, we just haven't recognize them as su...
948
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Hands-On Exercise 6 Step1: The first thing to notice is that the table does not include magnitude measurements. Gaaaasp The horror!! As an important p...
<ASSISTANT_TASK:> Python Code: # execute this cell SNlcs = Table.read("../data/Firth14Tbl2.txt", format = 'ascii') SNlcs Explanation: Hands-On Exercise 6: Determining $H_0$ with Type Ia SNe from PTF Version 0.1 Today we learned about a variety of different explosive, extragalactic transients. While the lectures focused...
949
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: 随机变量及其分布 Random Variable and its Distribution 包括以下内容: 1. 随机变量 Random Variable 2. 伯努利分布 Bernoulli Distribution 3. 二项分布 Binomial Distribution...
<ASSISTANT_TASK:> Python Code: import math import numpy as np import pandas as pd from pandas import Series, DataFrame # 引入绘图包 import matplotlib.pyplot as plt import seaborn as sns sns.set_style('whitegrid') %matplotlib inline Explanation: 随机变量及其分布 Random Variable and its Distribution 包括以下内容: 1. 随机变量 Random Variabl...
950
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: OOP in Action Step3: Explanation of the graph The graph portrays regions in which the $ (\lambda_1, \lambda_2) $ root pairs implied by the $ (\...
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt def param_plot(): this function creates the graph on page 189 of Sargent Macroeconomic Theory, second edition, 1987 fig, ax = plt.subplots(figsize=(12, 8)) ax.set_aspect('equal') # Set axis xmin, ymin = -3, -2 xmax...
951
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Directional Analysis of Dynamic LISAs This notebook demonstrates how to use Rose diagram based inference for directional LISAs. Step1: Visualization S...
<ASSISTANT_TASK:> Python Code: import pysal.lib import numpy as np from pysal.explore.giddy.directional import Rose %matplotlib inline f = open(pysal.lib.examples.get_path('spi_download.csv'), 'r') lines = f.readlines() f.close() lines = [line.strip().split(",") for line in lines] names = [line[2] for line in lines[1:...
952
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Vertex AI Step1: Install the latest GA version of google-cloud-storage library as well. Step2: Restart the kernel Once you've installed the additiona...
<ASSISTANT_TASK:> Python Code: import os # Google Cloud Notebook if os.path.exists("/opt/deeplearning/metadata/env_version"): USER_FLAG = "--user" else: USER_FLAG = "" ! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG Explanation: Vertex AI: Vertex AI Migration: Custom Image Classification w/pre-built...
953
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Insertion Sort (Insert Sort) Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time. It is much l...
<ASSISTANT_TASK:> Python Code: def insertion_sort(unsorted_list): x = ipytracer.List1DTracer(unsorted_list) display(x) for i in range(1, len(x)): j = i - 1 key = x[i] while x[j] > key and j >= 0: x[j+1] = x[j] j = j - 1 x[j+1] = key return x.data ...
954
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Unsupvervised Learning Step1: Let's start with $k=3$, arbitrarily assigned Step2: We can use the function cdist from SciPy to calculate the distances...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import seaborn as sns; sns.set_context('notebook') import numpy as np import matplotlib.pyplot as plt from sklearn import datasets iris = datasets.load_iris() features, target = iris.data, iris.target sepal_length, sepal_width, petal_length, petal_width = features.T x, ...
955
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Rechunking Rechunking lets us re-distribute how datasets are split between variables and chunks across a Beam PCollection. To get started we'll recreat...
<ASSISTANT_TASK:> Python Code: import apache_beam as beam import numpy as np import xarray_beam as xbeam import xarray def create_records(): for offset in [0, 4]: key = xbeam.Key({'x': offset, 'y': 0}) data = 2 * offset + np.arange(8).reshape(4, 2) chunk = xarray.Dataset({ 'foo':...
956
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Copyright 2020 Google LLC. Licensed under the Apache License, Version 2.0 (the "License"); Step1: Goal We want to build a model $h_\theta(s) \rightarr...
<ASSISTANT_TASK:> Python Code: #@title Default title text # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
957
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: DATASCI W261 Step1: HW 10.0 Step2: HW 10.1 Step3: HW 10.1.1 Modify the above word count code to count words that begin with lower case letters (a-z)...
<ASSISTANT_TASK:> Python Code: %cd ~/Documents/W261/hw10/ import os import sys spark_home = os.environ['SPARK_HOME'] = \ '/Users/davidadams/packages/spark-1.5.1-bin-hadoop2.6/' if not spark_home: raise ValueError('SPARK_HOME enviroment variable is not set') sys.path.insert(0,os.path.join(spark_home,'python')) sy...
958
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: <h1 align="center">TensorFlow Neural Network Lab</h1> <img src="image/notmnist.png"> In this lab, you'll use all the tools you learned from Introductio...
<ASSISTANT_TASK:> Python Code: import hashlib import os import pickle from urllib.request import urlretrieve import numpy as np from PIL import Image from sklearn.model_selection import train_test_split from sklearn.preprocessing import LabelBinarizer from sklearn.utils import resample from tqdm import tqdm from zipfil...
959
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Example 4 This project is for deep MNIST for experts. Step1: Build a Multilayer Convolutional Network This section will help to build more complex mod...
<ASSISTANT_TASK:> Python Code: from tensorflow.examples.tutorials.mnist import input_data import tensorflow as tf mnist = input_data.read_data_sets('MNIST_data', one_hot = True) ################## build a softmax regression model # input data x = tf.placeholder(tf.float32, shape = [None, 784]) # real labels y_ = tf.pla...
960
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Introduction The purpose of this product is to classify population depending on their uses of their phone and phone brands. This classification is the ...
<ASSISTANT_TASK:> Python Code: #Uplaod the data into the notbook and select the rows that will be used after previous visual inspection of the datasets datadir = 'D:/Users/Borja.gonzalez/Desktop/Thinkful-DataScience-Borja' gatrain = pd.read_csv('gender_age_train.csv',usecols=['device_id','gender','age','group'] ) gates...
961
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Algo - jeux de dictionnaires, plus grand suffixe commun Les dictionnaires sont très utilisés pour associer des choses entre elles, surtout quand ces ch...
<ASSISTANT_TASK:> Python Code: from jyquickhelper import add_notebook_menu add_notebook_menu() Explanation: Algo - jeux de dictionnaires, plus grand suffixe commun Les dictionnaires sont très utilisés pour associer des choses entre elles, surtout quand ces choses ne sont pas entières. Le notebook montre l'intérêt de pe...
962
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: infusionDrug Continuous infusions are documented here and are entered from the nursing flowsheet (either manually or interfaced from the hospital elect...
<ASSISTANT_TASK:> Python Code: # Import libraries import numpy as np import pandas as pd import matplotlib.pyplot as plt import psycopg2 import getpass import pdvega # for configuring connection from configobj import ConfigObj import os %matplotlib inline # Create a database connection using settings from config file ...
963
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: FFT Amplitude Scaling The relative amplitude of a sideband follows the relative amplitude of the peak in the FFT. Step1: Note, this also holds for int...
<ASSISTANT_TASK:> Python Code: from numpy.fft import * import numpy t = numpy.arange(0,100) data = 5*numpy.sin(t) + 3*numpy.sin(0.5*t) %pylab inline plot(data) fft_out = abs(fft.fft(data)) fft_out.max() plot(fft_out) from scipy.signal import find_peaks_cwt peak_ind = find_peaks_cwt(fft_out, numpy.arange(1,3)) fft_out[p...
964
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Optimisation Step2: We can still easily generate some data Step3: And we can define a log likelihood, and use optimisation to try and find bac...
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np import pints import pints.plot class BadLogisticModel(pints.ForwardModel): Logistic model of population growth with unidentifiable parameters. def __init__(self): super(BadLogisticModel, self).__init__() ...
965
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Performing Scenario Discovery in Python The purpose of example is to demonstrate how one can do scenario discovery in python. I will demonstrate how we...
<ASSISTANT_TASK:> Python Code: import pandas as pd data = pd.read_csv("./data/bryant et al 2010 data.csv", index_col=False) x = data.iloc[:, 2:11] y = data.iloc[:, 15].values Explanation: Performing Scenario Discovery in Python The purpose of example is to demonstrate how one can do scenario discovery in python. I will...
966
<SYSTEM_TASK:> Given the following text problem statement, write Python code to implement the functionality described below in problem statement <END_TASK> <USER_TASK:> Problem: Using scipy, is there an easy way to emulate the behaviour of MATLAB's dctmtx function which returns a NxN (ortho-mode normed) DCT matrix for ...
<ASSISTANT_TASK:> Python Code: import numpy as np import scipy.fft as sf N = 8 result = sf.dct(np.eye(N), axis=0, norm= 'ortho') <END_TASK>
967
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Machine Learning with Python and Scikit Learn Follow presentation on Step1: <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br></br> <br>...
<ASSISTANT_TASK:> Python Code: import warnings import numpy as np import pandas as pd from time import time import matplotlib.pyplot as plt from matplotlib.colors import ListedColormap from sklearn import datasets from sklearn.decomposition import PCA from sklearn.linear_model import LogisticRegression from sklearn.lin...
968
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Basic Python Explorations This is our first IPython nootebook, which we are going to use to explore the very basics of Python programming, Step1: As s...
<ASSISTANT_TASK:> Python Code: print('hello world') Explanation: Basic Python Explorations This is our first IPython nootebook, which we are going to use to explore the very basics of Python programming, End of explanation # This is an online comment: Python3 print('hello world') # Python2: print 'hello world' Explanat...
969
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Google PageRank Google's dominance as a search engine came from their PageRank algorithm, named after co-founder Larry Page. By assigning each page a ...
<ASSISTANT_TASK:> Python Code: A = np.array([[0, 2, 0, 5], [1, 0, 5, 6], [2, 4, 0, 3], [1, 0, 10, 2]]) labels = ['Google', 'Twitter', 'Facebook', 'Reddit'] graph.draw_matrix(A, labels) Explanation: Google PageRank Google's dominance as a search engine came from their...
970
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Quickstart This notebook was made with the following version of emcee Step1: The easiest way to get started with using emcee is to use it for a projec...
<ASSISTANT_TASK:> Python Code: import emcee emcee.__version__ Explanation: Quickstart This notebook was made with the following version of emcee: End of explanation import numpy as np Explanation: The easiest way to get started with using emcee is to use it for a project. To get you started, here’s an annotated, fully-...
971
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Additional forces REBOUND is a gravitational N-body integrator. But you can also use it to integrate systems with additional, non-gravitational forces....
<ASSISTANT_TASK:> Python Code: import rebound sim = rebound.Simulation() sim.integrator = "whfast" sim.add(m=1.) sim.add(m=1e-6,a=1.) sim.move_to_com() # Moves to the center of momentum frame Explanation: Additional forces REBOUND is a gravitational N-body integrator. But you can also use it to integrate systems with ...
972
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Lecture 13 Step1: With NumPy arrays, all the same functionality you know and love from lists is still there. Step2: These operations all work whether...
<ASSISTANT_TASK:> Python Code: li = ["this", "is", "a", "list"] print(li) print(li[1:3]) # Print element 1 (inclusive) to 3 (exclusive) print(li[2:]) # Print element 2 and everything after that print(li[:-1]) # Print everything BEFORE element -1 (the last one) Explanation: Lecture 13: Array Indexing, Slicing, and B...
973
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Dates pivot table Step1: Get collection information from ArticleMeta Step2: Filtering valid collections and renames 'code' to 'collection' Some colle...
<ASSISTANT_TASK:> Python Code: from datetime import datetime start = datetime.utcnow() # For measuring the total processing time import json from urllib.request import urlopen import pandas as pd import numpy as np Explanation: Dates pivot table End of explanation AMC_URL = "http://articlemeta.scielo.org/api/v1/collect...
974
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Fully-Connected Neural Nets In the previous homework you implemented a fully-connected two-layer neural network on CIFAR-10. The implementation ...
<ASSISTANT_TASK:> Python Code: # As usual, a bit of setup from __future__ import print_function import time import numpy as np import matplotlib.pyplot as plt from cs231n.classifiers.fc_net import * from cs231n.data_utils import get_CIFAR10_data from cs231n.gradient_check import eval_numerical_gradient, eval_numerical_...
975
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: <center><h2>Scale your pandas workflows by changing one line of code</h2> Getting Started To install the most recent stable release for Modin run the f...
<ASSISTANT_TASK:> Python Code: !pip install modin[all] Explanation: <center><h2>Scale your pandas workflows by changing one line of code</h2> Getting Started To install the most recent stable release for Modin run the following code on your command line: End of explanation import modin.pandas as pd import pandas #####...
976
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Spectral Line Data Cubes in Astronomy - Part 1 In this notebook we will introduce spectral line data cubes in astronomy. They are a convenient way to s...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt Explanation: Spectral Line Data Cubes in Astronomy - Part 1 In this notebook we will introduce spectral line data cubes in astronomy. They are a convenient way to store many spectra at points in the sky. Much like having a spectrum at eve...
977
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Considering our data Our initial goal was to apply a ML approach to accurately predict the likelihood of a wildfire occuring. The data we used was firs...
<ASSISTANT_TASK:> Python Code: import pandas as pd df = pd.io.parsers.read_csv( 'Data/NewBalanced.csv', ) print(df.shape) print('\n') print(df.head(5)) print('\n') print(df.tail(1)) Explanation: Considering our data Our initial goal was to apply a ML approach to accurately predict the likelihood of a wildfire occur...
978
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: IS620 - Document Classification Daina Bouquin Spam Filtering and Classification Step1: Summaries Step2: Split data into two datasets Step3: Random f...
<ASSISTANT_TASK:> Python Code: import nltk import numpy as np import pandas as pd %matplotlib inline # pull in the spam dataset spam = pd.read_csv("spambase.csv") Explanation: IS620 - Document Classification Daina Bouquin Spam Filtering and Classification End of explanation # Summary stats spam.describe() # Variable ty...
979
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described. <END_TASK> <USER_TASK:> Description: You are given a 2 dimensional data, as a nested lists, which is similar to matrix, however, unlike matrices, each row may contain a different number of column...
<ASSISTANT_TASK:> Python Code: def get_row(lst, x): coords = [(i, j) for i in range(len(lst)) for j in range(len(lst[i])) if lst[i][j] == x] return sorted(sorted(coords, key=lambda x: x[1], reverse=True), key=lambda x: x[0]) <END_TASK>
980
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Tensor Network Random Unitary Evolution This example demonstrates some features of TensorNetwork manipulation as well as the use of MatrixProductState....
<ASSISTANT_TASK:> Python Code: %matplotlib inline from quimb.tensor import * from quimb import * import numpy as np Explanation: Tensor Network Random Unitary Evolution This example demonstrates some features of TensorNetwork manipulation as well as the use of MatrixProductState.gate, based on 'evolving' an intitial MP...
981
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Outline Glossary 2. Mathematical Groundwork Previous Step1: Import section specific modules Step3: 2.8. The Discrete Fourier Transform (DFT) and the ...
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt %matplotlib inline from IPython.display import HTML HTML('../style/course.css') #apply general CSS Explanation: Outline Glossary 2. Mathematical Groundwork Previous: 2.7 Fourier Theorems Next: 2.9 Sampling Theory Import standard modules:...
982
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: A brief tutorial of basic python From the wikipedia Step1: It is easy to check the type of a variable with the type() command Step2: The following co...
<ASSISTANT_TASK:> Python Code: str1 = '"Hola" is how we say "hello" in Spanish.' str2 = "Strings can also be defined with quotes; try to be sistematic." Explanation: A brief tutorial of basic python From the wikipedia: "Python is a widely used general-purpose, high-level programming language. Its design philosophy emph...
983
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Now a distance cut Step1: Stars I actually observed Step2: Data for the observed stars Step3: Comparison of stars observed with Catalina Step4: Iss...
<ASSISTANT_TASK:> Python Code: d = triand['dh'].data d_cut = (d > 15) & (d < 21) triand_dist = triand[d_cut] c_triand = _c_triand[d_cut] print(len(triand_dist)) plt.hist(triand_dist['<Vmag>'].data) Explanation: Now a distance cut: End of explanation ptf_triand = ascii.read("/Users/adrian/projects/streams/data/observing...
984
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Matplotlib Exercise 1 Imports Step1: Line plot of sunspot data Download the .txt data for the "Yearly mean total sunspot number [1700 - now]" from the...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np Explanation: Matplotlib Exercise 1 Imports End of explanation import os assert os.path.isfile('yearssn.dat') Explanation: Line plot of sunspot data Download the .txt data for the "Yearly mean total sunspot number [1700 ...
985
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Grouping all encounter nbrs under respective person nbr Step1: Now grouping other measurements and properties under encounter_nbrs Step2: Aggregating...
<ASSISTANT_TASK:> Python Code: encounter_key = 'Enc_Nbr' person_key = 'Person_Nbr' encounters_by_person = {} for df in dfs: if df is not None: df_columns =set(df.columns.values) if encounter_key in df_columns and person_key in df_columns: for row_index, dfrow in df.iterrows(): ...
986
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: while loops The while statement in Python is one of most general ways to perform iteration. A while statement will repeatedly execute a single statemen...
<ASSISTANT_TASK:> Python Code: x = 0 while x < 10: print 'x is currently: ',x print ' x is still less than 10, adding 1 to x' x+=1 Explanation: while loops The while statement in Python is one of most general ways to perform iteration. A while statement will repeatedly execute a single statement or group of...
987
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Optimization Methods Until now, you've always used Gradient Descent to update the parameters and minimize the cost. In this notebook, you will learn mo...
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import scipy.io import math import sklearn import sklearn.datasets from opt_utils import load_params_and_grads, initialize_parameters, forward_propagation, backward_propagation from opt_utils import compute_cost, predict, predict_dec, plo...
988
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Cálculos en vecindades I En este taller vamos a utilizar Python para calcular un par de variables, asociadas a cada polígono del espacio, en función de...
<ASSISTANT_TASK:> Python Code: import geopandas as gpd denue = gpd.read_file("datos/DENUE_INEGI_09_.shp") denue.head() Explanation: Cálculos en vecindades I En este taller vamos a utilizar Python para calcular un par de variables, asociadas a cada polígono del espacio, en función de las propiedades de los polígonos vec...
989
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Motion Functions In this notebook you will learn how use Python functions for moving the robot in your programs. First, the initialization step needs t...
<ASSISTANT_TASK:> Python Code: # click on this cell and press Shift+Enter import packages.initialization import pioneer3dx as p3dx p3dx.init() Explanation: Motion Functions In this notebook you will learn how use Python functions for moving the robot in your programs. First, the initialization step needs to be executed...
990
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Active Directory Replication From Non-Domain-Controller Accounts Metadata | | | | Step1: Download & Process Mordor Dataset Step2:...
<ASSISTANT_TASK:> Python Code: from openhunt.mordorutils import * spark = get_spark() Explanation: Active Directory Replication From Non-Domain-Controller Accounts Metadata | | | |:------------------|:---| | collaborators | ['@Cyb3rWard0g', '@Cyb3rPandaH'] | | creation date | 2018/08/15 | |...
991
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Your first neural network In this project, you'll build your first neural network and use it to predict daily bike rental ridership. We've provided som...
<ASSISTANT_TASK:> Python Code: %matplotlib inline %config InlineBackend.figure_format = 'retina' import numpy as np import pandas as pd import matplotlib.pyplot as plt Explanation: Your first neural network In this project, you'll build your first neural network and use it to predict daily bike rental ridership. We've ...
992
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: With the variables we found so far here, we achieved a maximum performance of 75% (ROC AUC), so let's try to extract some more features in order to inc...
<ASSISTANT_TASK:> Python Code: #I'm considering only Acquisitions made in USA, with USD (dollars) acquisitions = pd.read_csv('data/acquisitions.csv') acquisitions = acquisitions[acquisitions['acquirer_country_code'] == 'USA'] acquisitions[:3] #acquirer_permalink #rounds_agg = df_rounds.groupby(['company_permalink', 'fu...
993
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Fitting a linear model fp1 Step1: Linear Function Step2: Fitting the model with polynomial degree of 2 Step3: Trying to fir the model with 53 polyn...
<ASSISTANT_TASK:> Python Code: # starting with linear model where degree is 1 # polyfit() - best put that line into the chart so that it results in the smallest # approximation error fp1, residuals, rank, sv, rcond = sp.polyfit(X, y, 1, full=True) fp1 Explanation: Fitting a linear model fp1 End of explanation print(res...
994
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: BigQuery query magic Jupyter magics are notebook-specific shortcuts that allow you to run commands with minimal syntax. Jupyter notebooks come with man...
<ASSISTANT_TASK:> Python Code: %%bigquery SELECT name, SUM(number) as count FROM `bigquery-public-data.usa_names.usa_1910_current` GROUP BY name ORDER BY count DESC LIMIT 10 Explanation: BigQuery query magic Jupyter magics are notebook-specific shortcuts that allow you to run commands with minimal syntax. Jupyter noteb...
995
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Setup Cosmology Step1: Create Stellar Population Step2: Calculate a few things to get going. Step5: Define the functions that we'll need Need to com...
<ASSISTANT_TASK:> Python Code: cosmo = LambdaCDM(H0=70, Om0=0.3, Ode0=0.7, Tcmb0=2.725) Explanation: Setup Cosmology End of explanation # check to make sure we have defined the bpz filter path if not os.getenv('EZGAL_FILTERS'): os.environ['EZGAL_FILTERS'] = (f'{os.environ["HOME"]}/Projects/planckClusters/MOSAICpipe...
996
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Using Fourier Analysis to Analyze Quasi-Periodic Oscillations By Abigail Stevens Problem 1 Step1: 1a. Compute the time steps and a cosine harmonic wit...
<ASSISTANT_TASK:> Python Code: a = Table() a.meta['dt'] = 0.0001 # time step, in seconds a.meta['duration'] = 200 # length of time, in seconds a.meta['omega'] = 2*np.pi # angular frequency, in radians a.meta['phi'] = 0.0 # offset angle, in radians Explanation: Using Fourier Analysis to Analyze Quasi-Periodic Oscilla...
997
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Plotting a line chart in matplotlib Step1: Plotting a line chart from a Pandas object Step2: Creating bar charts Step3: Creating a pie chart Step4: ...
<ASSISTANT_TASK:> Python Code: x=range(1,10) y=[1,2,3,4,0,4,3,2,1] plt.plot(x,y) Explanation: Plotting a line chart in matplotlib End of explanation # address = some data set # cars = pd.read_csv(address) # cars.columns = ['car_names','mpg','cyl','disp','hp','drat','wt','qsec','vs','am',gear',carb'] #mpg = cars['mpg']...
998
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: How to download CMEMS SLTAC products from the CMEMS ftp server ? some python imports Step1: init the connection to the ftp server Step2: What is in t...
<ASSISTANT_TASK:> Python Code: from ftplib import FTP import os import numpy as np Explanation: How to download CMEMS SLTAC products from the CMEMS ftp server ? some python imports End of explanation ftp = FTP('ftp.sltac.cls.fr') ftp.login('pprandi','PierreCMEMS2017') Explanation: init the connection to the ftp server...
999
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Table of Contents Preparation User data vectors Graphs Preparation <a id=preparation /> Step1: Data vectors of users <a id=userdatavectors /> Step2: ...
<ASSISTANT_TASK:> Python Code: %run "../Functions/4. User comparison.ipynb" Explanation: Table of Contents Preparation User data vectors Graphs Preparation <a id=preparation /> End of explanation # small sample #allData = getAllUserVectorData( getAllUsers()[:10] ) # complete set #allData = getAllUserVectorData( getAllU...