text_prompt
stringlengths
168
30.3k
code_prompt
stringlengths
67
124k
<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: <a id="ref0"></a> Step2: Use the following function to calculate accuracy Step3: <a id="ref1"></a> Step4: Define a function to train the mode...
<ASSISTANT_TASK:> Python Code: !conda install -y torchvision import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import matplotlib.pyplot as plt from matplotlib.colors import ListedColormap def plot_decision_regions_2class(model,data_set): cmap_light = ListedColormap(['#FFAAAA',...
<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: original output Step2: Recreate validation set and sample Step3: Examine the driver_imgs_list.csv
<ASSISTANT_TASK:> Python Code: #Create directories %cd $DATA_HOME_DIR # did this once %mkdir valid %mkdir results %mkdir -p sample/train %mkdir -p sample/test %mkdir -p sample/valid %mkdir -p sample/results %mkdir -p test/unknown # Create subdirectories for c in categories: %mkdir -p valid/{c} %mkdir -p sample/...
<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: Plot histogram of average ratings by revision Step2: Selected harassing and aggressive revisions by quartile Step3: Inter-Annotator Agreement
<ASSISTANT_TASK:> Python Code: %matplotlib inline from __future__ import division import pandas as pd import numpy as np import matplotlib.pyplot as plt pd.set_option('display.max_colwidth', 1000) # Download data from google drive (Respect Eng / Wiki Collab): wikipdia data/v0_annotated dat = pd.read_csv('../data/experi...
<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: 1. Model-based parametric regression Step2: 2.2. Summary Step3: Fit a Bayesian linear regression model assuming ${\bf z}={\bf x}$ and Step4: ...
<ASSISTANT_TASK:> Python Code: # Import some libraries that will be necessary for working with data and displaying plots # To visualize plots in the notebook %matplotlib inline from IPython import display import matplotlib import matplotlib.pyplot as plt import numpy as np import scipy.io # To read matlab files ...
<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: Tensorflow Lattice์™€ ํ˜•์ƒ ์ œ์•ฝ ์กฐ๊ฑด Step2: ํ•„์ˆ˜ ํŒจํ‚ค์ง€ ๊ฐ€์ ธ์˜ค๊ธฐ Step3: ์ด ๊ฐ€์ด๋“œ์—์„œ ์‚ฌ์šฉ๋˜๋Š” ๊ธฐ๋ณธ๊ฐ’ Step4: ๋ ˆ์Šคํ† ๋ž‘ ์ˆœ์œ„ ์ง€์ •์„ ์œ„ํ•œ ํ›ˆ๋ จ ๋ฐ์ดํ„ฐ์„ธํŠธ Step6: ์ด CTR ํ•จ์ˆ˜์˜ ๋“ฑ๊ณ ์„ ๋„๋ฅผ ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. Step7...
<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...
<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: 10.1. Spatiocyte Lattice-based Method Step2: There is a distinct difference in the second argument for spatiocyte.World. This is called voxel r...
<ASSISTANT_TASK:> Python Code: %matplotlib inline from ecell4.prelude import * with species_attributes(): A | B | C | {'D': 1} with reaction_rules(): A + B == C | (0.01, 0.3) m = get_model() w = spatiocyte.World(ones(), 0.005) # The second argument is 'voxel_radius'. w.bind_to(m) w.add_molecules(Species('C'),...
<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: Load in house sales data Step2: Create new features Step3: Squaring bedrooms will increase the separation between not many bedrooms (e.g. 1) a...
<ASSISTANT_TASK:> Python Code: import graphlab graphlab.product_key.set_product_key("C0C2-04B4-D94B-70F6-8771-86F9-C6E1-E122") sales = graphlab.SFrame('kc_house_data.gl/kc_house_data.gl') from math import log, sqrt sales['sqft_living_sqrt'] = sales['sqft_living'].apply(sqrt) sales['sqft_lot_sqrt'] = sales['sqft_lot']...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import torch A, B = load_data() cnt_not_equal = int((A[int(len(A) / 2):] != B[int(len(A) / 2):]).sum()) <END_TASK>
<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: The global collection of tide gauge records at the PSMSL is used to access the data. The other way to access the data is to ask the service desk...
<ASSISTANT_TASK:> Python Code: # this is a list of packages that are used in this notebook # these come with python import io import zipfile import functools # you can install these packages using pip or anaconda # (requests numpy pandas bokeh pyproj statsmodels) # for downloading import requests # computation librarie...
<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: The code above also defines a stardard conformal $\mathbb{R}^{N+1,1}$ layout without this new basis vector. This is primarily to support renderi...
<ASSISTANT_TASK:> Python Code: from clifford import ConformalLayout, BasisVectorIds, MultiVector, transformations class OurCustomLayout(ConformalLayout): def __init__(self, ndims): self.ndims = ndims euclidean_vectors = [str(i + 1) for i in range(ndims)] conformal_vectors = ['m2', '...
<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: Load the database webserver. Step2: Import the web interface and initialize it. Step3: The instructions below assume that these three steps ha...
<ASSISTANT_TASK:> Python Code: # you must specify the length of the time series when loading the database ts_length = 100 # when running from the terminal # python go_server_persistent.py --ts_length 100 --db_name 'demo' # here we load the server as a subprocess for demonstration purposes server = subprocess.Popen(['py...
<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: 1.4.2 Code Management with Git Step4: 1.5.6 SDSS DR7 Quasar Catalog Step5: Access BOSS spectra and metadata Step6: Read the DR12 quasar catal...
<ASSISTANT_TASK:> Python Code: %pylab inline import astroML print astroML.__version__ SDSS Spectrum Example --------------------- Figure 1.2. An example of an SDSS spectrum (the specific flux plotted as a function of wavelength) loaded from the SDSS SQL server in real time using Python tools provided here (this spectr...
<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: Set up default parameters. We use 32 subjects, which is the median sample size of the set of fMRI studies published between 2011 and 2015 that ...
<ASSISTANT_TASK:> Python Code: import numpy import nibabel import os import nilearn.plotting import matplotlib.pyplot as plt from statsmodels.regression.linear_model import OLS import nipype.interfaces.fsl as fsl import scipy.stats if not 'FSLDIR' in os.environ.keys(): raise Exception('This notebook requires that F...
<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: ้žใ‚ฌใ‚ฆใ‚นๅž‹่ฆณๆธฌใซใ‚ˆใ‚‹ STS ใƒขใƒ‡ใƒซใฎ่ฟ‘ไผผๆŽจ่ซ– Step2: ๅˆๆˆใƒ‡ใƒผใ‚ฟ Step3: ใƒขใƒ‡ใƒซ Step4: ใ“ใฎใƒขใƒ‡ใƒซใฏใ€่ฆณๆธฌใ•ใ‚ŒใŸๆ™‚็ณปๅˆ—ใงๆผ”็ฎ—ใ™ใ‚‹ไปฃใ‚ใ‚Šใซใ€่ฆณๆธฌใ‚’็ฎก็†ใ™ใ‚‹ใƒใƒฏใ‚ฝใƒณๅž‹ใƒฌใƒผใƒˆใƒ‘ใƒฉใƒกใƒผใ‚ฟใฎ็ณปๅˆ—ใงๆผ”็ฎ—ใ—ใพใ™ใ€‚ Step5: ้žใ‚ฌใ‚ฆใ‚นๅž‹่ฆณๆธฌใƒขใƒ‡ใƒซใซ่ฟ‘ไผผๆŽจ่ซ–ใ‚’ไฝฟ็”จใ™ใ‚‹ใŸใ‚...
<ASSISTANT_TASK:> Python Code: #@title Licensed under the Apache License, Version 2.0 (the "License"); { display-mode: "form" } # 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 l...
<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: Configure environment settings Step2: Importing the dataset into BigQuery Step3: Explore the Covertype dataset Step4: Create training and val...
<ASSISTANT_TASK:> Python Code: import json import os import pickle import tempfile import time import uuid from typing import NamedTuple import numpy as np import pandas as pd from google.cloud import bigquery from googleapiclient import discovery, errors from jinja2 import Template from kfp.components import func_to_c...
<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: Let's load and examine the titanic data with pandas first. Step2: So we have 891 training examples with 10 information columns given. Of course...
<ASSISTANT_TASK:> Python Code: #import all the needed package import numpy as np import scipy as sp import re import pandas as pd import sklearn from sklearn.cross_validation import train_test_split,cross_val_score from sklearn.preprocessing import StandardScaler from sklearn import metrics import matplotlib from matp...
<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: Import data from Google Clod Storage Step2: Prepare data for ARIMA Step3: Let's create a column for weekly returns. Take the log to of the ret...
<ASSISTANT_TASK:> Python Code: !pip install --user statsmodels %matplotlib inline import pandas as pd import matplotlib.pyplot as plt import numpy as np import datetime %config InlineBackend.figure_format = 'retina' df = pd.read_csv('gs://cloud-training/ai4f/AAPL10Y.csv') df['date'] = pd.to_datetime(df['date']) df.sor...
<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: We are going to use a simple cnn network as our encoder and decoder. In decoder, we use SpatialFullConvolution (aka deconvolution or convolution...
<ASSISTANT_TASK:> Python Code: # a bit of setup import numpy as np from bigdl.nn.criterion import * from bigdl.dataset import mnist from zoo.pipeline.api.keras.layers import * from zoo.pipeline.api.keras.models import Model from zoo.pipeline.api.keras.utils import * import datetime as dt IMAGE_SIZE = 784 IMAGE_ROWS = 2...
<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: ๅฐฑๅฏไปฅไธ‹่ฝฝๅˆฐ๏ผŒ็„ถๅŽๅฏไปฅๆ‰พๅˆฐไธ€ไธชๅซๅšmeetingminitus.pdf็š„ๆ–‡ไปถใ€‚่ฟ™ไธชๅฐฑๆ˜ฏๆˆ‘ไปฌๆŽฅไธ‹ๆฅ่ฆ็”จ็š„ Step2: ๅฅฝใ€‚็Žฐๅœจๆฅ่ฏ•่ฏ•ๆˆ‘่‡ชๅทฑ็”จlatexๅ†™็š„pdfๆ–‡ๆกฃใ€‚
<ASSISTANT_TASK:> Python Code: wget https://nostarch.com/download/Automate_the_Boring_Stuff_onlinematerials_v.2.zip import PyPDF2 with open('./automate_online-materials/meetingminutes.pdf', 'rb') as f: pdfreader = PyPDF2.PdfFileReader(f) print(pdfreader.numPages) page0 = pdfreader.getPage(0) page0...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step3: Part 0 Step4: In this lab we will be examining subsets of the tuples we create (e.g., the top rated movies by users). Whenever we examine only ...
<ASSISTANT_TASK:> Python Code: import sys import os from test_helper import Test baseDir = os.path.join('data') inputPath = os.path.join('cs100', 'lab4', 'small') ratingsFilename = os.path.join(baseDir, inputPath, 'ratings.dat.gz') moviesFilename = os.path.join(baseDir, inputPath, 'movies.dat') numPartitions = 2 rawRa...
<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: We need to import here the data, modify them if needed and proceed
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import pandas as pd import matplotlib.pyplot as plt from simmit import smartplus as sim import os dir = os.path.dirname(os.path.realpath('__file__')) umat_name = 'MIPLN' #This is the 5 character code for the periodic homogenization for multlayered co...
<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: SBML Step2: There are other dialects of SBML prior to FBC 2 which have previously been use to encode COBRA models. The primary ones is the "COB...
<ASSISTANT_TASK:> Python Code: import cobra.test import os from os.path import join data_dir = cobra.test.data_directory print("mini test files: ") print(", ".join(i for i in os.listdir(data_dir) if i.startswith("mini"))) textbook_model = cobra.test.create_test_model("textbook") ecoli_model = cobra.test...
<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: Now let's pretend that we feel there are too many features, and many are probably useless. We only want the top 100 for making our model. Step2:...
<ASSISTANT_TASK:> Python Code: npoints = 100 nfeatures = int(5e4) rng = np.random.default_rng() X = rng.random(size=(npoints, nfeatures)); Y = rng.random(size=(npoints,)) > 0.5 def select_best_features(X, Y, n=100): corrs = np.zeros(X.shape[1]) for ii in range(X.shape[1]): corrs[ii] = np.corrcoef(X[:, ...
<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: Transforming an input to a known output Step2: relation between input and output is linear Step3: Defining the model to train Step5: Defining...
<ASSISTANT_TASK:> Python Code: !pip install -q tf-nightly-gpu-2.0-preview import tensorflow as tf print(tf.__version__) # a small sanity check, does tf seem to work ok? hello = tf.constant('Hello TF!') print("This works: {}".format(hello)) # this should return True even on Colab tf.test.is_gpu_available() tf.test.is_bu...
<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: If you look above you can see that we are accessing a csv file that has the locations of the podcasts, taking the html data and parsing it, to l...
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import urllib2 import re import wget import os os.chdir('/Users/sheldon/git/springboard_capstone/acquire_podcasts') df = pd.read_csv('top100_pcasts_locations.csv') urls = df.url.tolist() urls = filter(lambda string: 'feeds.' in string or 'feed.' in s...
<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: Note that a similar transformation can be applied with compute_ems
<ASSISTANT_TASK:> Python Code: # Author: Denis Engemann <denis.engemann@gmail.com> # Jean-Remi King <jeanremi.king@gmail.com> # # License: BSD (3-clause) import numpy as np import matplotlib.pyplot as plt import mne from mne import io, EvokedArray from mne.datasets import sample from mne.decoding import EMS, co...
<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: Load the Data Step2: Create the Model Step3: Training the Model Step4: Store the Model
<ASSISTANT_TASK:> Python Code: # ใ‚ฐใƒฉใƒ•ใŒๆ–‡็ซ ไธญใซ่กจ็คบใ•ใ‚Œใ‚‹ใ‚ˆใ†ใซใ™ใ‚‹ใŠใพใ˜ใชใ„ %matplotlib inline # autoreload module %load_ext autoreload %autoreload 2 # load local package import sys import os current_path = os.getcwd() sys.path.append(os.path.join(current_path, "../../")) # load project root def read_data(path, ignore_columns): imp...
<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: 1 Introduction Step2: Ou importer le module matplotlib.pyplot avec l'identifiant plt. Plus correct pour รฉviter de charger tous les objets Step3...
<ASSISTANT_TASK:> Python Code: %matplotlib inline from pylab import * # import matplotlib import matplotlib.pyplot as plt import numpy as np from pylab import * x = np.linspace(0, 5, 10) y = x ** 2 figure() plot(x, y, 'r') xlabel('x') ylabel('y') title('titre') show() subplot(1,2,1) plot(x, y, 'r--') subplot(1,2,...
<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: Define an objective function Step2: Let's begin by plotting $f$. Step3: Setting a Gaussian Process prior Step4: The following helper function...
<ASSISTANT_TASK:> Python Code: import matplotlib.gridspec as gridspec import matplotlib.pyplot as plt import torch import torch.autograd as autograd import torch.optim as optim from torch.distributions import constraints, transform_to import pyro import pyro.contrib.gp as gp assert pyro.__version__.startswith('1.7.0') ...
<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: Ideal Responses Step2: Modeling the Offset Transmission Line Step3: The broadcasting feature in numpy is used here. The quantities Step4: At ...
<ASSISTANT_TASK:> Python Code: import skrf from skrf.media import DefinedGammaZ0 import numpy as np freq = skrf.Frequency(1, 9000, 1001, "MHz") ideal_medium = DefinedGammaZ0(frequency=freq, z0=50) ideal_open = ideal_medium.open() ideal_short = ideal_medium.short() ideal_load = ideal_medium.match() ideal_thru = idea...
<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: Data Step2: Exercise 1 Step3: Since we find a pvalue for the Levene test of less than our $\alpha$ level (0.05), we can reject the null hypot...
<ASSISTANT_TASK:> Python Code: # Useful functions def normal_test(X): z, pval = stats.normaltest(X) if pval < 0.05: print 'Values are not normally distributed.' else: print 'Values are normally distributed.' return # Useful Libraries import numpy as np import matplotlib.pyplot as plt fr...
<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: Overview <a class="anchor" id="Overview"></a> Step2: However under the enumeration interpretation, the same sample site will return a fully enu...
<ASSISTANT_TASK:> Python Code: import os import torch import pyro import pyro.distributions as dist from torch.distributions import constraints from pyro import poutine from pyro.infer import SVI, Trace_ELBO, TraceEnum_ELBO, config_enumerate, infer_discrete from pyro.infer.autoguide import AutoNormal from pyro.ops.inde...
<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: Create dataframe Step2: Make plot
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pandas as pd import matplotlib.pyplot as plt import numpy as np raw_data = {'first_name': ['Jason', 'Molly', 'Tina', 'Jake', 'Amy'], 'pre_score': [4, 24, 31, 2, 3], 'mid_score': [25, 94, 57, 62, 70], 'post_score': [5, 43, 23, 23, 51]} df ...
<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: Train the model Step2: Some crude attempts at sentiment analysis Step3: Proof of principal - ish
<ASSISTANT_TASK:> Python Code: import Load_Text_Set as l_data import run_Word2Vec as w2v words = l_data.text_8(200000) embeddings = w2v.run_embeddings() import numpy as np import regex as re joy_words = ['happy','joy','pleasure','glee'] sad_words = ['sad','unhappy','gloomy'] scary_words = ['scary','frightening','terr...
<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: Comparing the Errors
<ASSISTANT_TASK:> Python Code: def compute_value_dct(theta_lst, features): return [{s: np.dot(theta, x) for s, x in features.items()} for theta in theta_lst] def compute_values(theta_lst, X): return [np.dot(X, theta) for theta in theta_lst] def compute_errors(value_lst, error_func): return [error_func(v) fo...
<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: Let's look at the tables and columns we have for analysis. Step2: Price History Step3: Compare google to S&P Step4: Learning objective 2 Step...
<ASSISTANT_TASK:> Python Code: PROJECT = 'qwiklabs-gcp-ml-489e10787faf' # Change to your project. import numpy as np import pandas as pd import seaborn as sns from matplotlib import pyplot as plt from google.cloud import bigquery from IPython.core.magic import register_cell_magic from IPython import get_ipython bq = b...
<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: 1. Gnerate x = a sequence of points, y = sin(x)+a where a is a small random error. Step2: 2. Draw a scatter plot of x and y. Step3: 3. Use lin...
<ASSISTANT_TASK:> Python Code: %%javascript $.getScript('https://kmahelona.github.io/ipython_notebook_goodies/ipython_notebook_toc.js') # import the necessary package at the very beginning import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline import sklearn ## Type Your Answer Below...
<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: As always, let's do imports and initialize a logger and a new bundle. See Building a System for more details. Step2: Adding Spots Step3: Spot...
<ASSISTANT_TASK:> Python Code: !pip install -I "phoebe>=2.0,<2.1" import phoebe from phoebe import u # units import numpy as np import matplotlib.pyplot as plt logger = phoebe.logger() b = phoebe.default_star() b.add_spot(radius=30, colat=80, long=0, relteff=0.9) print b['spot'] times = np.linspace(0, 10, 11) b.set...
<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: Now import the version in bruges for comparison Step2: Plot the two together Step3: We can use the inspect module ot compare the source code S...
<ASSISTANT_TASK:> Python Code: def r(l,d,f):import numpy as n;t=n.arange(-l/2,l/2,d);k=(n.pi*f*t)**2;return t,(1-2*k)/n.exp(k) from bruges.filters import ricker import matplotlib.pyplot as plt t, w = r(0.128, 0.004, 25) plt.figure(figsize=(10,3)) plt.plot(t, ricker(0.128, 0.004, 25), 'o') # Compare to bruges. plt.pl...
<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: Multiplying Numpy Arrays Step2: LAB CHALLENGE
<ASSISTANT_TASK:> Python Code: import numpy as np one_dimensional = np.array([1,1,1,2,3,3,3,3,3]) one_dimensional one_dimensional.shape # not yet rows & columns one_dimensional.reshape((9,-1)) # let numpy figure out how many columns one_dimensional # still the same one_dimensional.ndim two_dimensional = one_dimension...
<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: If you did not already have the training set, download and unpack the tarball. Step2: Problem 1b Step3: Problem 1c Step4: Problem 1d Step5: ...
<ASSISTANT_TASK:> Python Code: def lc_plot(t, m, m_unc, period=0.0): if period == 0.0: fig, ax = plt.subplots() ax.errorbar(t, m, m_unc, fmt='o', color='MediumAquaMarine', mec="0.2",mew=0.5) ax.set_xlabel('HJD (d)') ax.set_ylabel(r'$V_\mathrm{...
<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: Download & Process Security Dataset Step2: Analytic I Step3: Analytic II
<ASSISTANT_TASK:> Python Code: from openhunt.mordorutils import * spark = get_spark() sd_file = "https://raw.githubusercontent.com/OTRF/Security-Datasets/master/datasets/atomic/windows/defense_evasion/host/empire_powerview_ldap_ntsecuritydescriptor.zip" registerMordorSQLTable(spark, sd_file, "sdTable") df = spark.sql...
<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: Input data Step2: Create a plot function for a visual comparison of the time series Step3: Plot an example series - in this case the temperatu...
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 import copy import os import pandas as pd import matplotlib.pyplot as plt import tsam.timeseriesaggregation as tsam import tsam.hyperparametertuning as tune import tqdm %matplotlib inline raw = pd.read_csv('testdata.csv', index_col = 0) raw=raw.rename(c...
<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: Verify that models.OneParameterLogisticModel can recover parameters. We would only expect this to be possible when USING_2PL = False. Step2: Ve...
<ASSISTANT_TASK:> Python Code: num_students = 2000 num_assessments = 3000 num_ixns_per_student = 1000 USING_2PL = False # False => using 1PL proficiencies = np.random.normal(0, 1, num_students) difficulties = np.random.normal(0, 1, num_assessments) if USING_2PL: discriminabilities = np.random.normal(0, 1, num_asses...
<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: Each variable holds data, a gradient, and information about the function that created it. Step2: Compare the above computations to the below gr...
<ASSISTANT_TASK:> Python Code: x = torch.Tensor(5, 3) print(x) x.zero_() torch.Tensor([[1, 2, 3], # rank 2 tensor [4, 5, 6], [7, 8, 9]]) x.size() x = torch.rand(5, 3) print(x) npy = np.random.rand(5, 3) y = torch.from_numpy(npy) print(y) z = x + y #can we do this addition? x.type(), y.type...
<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: Parameterization within SQL queries Step2: This defined a SQL query with a string parameter named endpoint, which can be filled when executing ...
<ASSISTANT_TASK:> Python Code: %%bq query -n logs_query SELECT * FROM `cloud-datalab-samples.httplogs.logs_20140615` %bq sample -q logs_query --count 10 %%bq query SELECT endpoint FROM `cloud-datalab-samples.httplogs.logs_20140615` GROUP BY endpoint %%bq query -n endpoint_stats SELECT * FROM `cloud-datalab-samples.htt...
<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: Estimating the angle of rotation Step2: The function can be applied as follows. Step3: Estimating the angle of rotation and the translation St...
<ASSISTANT_TASK:> Python Code: import numpy as np import sys,os ia898path = os.path.abspath('../../') if ia898path not in sys.path: sys.path.append(ia898path) import ia898.src as ia %matplotlib inline import matplotlib.image as mpimg #f = ia.normalize(ia.gaussian((151,151), [[75],[75]], [[800,0],[0,800]]), [0,200])...
<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: Now we plot the two classes as a scatter plot! Step2: Now we want to classify this synthetic data using the perceptron model which will be trai...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import scipy as sp import matplotlib.pyplot as plt # now we genrate the data N = 30 x = np.zeros(N, dtype=np.float64) y = np.zeros(N, dtype=np.float64) for k in range(N): x[k], y[k] = [np.random.uniform(-1,1) for i in range(2)] a = np.random....
<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: Lorenz system Step4: Write a function solve_lorenz that solves the Lorenz system above for a particular initial condition $[x(0),y(0),z(0)]$. Y...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np from scipy.integrate import odeint from IPython.html.widgets import interact, fixed def lorentz_derivs(yvec, t, sigma, rho, beta): Compute the the derivatives for the Lorentz system at yvec(t). x,y,z = yvec[0],...
<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: Client-efficient large-model federated learning via federated_select and sparse aggregation Step2: Each client will federated_select the rows o...
<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...
<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: Constrained problem Step2: Modeling and joint acquisition function Step3: Initial belief Step4: Running Bayesian Optimizer Step5: Results St...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import gpflow import gpflowopt import numpy as np # Objective & constraint def townsend(X): return -(np.cos((X[:,0]-0.1)*X[:,1])**2 + X[:,0] * np.sin(3*X[:,0]+X[:,1]))[:,None] def constraint(X): return -(-np.cos(1.5*X[:,0]+np.pi)...
<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: Curve data Step2: You can also access curves by index (remembering that the first index is zero but the first curve is the depth). Step3: All ...
<ASSISTANT_TASK:> Python Code: import os import lasio l = lasio.read(os.path.join("..", "tests", "examples", "6038187_v1.2.las")) print(type(l)) print(l._text) l.keys() l['NEUT'] print(l['GAMN']) print(l[2]) print(l["COND"]) print(l[-1]) print(l.data.shape) print(l.data) from lasio.las import HeaderItem example = H...
<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: Python Basics (2016-09-09) Step2: Data Types Step3: What will be the data type of a+b? Step4: It's a float. But why? If it was an integer, in...
<ASSISTANT_TASK:> Python Code: # this is a single line comment this is a multi line comment a = 5.1 print 'a', type(a) b = 3 print 'b', type(b) print a+b, type(a+b) print '3/2', 3/2 # integer divided by integer print '3./2', 3./2 # float divided by integer c = 'g' print 'c', type(c) d = 'stuff' print 'd', type(d...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step3: Jupyter notebooks Step4: Some common terminology Step5: Vandermonde matrices Step6: This type of matrix is very common; we can also create it...
<ASSISTANT_TASK:> Python Code: %matplotlib notebook import numpy from matplotlib import pyplot def matmult1(A, x): Entries of y are dot products of rows of A with x y = numpy.zeros_like(A[:,0]) for i in range(len(A)): row = A[i,:] for j in range(len(row)): y[i] += row[j] * x[j] ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step6: The pipeline uses a mix of custom and pre-build components. Step7: The custom components execute in a container image defined in base_image/Doc...
<ASSISTANT_TASK:> Python Code: !grep 'BASE_IMAGE =' -A 5 pipeline/covertype_training_pipeline.py %%writefile ./pipeline/covertype_training_pipeline.py # Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You...
<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: Exercise 1 Step2: Exercise 2 Step3: Exercise 3
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import matplotlib.pyplot as plt plt.style.use('ggplot') %pylab inline #Your code here... file1 = pd.read_json('../../data/data1.json') file2 = pd.read_json('../../data/data2.json') file2 = pd.read_json('../../data/data2.json') file3 = pd.read_json('...
<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: Prepare non-python dependencies by calling "nbinstall" Step2: Set default options by calling "set_defaults" (optional) Step3: Demo 1 - Renderi...
<ASSISTANT_TASK:> Python Code: import qgrid qgrid.nbinstall(overwrite=True) # copiesย javascript dependencies to your /nbextensions folder qgrid.set_defaults(remote_js=True, precision=4) import pandas as pd import numpy as np randn = np.random.randn pd.set_option('display.max_rows', 8) from pandas.io.data import ge...
<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: Jax Model Conversion For TFLite Step3: Data Preparation Step4: Build the MNIST model with Jax Step5: Train & Evaluate the model Step6: Conve...
<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...
<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: Download and prepare the dataset Step2: Limit the size of the dataset to experiment faster (optional) Step3: Create a tf.data dataset Step4: ...
<ASSISTANT_TASK:> Python Code: from __future__ import absolute_import, division, print_function # Import TensorFlow >= 1.10 and enable eager execution import tensorflow as tf tf.enable_eager_execution() import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split import unicodedata import re imp...
<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: This is just a simple sample to show how Bollinger Bands work. Step2: What is a 'Bollinger Bandยฎ' Step4: In this example of Bollinger Bandsยฎ, ...
<ASSISTANT_TASK:> Python Code: import quantiacsToolbox import matplotlib.pyplot as plt import numpy as np import pandas as pd %matplotlib inline F_AD = pd.read_csv('./tickerData/F_AD.txt') CLOSE = np.array(F_AD.loc[:252-1, [' CLOSE']]) plt.plot(CLOSE) def bollingerBands(a, n=20): sma = np.nansum(a[-n:]) / n s...
<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: Creation of Dictionary Step3: Recalibration of Dictionary
<ASSISTANT_TASK:> Python Code: file_path = '../data/2011.0.00419.S/sg_ouss_id/group_ouss_id/member_ouss_2013-03-06_id/product/IRAS16547-4247_Jet_CH3OH7-6.clean.fits' noise_pixel = (15, 4) train_pixels = [(133, 135),(134, 135),(133, 136),(134, 136)] img = fits.open(file_path) meta = img[0].data hdr = img[0].header # V a...
<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: Delta hedging Step2: Construct efficient frontier based on return in infinitesimal future time $\mathrm{d}t$ Step3: The most risk averse por...
<ASSISTANT_TASK:> Python Code: from scipy.stats import norm import numpy as np def bs_put(df, fwd, t, vol, k): log_fwd_moneyness = np.log(fwd/k) d1 = (log_fwd_moneyness + vol**2 /2.0 * t) / vol / np.sqrt(t) d2 = d1 - vol * np.sqrt(t) return df * (-norm.cdf(-d1) * fwd + norm.cdf(-d2) * k), norm.cdf(-d1)...
<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: quickly add lots of similar procedures Step2: Error handling Step3: Advance usage
<ASSISTANT_TASK:> Python Code: import os import sys import ruamel.yaml as yaml from ddf_utils.chef.api import Chef # at the beginning, initial the chef chef = Chef() # adding configs and metadata(to the info section) (chef.add_config(ddf_dir=os.path.expanduser('~/src/work/Gapminder/datasets')) .add_metadata(id='te...
<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: Make a grid and set boundary conditions. Step2: Here we make the initial grid of elevation of zeros with a very small amount of noise to make a...
<ASSISTANT_TASK:> Python Code: # Code block 1 import copy import numpy as np from matplotlib import pyplot as plt from landlab import RasterModelGrid, imshow_grid from landlab.components import ( ChannelProfiler, ChiFinder, FlowAccumulator, SteepnessFinder, StreamPowerEroder, ) from landlab.io impor...
<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: Working with ndarray Step2: Examining ndrray Step3: Why to use numpy? Step4: Basic Operation Step5: Most Common Functions Step6: Multi Dime...
<ASSISTANT_TASK:> Python Code: import numpy as np np.arange(10) np.arange(1,10) np.arange(1,10, 0.5) np.arange(1,10, 3) np.arange(1,10, 2, dtype=np.float64) ds = np.arange(1,10,2) ds.ndim ds.shape ds.size ds.dtype ds.itemsize x=ds.data list(x) ds # Memory Usage ds.size * ds.itemsize %%capture timeit_results # Regula...
<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: ๊ทธ๋ž˜๋””์–ธํŠธ ๋ฐ ์ž๋™ ๋ฏธ๋ถ„ ์†Œ๊ฐœ Step2: ๊ทธ๋ž˜๋””์–ธํŠธ ๊ณ„์‚ฐํ•˜๊ธฐ Step3: ์ผ๋ถ€ ์—ฐ์‚ฐ์„ ๊ธฐ๋กํ•œ ํ›„์—๋Š” GradientTape.gradient(target, sources)๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ผ๋ถ€ ์†Œ์Šค(์ข…์ข… ๋ชจ๋ธ ๋ณ€์ˆ˜)์— ์ƒ๋Œ€์ ์ธ ์ผ๋ถ€ ๋Œ€์ƒ(์ข…์ข… ์†์‹ค)์˜ ๊ทธ๋ž˜๋””์–ธ...
<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...
<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: Now we must generate a dictionary which maps vocabulary into a number
<ASSISTANT_TASK:> Python Code: from itertools import chain from collections import OrderedDict reviews_merged = OrderedDict() # Flatten the reviews, so each review is just a single list of words. n_reviews = -1 for bus_id in set(review.business_id.values[:n_reviews]): # This horrible line first collapses each revie...
<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: Step 1 Step3: Include an exploratory visualization of the dataset Step7: Histogram of the data shows that the trainign data is unevenly distri...
<ASSISTANT_TASK:> Python Code: # Import all the relevant modules. import cv2 import csv import matplotlib.image as mpimg import matplotlib.mlab as mlab import matplotlib.pyplot as plt import numpy as np import pandas as pd import pickle from random import randint import seaborn as sns from sklearn.utils import shuffle ...
<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: If you want the confidence intervals
<ASSISTANT_TASK:> Python Code: from lmfit.models import GaussianModel # initialize the gaussian model gm = GaussianModel() # take a look at the parameter names print gm.param_names # I get RuntimeError since my numpy version is a little old # guess parameters par_guess = gm.guess(n,x=xpos) # fit data result = gm.fit(n,...
<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: Building the policy network Step2: Loss function and updates Step5: Computing cumulative rewards Step7: Playing the game Step9: Results & vi...
<ASSISTANT_TASK:> Python Code: # This code creates a virtual display to draw game images on. # If you are running locally, just ignore it import os if type(os.environ.get("DISPLAY")) is not str or len(os.environ.get("DISPLAY")) == 0: !bash ../xvfb start os.environ['DISPLAY'] = ':1' import gym import numpy as n...
<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: A univariate example Step2: We create a bimodal distribution Step3: The simplest non-parametric technique for density estimation is the histog...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np from scipy import stats import statsmodels.api as sm import matplotlib.pyplot as plt from statsmodels.distributions.mixture_rvs import mixture_rvs np.random.seed(12345) # Seed the random number generator for reproducible results # Location, scale an...
<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: ... or call all the methods individually
<ASSISTANT_TASK:> Python Code: # NOTE: This will take several minutes depending on the performance of your machine audio_features = audioAnalyzer.analyze(audio_filename) # plot the features plt.rcParams['figure.figsize'] = [20, 8] audioAnalyzer.plot(audio_features) plt.show() # audio metadata extraction metadata = aud...
<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: Load Data Step2: Create Classifier Pipeline Step3: Cross Validation Step4: Evaluate Model Step5: To get an good measure of the model's accur...
<ASSISTANT_TASK:> Python Code: from sklearn.datasets import load_iris from sklearn.pipeline import make_pipeline from sklearn import preprocessing from sklearn import cross_validation from sklearn import svm # Load the iris test data iris = load_iris() # View the iris data features for the first three rows iris.data[0...
<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: Make a function for importing the station info for each line Step3: Import the data for each line Step4: Turn list of dict's into dic with lin...
<ASSISTANT_TASK:> Python Code: import http.client, urllib.request, urllib.parse, urllib.error, base64 import urllib import json import pickle def metro_line_import(line): Import station data from WMATA API and format it as a dictionary with staion name as the key and the [latitude, longitude] as the values ...
<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: Problem 1) An (oversimplified) 1-D Model Step3: Problem 1b Step4: Problem 1c Step5: Problem 2) Add Noise Step6: Problem 2b Step7: Problem 3...
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt %matplotlib notebook def phi(x, mu, fwhm): Evalute the 1d PSF N(mu, sigma^2) along x sigma = fwhm/2.3548 flux = 1/np.sqrt(2*np.pi*sigma**2)*np.exp(-(x - mu)**2/(2*sigma**2)) return flux x = np.linspace(0,20,21) plt.plot(...
<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: We are using TensorFlow-GPU 0.12.1 on Python 3.5.2, running on Windows 10 with Cuda 8.0. Step2: Definitions Step3: Data load Step4: Model def...
<ASSISTANT_TASK:> Python Code: import tensorflow as tf # We don't really need to import TensorFlow here since it's handled by Keras, # but we do it in order to output the version we are using. tf.__version__ from IPython.display import Image from util import Util u = Util() import numpy as np # Explicit random seed ...
<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: ไปฅไธŠใŒๆ•ฐๅ€ค่จˆ็ฎ—ใ‚’่กŒใ†ใƒ—ใƒญใ‚ฐใƒฉใƒ ใงใ‚ใ‚‹๏ผŽ Step2: 3. ๅฏ่ฆ–ๅŒ– Step3: animfuncใ‚’ๅฎŸ่กŒใ™ใ‚‹ใ“ใจใง๏ผŒpendulum.mp4ใฎใ‚ˆใ†ใชใ‚ขใƒ‹ใƒกใƒผใ‚ทใƒงใƒณๅ‹•็”ปใŒไฟๅญ˜ใ•ใ‚Œใ‚‹๏ผŽ Step4: <video width="432" height="288" controls>
<ASSISTANT_TASK:> Python Code: import numpy as np from scipy.integrate import odeint from math import sin ''' constants ''' m = 1 # mass of the pendulum [kg] l = 1 # length of the pendulum [m] g = 10 # Gravitational acceleration [m/s^2] ''' time setting ''' t_end = 10 # simulation time [s] t_fps = 50 # frame per second...
<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: Parameters are given as follows. D and radius mean a diffusion constant and a radius of molecules, respectively. Dimensions of length and time a...
<ASSISTANT_TASK:> Python Code: %matplotlib inline from ecell4.prelude import * D = 1 # 0.01 radius = 0.005 N = 20 # a number of samples y0 = {} # {'A': 60} duration = 3 V = 8 with species_attributes(): A | {'radius': radius, 'D': D} with reaction_rules(): ~A > A | 45.0 A > ~A | 1.5 m = get_model() ret1...
<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: Pregunta 2 Step2: Pregunta 4
<ASSISTANT_TASK:> Python Code: ##escriba la funciรณn aqui## horaValida('13:00:00') rut = input("ingrese su rut: ") ##su cรณdigo va aqui## import random random.seed(int(rut)) ##su cรณdigo va aqui## <END_TASK>
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step3: STOCK PICKING 3.1 - FORECASTING ARIMAs Step4: ARIMA Step5: Massive Predictions Step6: Reloading full results Step7: Stock picking Step8: No...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt import pandas_datareader.data as web import datetime def get_data(symbols, add_ref=True, data_source='yahoo', price='Adj Close', start='1/21/2010', en...
<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: Exercise 1 Step2: Exercise 2 Step3: Exercise 3 Step4: b. Confidence Intervals. Step5: Exercise 4
<ASSISTANT_TASK:> Python Code: # Useful Functions class DiscreteRandomVariable: def __init__(self, a=0, b=1): self.variableType = "" self.low = a self.high = b return def draw(self, numberOfSamples): samples = np.random.randint(self.low, self.high, numberOfSamples) ...
<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: Request Data Step3: Now that we have a function, we can run a query like this Step4: Pandas Dataframes Step5: Additional operations Step6: O...
<ASSISTANT_TASK:> Python Code: import datetime import pandas as pd import numpy as np import linecache, bisect import os spath = os.getcwd() path = spath.split("/") date = path[len(path)-1] def makeGraphqlRequest(query, variables): return GraphQLClient.request(query, variables) suspicious_query = query($date:Spot...
<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: As always, let's do imports and initialize a logger and a new Bundle. See Building a System for more details. Step2: Dataset Parameters Step3:...
<ASSISTANT_TASK:> Python Code: !pip install -I "phoebe>=2.1,<2.2" %matplotlib inline import phoebe from phoebe import u # units import numpy as np import matplotlib.pyplot as plt logger = phoebe.logger() b = phoebe.default_binary() b.add_dataset('orb') print b.filter(kind='orb') print b['times'] print b['compute'] ...
<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: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'bnu', 'sandbox-1', 'aerosol') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "ema...
<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: As with previous notebooks we will use an action selection function to give us an exploration strategy. Feel free to change this function and pl...
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt import tempfile import base64 import pprint import random import json import sys import gym import io from gym import wrappers from collections import deque from subprocess import check_output from IPython.display impo...
<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: Initial set-up Step2: Combine model and experiments to produce Step3: Set up prior ranges for each parameter in the model. Step4: Run ABC cal...
<ASSISTANT_TASK:> Python Code: import os, tempfile import logging import matplotlib as mpl import matplotlib.pyplot as plt import seaborn as sns import numpy as np from ionchannelABC import theoretical_population_size from ionchannelABC import IonChannelDistance, EfficientMultivariateNormalTransition, IonChannelAccepto...
<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: Create a survey plan Step3: Transient model Step4: Transient Generator Step5: Number of injections, you can fix the number of generated trans...
<ASSISTANT_TASK:> Python Code: import os home_dir = os.getcwd() # Please enter the path to where you have placed the Schlegel, Finkbeiner & Davis (1998) dust map files # You can also set the environment variable SFD_DIR to this path (in that case the variable below should be None) sfd98_dir = os.path.join(home_dir, 'da...
<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: ALS implementation using DML Step3: Running the Algorithm Step5: Predictions Step6: Just for Fun!
<ASSISTANT_TASK:> Python Code: from pyspark.sql import SparkSession from pyspark.sql.types import * from systemml import MLContext, dml spark = SparkSession\ .builder\ .appName("als-example")\ .getOrCreate() schema = StructType([StructField("movieId", IntegerType(), True), S...
<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: Paths Step2: Config parameters Step3: Data Loading Step4: experimenting with Fastai Step5: Misc / Asides / Notes
<ASSISTANT_TASK:> Python Code: import pathlib import os import torchtext # from torchtext.data import Field from torchtext import data # import spacy import pandas as pd import numpy as np # from torchtext.data import TabularDataset data_path = pathlib.Path('../../data') comp_path = pathlib.Path(data_path/'competition...
<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: Load the MNIST database Step2: Each digit is represented by a one hot vector where the index of the 1 represents the number Step3: Load the sa...
<ASSISTANT_TASK:> Python Code: import nengo import numpy as np import cPickle from nengo_extras.data import load_mnist from nengo_extras.vision import Gabor, Mask from matplotlib import pylab import matplotlib.pyplot as plt import matplotlib.animation as animation from scipy import linalg # --- load the data img_rows,...
<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: Processing the text using TRIPS Step2: We can pass the block of text defined above to the TRIPS processor Step3: Here tp is a TripsProcessor o...
<ASSISTANT_TASK:> Python Code: model_text = \ ''' Active ATM phosphorylates ATM, and phosphorylated ATM is active. Active ATM activates p53. p53 is transcribed and active p53 transcribes MDM2. MDM2 is degraded. Active p53 activates Wip1. Active Wip1 inactivates p53. Active Wip1 dephosphorylates ATM. MDM2 ubiquitinates ...
<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: In the Data Processing Pipelines section we discovered how to declare a DynamicMap and control multiple processing steps with the use of custom ...
<ASSISTANT_TASK:> Python Code: import pandas as pd import holoviews as hv from bokeh.sampledata import stocks from holoviews.operation.timeseries import rolling, rolling_outlier_std hv.extension('bokeh') def load_symbol(symbol, variable='adj_close', **kwargs): df = pd.DataFrame(getattr(stocks, symbol)) df['dat...
<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: Enter Your Project and GCS Bucket Step2: Set Your Application Name, Task Name, and Directories. Step3: Set a GCS Prefix Step7: Stack Overflow...
<ASSISTANT_TASK:> Python Code: !pip3 uninstall -y google-cloud-aiplatform !pip3 install google-cloud-aiplatform import IPython app = IPython.Application.instance() app.kernel.do_shutdown(True) MY_PROJECT = "YOUR PROJECT ID" MY_STAGING_BUCKET = "gs://YOUR BUCKET" # bucket should be in same region as ucaip APP_NAME = ...
<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: Symbolic differentiation Step2: You can even ask sympy to give you a formula you can evaluate in a coding language Step3: And sympy can evalua...
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt plt.style.use('ggplot') import sympy from sympy.abc import x f = sympy.cos(x**sympy.pi) * sympy.log(x) f sympy.diff(f, x) sympy.ccode(f, 'y') sympy.fcode(f, 'y') f.evalf(40, subs={x: 1.9}) def g(x, m=np): y = x ...
<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: At this point, we have our stations and trips data loaded into memory. Step2: Then, let's iterate over the stations DataFrame, and add in the ...
<ASSISTANT_TASK:> Python Code: # This block of code checks to make sure that a particular directory is present. if "divvy_2013" not in os.listdir('datasets/'): print('Unzip the divvy_2013.zip file in the datasets folder.') stations = pd.read_csv('datasets/divvy_2013/Divvy_Stations_2013.csv', parse_dates=['online da...
<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: Load house sales data Step2: Split data into training and testing Step3: Useful SFrame summary functions Step4: As we see we get the same ans...
<ASSISTANT_TASK:> Python Code: import graphlab sales = graphlab.SFrame('kc_house_data.gl/') train_data,test_data = sales.random_split(.8,seed=0) # Let's compute the mean of the House Prices in King County in 2 different ways. prices = sales['price'] # extract the price column of the sales SFrame -- this is now an SA...
<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: Exercรญcios - Mรฉtodos e Funรงรตes
<ASSISTANT_TASK:> Python Code: # Versรฃo da Linguagem Python from platform import python_version print('Versรฃo da Linguagem Python Usada Neste Jupyter Notebook:', python_version()) # Exercรญcio 1 - Crie uma funรงรฃo que imprima a sequรชncia de nรบmeros pares entre 1 e 20 (a funรงรฃo nรฃo recebe parรขmetro) e # depois faรงa uma ...
<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: Plotting Histogram Step2: By default, hist is using 10 equal bins to plot the data, we can increase this no by using bins=n Step3: Another imp...
<ASSISTANT_TASK:> Python Code: # import import numpy as np import matplotlib.pyplot as plt %matplotlib inline # generating some data points X = np.random.random_integers(20, 50, 1000) Y = np.random.random_integers(20, 50, 1000) plt.hist(X) plt.xlabel("Value of X") plt.ylabel("Freq") gaussian_numbers = np.random.normal...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
<ASSISTANT_TASK:> Python Code:: # one hot encode target sequence def encode_output(sequences, vocab_size): ylist = list() for sequence in sequences: encoded = to_categorical(sequence, num_classes=vocab_size) ylist.append(encoded) y = array(ylist) y = y.reshape(sequences.shape[0], sequences.shape[1], vocab_size) ...
<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: Exercicio 2 - Juros Compostos Step2: Exercicio 3 - Imposto de renda Step3: Exercรญcio 4 - Somatรณria Step4: Exercicio 5 - Palรญndromo Step5: Ex...
<ASSISTANT_TASK:> Python Code: def CaixaEletronico(valor): notas50 = valor // 50 valor = valor % 50 notas20 = valor // 20 valor = valor % 20 notas10 = valor // 10 valor = valor % 10 notas5 = valor // 5 valor = valor % 5 notas1 = valor // 1 return (notas50, notas20, notas10, notas...