Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
9,800
<ASSISTANT_TASK:> Python Code: import os %%bash export PROJECT=$(gcloud config list project --format "value(core.project)") echo "Your current GCP Project Name is: "${PROJECT} # TODO: Change these to try this notebook out PROJECT = "cloud-training-demos" # Replace with your PROJECT BUCKET = PROJECT # defaults to PRO...
<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: Lab Task #1 Step2: Check data exists Step3: Now that we have the Keras wide-and-deep code working on a subset of the data, we can package the ...
9,801
<ASSISTANT_TASK:> Python Code: def p(n, m): output = 0 for i in range(n): output += i % m return output %timeit p(1000000, 42) %%cython def f(n, m): output = 0 for i in range(n): output += i % m return output %timeit f(1000000, 42) %%cython def c(int n): cdef int i, output ...
<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: Still Python, but inside a Cython cell Step2: Cython Step3: Example of a while loop Step6: Application Step7: Quick demo Step8: Speed test ...
9,802
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np %matplotlib inline import matplotlib.pyplot as plt import matplotlib.cm as cm import time import gzip import shutil import seaborn as sns from collections import Counter from sklearn.mixture import GaussianMixture from sklearn.cluster import KMeans, ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step 1 (clustering) Step1: Do some preprocessing to group the data by 'Anon Stud Id' and extract features for further analysis Step2: Note to reviewer...
9,803
<ASSISTANT_TASK:> Python Code: # A comma-delimited list of the words you want to train for. # The options are: yes,no,up,down,left,right,on,off,stop,go # All the other words will be used to train an "unknown" label and silent # audio data with no spoken words will be used to train a "silence" label. WANTED_WORDS = "yes...
<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: DO NOT MODIFY the following constants as they include filepaths used in this notebook and data that is shared during training and inference. Ste...
9,804
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'nasa-giss', 'giss-e2-1h', 'toplevel') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("nam...
<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: 2...
9,805
<ASSISTANT_TASK:> Python Code: import datetime import logging import os import matplotlib.pyplot as plt import numpy as np import tensorflow as tf from tensorflow import feature_column as fc from tensorflow.keras import layers from tensorflow.keras import models # set TF error log verbosity logging.getLogger("tensorflo...
<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 taxifare dataset Step2: Let's check that the files were copied correctly and look like we expect them to. Step3: Create an input pipeline...
9,806
<ASSISTANT_TASK:> Python Code: def total (m): i=0 result=1 while i<m: i+=1 result*=i return result m=int(input('please enter an integer. ')) n=int(input('please enter an integer. ')) k=int(input('please enter an integer. ')) print('The result of ',m,'!+',n,'!+',k,'! is :',total(m)+total(...
<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: 练习 2:写函数可返回1 - 1/3 + 1/5 - 1/7...的前n项的和。在主程序中,分别令n=1000及100000,打印4倍该函数的和。 Step2: 练习 3:将task3中的练习1及练习4改写为函数,并进行调用。 Step3: TASK3练习 4:英文单词单数转复数,要...
9,807
<ASSISTANT_TASK:> Python Code: from awips.dataaccess import DataAccessLayer from awips.tables import vtec from datetime import datetime import numpy as np import matplotlib.pyplot as plt import cartopy.crs as ccrs import cartopy.feature as cfeature from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATT...
<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: Next, we create a request for the "warning" data type Step2: Now loop through each record and plot it as either Polygon or MultiPolygon, with a...
9,808
<ASSISTANT_TASK:> Python Code: project_dir = "/home/ubuntu/github/AstroWeekStudy/python_code/" import sys sys.path.append("/home/ubuntu/github/AstroWeekStudy/python_code/") try: reload(loadData) reload(astroWeekLib) except: import loadData import astroWeekLib from loadData import * from astroWeekLi...
<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. Study of Repository Creations Step2: 2. Timeline Of Activity (active repos,actors, and number of events) Step3: 3. Productive Bursts Step4:...
9,809
<ASSISTANT_TASK:> Python Code: import numpy as np from numpy import pi from matplotlib import pyplot as plt %matplotlib inline import pyqg from pyqg import diagnostic_tools as tools L = 1000.e3 # length scale of box [m] Ld = 15.e3 # deformation scale [m] kd = 1./Ld # deformation wavenumber [m^...
<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 Step2: Initial condition Step3: Run the model Step4: Snapshots Step5: pyqg has a built-in method that computes the vertical modes. St...
9,810
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'test-institute-3', 'sandbox-2', 'aerosol') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor...
<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...
9,811
<ASSISTANT_TASK:> Python Code: %load_ext sql # %sql postgresql://gpdbchina@10.194.10.68:55000/madlib %sql postgresql://fmcquillan@localhost:5432/madlib %sql select madlib.version(); %%sql DROP TABLE IF EXISTS test_set; CREATE TABLE test_set( pred FLOAT8, -- predicted values obs FL...
<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: Continuous variables Step2: Binary classification Step3: Run the Binary Classifier metrics function and View the True Positive Rate and the Fa...
9,812
<ASSISTANT_TASK:> Python Code: import glob all_filenames = glob.glob('../data/names/*.txt') print(all_filenames) import unicodedata import string all_letters = string.ascii_letters + " .,;'" n_letters = len(all_letters) # Turn a Unicode string to plain ASCII, thanks to http://stackoverflow.com/a/518232/2809427 def unic...
<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 have category_lines, a dictionary mapping each category (language) to a list of lines (names). We also kept track of all_categories (just...
9,813
<ASSISTANT_TASK:> Python Code: %%sh pip install pandas pip install scikit-learn pip install tpot from __future__ import print_function import numpy as np %matplotlib inline import pandas as pd import matplotlib.pyplot as plt from sklearn.model_selection import cross_val_score from sklearn.model_selection import KFold ,...
<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 Preprocessing Step2: We procceed to run Paolo Bestagini's routine to include a small window of values to acount for the spatial component ...
9,814
<ASSISTANT_TASK:> Python Code: ## Read in the Training Data and Instantiating the Photo-z Algorithm %matplotlib inline from astropy.table import Table import numpy as np import matplotlib.pyplot as plt #data = Table.read('GTR-ADM-QSO-ir-testhighz_findbw_lup_2016_starclean.fits') #JT PATH ON TRITON to training set after...
<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: Since we are running on separate test data, we don't need to do a train_test_split here. But we will scale the data. Need to remember to scale...
9,815
<ASSISTANT_TASK:> Python Code: #@title Python imports import collections import datetime from functools import partial import math import numpy as np import pandas as pd import matplotlib.pyplot as plt import matplotlib.ticker as ticker from scipy import stats import seaborn as sns from sklearn.datasets import make_reg...
<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 Step2: Section 1 Step3: So we see that JAX gets the same answer by computing the derivative of the composite or by multiplying together th...
9,816
<ASSISTANT_TASK:> Python Code: import torch from torchvision import datasets, transforms # Define a transform to normalize the data transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5,...
<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: Here I'll create a model like normal, using the same one from my solution for part 4. Step2: The goal of validation is to measure the model's p...
9,817
<ASSISTANT_TASK:> Python Code: !sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst import os import shutil import matplotlib.pyplot as plt import numpy as np import tensorflow as tf from tensorflow.keras import Sequential from tensorflow.keras.callbacks import ModelCheckpoint, TensorBoard from tensorflow...
<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: Exploring the data Step2: Each image is 28 x 28 pixels and represents a digit from 0 to 9. These images are black and white, so each pixel is a...
9,818
<ASSISTANT_TASK:> Python Code: N = 10 theta_0 = 0.5 np.random.seed(0) x = sp.stats.bernoulli(theta_0).rvs(N) n = np.count_nonzero(x) n sp.stats.binom_test(n, N) N = 100 theta_0 = 0.5 np.random.seed(0) x = sp.stats.bernoulli(theta_0).rvs(N) n = np.count_nonzero(x) n sp.stats.binom_test(n, N) N = 100 theta_0 = 0.35 np....
<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: 유의 확률(p-value)이 34%로 높으므로 귀무 가설을 기각할 수 없다. 따라서 $\theta=0.5$이다. Step2: 유의 확률(p-value)이 92%로 높으므로 귀무 가설을 기각할 수 없다. 따라서 $\theta=0.5$이다. Step3: 유의...
9,819
<ASSISTANT_TASK:> Python Code: import logging from conf import LisaLogging LisaLogging.setup() # Generate plots inline %matplotlib inline import json import os # Support to access the remote target import devlib from env import TestEnv from executor import Executor # RTApp configurator for generation of PERIODIC tasks...
<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 required modules Step2: Target Configuration Step3: Workload Execution and Functions Profiling Data Collection Step4: Parse Trace and ...
9,820
<ASSISTANT_TASK:> Python Code: #--- Libraries import pandas as pd # statistics packages import numpy as np # linear algebra packages import matplotlib.pyplot as plt # plotting routines import seaborn as sns ...
<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: Specify region Step2: Set data Step3: Reanalysis Step4: Once have full data set can then subdivide to create individual files for different r...
9,821
<ASSISTANT_TASK:> Python Code: import keras.backend as K import numpy as np # Placeholders and variables x = K.placeholder() target = K.placeholder() lr = K.variable(0.1) w = K.variable(np.random.rand()) b = K.variable(np.random.rand()) # Define model and loss y = w * x + b loss = K.mean(K.square(y-target)) grads = K...
<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: Model definition Step2: Then, given the gradient of MSE wrt to w and b, we can define how we update the parameters via SGD Step3: The whole mo...
9,822
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL # load in data import helper data_dir = './data/Seinfeld_Scripts.txt' text = helper.load_data(data_dir) view_line_range = (0, 10) DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE import numpy as np print('Dataset Stats') print('Roughly the num...
<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: TV Script Generation Step3: Explore the Data Step6: Implement Pre-processing Functions Step9: Tokenize Punctuation Step11: Pre-process all t...
9,823
<ASSISTANT_TASK:> Python Code: %matplotlib inline from __future__ import print_function import mxnet as mx import numpy as np import matplotlib.pyplot as plt record = mx.recordio.MXRecordIO('tmp.rec', 'w') for i in range(5): record.write('record_%d'%i) record.close() record = mx.recordio.MXRecordIO('tmp.rec', 'r'...
<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 relevent code is under mx.recordio. There are two classes Step2: Then we can read it back by opening the same file with 'r' Step3: MXIndex...
9,824
<ASSISTANT_TASK:> Python Code: Setup the outcome map. Rows correspond to vote types. Columns correspond to disposition types. Element values correspond to: * -1: no precedential issued opinion or uncodable, i.e., DIGs * 0: affirm, i.e., no change in precedent * 1: reverse, i.e., change in precent outcome_map = pand...
<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: Disposition outcoming coding Step8: Running a simulation Step9: Predicting case outcomes with court reversal rate Step10: Predicting case out...
9,825
<ASSISTANT_TASK:> Python Code: from learning import * from notebook import psource, pseudocode psource(NeuralNetLearner) pseudocode('Back-Prop-Learning') psource(BackPropagationLearner) iris = DataSet(name="iris") iris.classes_to_numbers() nNL = NeuralNetLearner(iris) print(nNL([5, 3, 1, 0.1])) <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: NEURAL NETWORK ALGORITHM Step2: BACKPROPAGATION Step3: Implementation
9,826
<ASSISTANT_TASK:> Python Code: import random as rd import numpy as np from numpy.random import choice import matplotlib.pyplot as plt import matplotlib %matplotlib inline matplotlib.style.use('ggplot') matplotlib.rc_params_from_file("../styles/matplotlibrc" ).update() list_of_categories = ["H", "T"] def initializeExpe...
<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: Constructing the experiment Step2: Next we need to check if the last N throws have been equal to the category we want to observe. To do this we...
9,827
<ASSISTANT_TASK:> Python Code: # If we're running on Colab, install empiricaldist # https://pypi.org/project/empiricaldist/ import sys IN_COLAB = 'google.colab' in sys.modules if IN_COLAB: !pip install empiricaldist # Get utils.py from os.path import basename, exists def download(url): filename = basename(url) ...
<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 chapter introduces two related topics Step2: Each update uses the same likelihood, but the changes in probability are not the same. The f...
9,828
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import seaborn %matplotlib inline x = np.linspace(-3, 3, 100) plt.plot(x, x**2, label='f(x)') # optymalizowana funkcja plt.plot(x, 2 * x, label='pochodna -- f\'(x)') # pochodna plt.legend() plt.show() learning_rate = ... nb_steps = 10 ...
<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: Funkcja ta ma swoje minimum w punkcie $x = 0$. Jak widać na powyższym rysunku, gdy pochodna jest dodatnia (co oznacza, że funkcja jest rosnąca) ...
9,829
<ASSISTANT_TASK:> Python Code: !pip install -r requirements.txt --user --quiet import sys, os from tqdm import tqdm import subprocess import numpy as np import pandas as pd from scipy import stats import matplotlib.pyplot as plt import zipfile import joblib import gc from lightgbm import LGBMRegressor from sklearn.met...
<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: Imports Step2: Project hyper-parameters Step3: Set random seed for reproducibility and ignore warning messages. Step4: Download and load the ...
9,830
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd index = ['x', 'y'] columns = ['a','b','c'] dtype = [('a','int32'), ('b','float32'), ('c','float32')] values = np.zeros(2, dtype=dtype) df = pd.DataFrame(values, index=index) <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:
9,831
<ASSISTANT_TASK:> Python Code: import plotly from pageviews import * from wiki_parser import * import plotly.tools as tls from helpers_parser import * from across_languages import * plotly.tools.set_credentials_file(username='crimenghini', api_key='***') # Define the path of the corpora path = '/Users/cristinamenghini...
<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. Find articles <a name="parse"></a> Step2: After having a quick peek at a snippet of the XML. The elements we are interested in are on the ch...
9,832
<ASSISTANT_TASK:> Python Code: # import statements to make numeric and plotting functions available %matplotlib inline from numpy import * from matplotlib.pyplot import * def hill_activating(X, B, K, n): Hill function for an activator return (B * X**n)/(K**n + X**n) ## generate a plot using the hill_activatin...
<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: Modeling Gene Networks Using Ordinary Differential Equations Step2: Visualizing the activating Hill function Step3: <h2> <font color='firebric...
9,833
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import gzip import json import numpy as np def read_data(fname): with gzip.open(fname) as fpt: d = json.loads(str(fpt.read(), encoding='utf-8')) return d %matplotlib inline plt.figure(figsize=(20, 10)) mx_pos = read_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: Efecto oscilatorio cuyo periodo corresponde a los días de la semana. Step2: Análisis de polaridad en Estados Unidos, Argentina, México y España...
9,834
<ASSISTANT_TASK:> Python Code: # To support both python 2 and python 3 from __future__ import division, print_function, unicode_literals # Common imports import numpy as np import os try: # %tensorflow_version only exists in Colab. %tensorflow_version 1.x except Exception: pass # to make this notebook's out...
<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: Then of course we will need TensorFlow Step2: Basic RNNs Step3: Using static_rnn() Step4: Packing sequences Step5: Using dynamic_rnn() Step6...
9,835
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt def f(x): return 2-x-np.exp(-x) x = np.linspace(-10, 10, 400) y = f(x) plt.figure() plt.plot(x, y) # melhorando a escala para visualizar as possíveis raízes plt.figure() plt.plot(x, y) plt.hlines(0,x.min(),x.max(),colors='C1',linestyl...
<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 que a função tem duas raízes no entanto, por este método não temos como convergir para a raíz negativa. Uma alternativa é obter maneiras di...
9,836
<ASSISTANT_TASK:> Python Code: # Install all dependencies for this example. ! pip install ray gradio transformers requests import gradio as gr from ray import serve from transformers import pipeline import requests serve.start() @serve.deployment def model(request): language_model = pipeline("text-generation", mo...
<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: Deploying a model with Ray Serve Step2: Next, we define a Ray Serve deployment with a GPT-2 model, by using the @serve.deployment decorator on ...
9,837
<ASSISTANT_TASK:> Python Code: from keras.datasets import mnist (X_raw, y_raw), (X_raw_test, y_raw_test) = mnist.load_data() n_train, n_test = X_raw.shape[0], X_raw_test.shape[0] import matplotlib.pyplot as plt import random %matplotlib inline %config InlineBackend.figure_format = 'retina' for i in range(15): plt....
<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: 可视化 mnist Step2: 练习:合成数据 Step3: 问题 1 Step4: 问题 2 Step5: 问题 3 Step6: 问题 4 Step7: 保存模型
9,838
<ASSISTANT_TASK:> Python Code: import numpy as np %matplotlib inline import matplotlib.pyplot as plt import seaborn as sns def np_fact(n): Compute n! = n*(n-1)*...*1 using Numpy. if n==0: c=1 # this makes it so if 0 is imputed a 1 is reurned return c else: a=np.ar...
<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: Factorial Step3: Write a function that computes the factorial of small numbers using a Python loop. Step4: Use the %timeit magic to time both ...
9,839
<ASSISTANT_TASK:> Python Code: %matplotlib inline import mpld3 mpld3.enable_notebook() # Get the dataset: from clustering import create_cluster_dataset, NewspaperArchive DBFILE = "1749_1750_no_drift.db" n = NewspaperArchive() ds = create_cluster_dataset(n, daterange = [1749, 1750], dbfile = DBFILE) data, transform, id...
<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: What do these 'vectors' look like? What do the columns refer to? Step2: Going from a vector back to the metadata reference Step3: Initial data...
9,840
<ASSISTANT_TASK:> Python Code: import logging logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO) import os import gensim # Set file names for train and test data test_data_dir = os.path.join(gensim.__path__[0], 'test', 'test_data') lee_train_file = os.path.join(test_data_dir, '...
<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: Doc2Vec is a core_concepts_model that represents each Step2: Define a Function to Read and Preprocess Text Step3: Let's take a look at the tra...
9,841
<ASSISTANT_TASK:> Python Code: import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) X_train, y_train = mnist.train.images, mnist.train.labels X_validation, y_validation = mnist.validation.images, mnist.validation.labe...
<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: Section 1 Step2: <b> Part 2 </b> Step3: <b> Question 2.1.2. </b> Calculate the number of parameters of this model Step4: Your answer goes ...
9,842
<ASSISTANT_TASK:> Python Code: def countTrailingZero(x ) : count = 0 while(( x & 1 ) == 0 ) : x = x >> 1 count += 1  return count  if __name__== ' __main __' : print(countTrailingZero(11 ) )  <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:
9,843
<ASSISTANT_TASK:> Python Code: import sys sys.version import warnings warnings.simplefilter('ignore', FutureWarning) from pandas import * show_versions() df = read_csv('WHO POP TB all.csv') df.head() df.head(10) df.tail(5) df.columns df.iloc[0] # first row, index 0 df.iloc[2] # third row, index 2 df.head() # first ...
<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: Dataframe attributes Step3: Dataframe rows Step4: The <code>head()</code> method Step5: The <code>tail()</code> method Ste...
9,844
<ASSISTANT_TASK:> Python Code: import random gameStake = 50 cards = range(10) class Player: # create here two local variables to store a unique ID for each player and the player's current 'pot' of money # [FILL IN YOUR VARIABLES HERE] # in the __init__() function, use the two input variables t...
<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: First we will establish some general variables for our game, including the 'stake' of the game (how much money each play is worth), as well as a...
9,845
<ASSISTANT_TASK:> Python Code: from pint import UnitRegistry import sympy import networkx as nx import numpy as np import matplotlib.pyplot as plt import sys %matplotlib inline from IPython.display import display from Section import Section ureg = UnitRegistry() sympy.init_printing() A, A0, t, t0, a, b, h, L, E, G =...
<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 Section class, which contains all calculations Step2: Initialization of sympy symbolic tool and pint for dimension analysis (not really ...
9,846
<ASSISTANT_TASK:> Python Code: ## Utility functions. def revcomp(sequence): "returns reverse complement of a string" sequence = sequence[::-1].strip()\ .replace("A", "t")\ .replace("T", "a")\ .replace("C", "g")\ ...
<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: Handy function for manufacturing a psuedo-genome with guaranteed hits from simulated data Step2: Insert SE and PE reads into simulated genome S...
9,847
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'cnrm-cerfacs', 'cnrm-esm2-1-hr', 'seaice') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor...
<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: 2...
9,848
<ASSISTANT_TASK:> Python Code: %pylab inline import ABCPRC as prc import seaborn as sns import scipy.stats as stats def createData(beta,gamma,n=100,T=100,I0=1): S,I = np.zeros(T),np.zeros(T) S[0] = n-I0 I[0] = I0 eps=0.1 for i in np.arange(1,T): if beta*S[i-1]*I[i-1]/n<0: print(beta*S[i-1]*...
<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 individual-based model Step2: Generate some fake data Step3: Check the shape of the output. $T=100$, so the number of pairs should be $...
9,849
<ASSISTANT_TASK:> Python Code: # Author: Marijn van Vliet <w.m.vanvliet@gmail.com> # # License: BSD (3-clause) import os.path as op import numpy as np from scipy.signal import welch, coherence from mayavi import mlab from matplotlib import pyplot as plt import mne from mne.simulation import simulate_raw from mne.datas...
<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: Setup Step3: Data simulation Step4: Let's simulate two timeseries and plot some basic information about them. Step5: Now we put the signals a...
9,850
<ASSISTANT_TASK:> Python Code: from sympy.parsing.latex import parse_latex parse_latex(r'\frac{x^2}{\sqrt{y}}') import numpy as np import pandas as pd x = np.empty([3], dtype=object) x x[0]=parse_latex(r'\frac{x^2}{\sqrt{y}}') x y = list(np.array([parse_latex(r'x+y=6'),parse_latex(r'x-y=0')])) y from sympy import 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: Solo nos queda pasar un string con la expresión LaTeX para que la función devuelva la expresión en código entendible por Sympy. NOTA Step2: Eje...
9,851
<ASSISTANT_TASK:> Python Code: from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import os print("Required modules imported.") # You should have checked out original Caffe # git clone https://github.com/BVLC/caffe.git # ...
<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 you can setup your root folder for Caffe below if you put it somewhere else. You should only be changing the path that's being set for CAFFE...
9,852
<ASSISTANT_TASK:> Python Code: %matplotlib inline from karabo_data import RunDirectory import matplotlib.pyplot as plt import numpy as np import re import xarray as xr run = RunDirectory('/gpfs/exfel/exp/SA1/201830/p900025/raw/r0150/') df = run.get_dataframe(fields=[("*_XGM/*", "*.i[xy]Pos"), ("*_XGM/*", "*.photonFlux...
<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: Using pandas Step2: We can now make plots to compare the parameters at the two XGM positions. Step3: We can also export the dataframe to a CSV...
9,853
<ASSISTANT_TASK:> Python Code: import sklearn import matplotlib.pyplot as plt import scipy import numpy as np from keras.models import Sequential from keras.layers.embeddings import Embedding from keras.layers import Flatten, Activation, Merge from keras.preprocessing.text import Tokenizer, base_filter from keras.prepr...
<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: ...Depending on which environment you're running this from, you may find yourself needing to upgrade one of these libraries, which you can do by...
9,854
<ASSISTANT_TASK:> Python Code: import urllib, json, time apiKey="" if not apiKey: print "Enter your API key for traffic data!" exit(1) origin="Empire State Building, NY" destination="One World Trade Center, NY" params = urllib.urlencode( {'origin': origin, 'destination': destination, 'mode': ...
<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 Google Maps Directions API key below Step2: Enter your origin and destination Step3: Try to grab realtime traffic from Google Step4...
9,855
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np import seaborn as sns from scipy.integrate import odeint from IPython.html.widgets import interact, fixed def solve_euler(derivs, y0, x): Solve a 1d ODE using Euler's method. Parameters ---------- ...
<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: Euler's method Step4: The midpoint method is another numerical method for solving the above differential equation. In general it is more accura...
9,856
<ASSISTANT_TASK:> Python Code: !sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst from google.cloud import bigquery import seaborn as sns import matplotlib.pyplot as plt import pandas as pd import numpy as np %%bigquery SELECT FORMAT_TIMESTAMP( "%Y-%m-%d %H:%M:%S %Z", pickup_datetime) AS 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: <h3> Extract sample data from BigQuery </h3> Step2: Let's increase the number of records so that we can do some neat graphs. There is no guara...
9,857
<ASSISTANT_TASK:> Python Code: from flexx import app, ui, react app.init_notebook() b = ui.Button(text='foo') b b.text('Push me!') with ui.HBox() as hbox: slider = ui.Slider(flex=0) label = ui.Label(flex=1, text='xx') hbox @react.connect('slider.value') def show_slider_value(v): label.text(str(v)) clas...
<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: Displaying widgets Step2: Widgets have many input signals to modify their appearance and behavior Step3: Layout Step4: React Step5: Compound...
9,858
<ASSISTANT_TASK:> Python Code: from netCDF4 import Dataset url = ('http://geoport.whoi.edu/thredds/dodsC/usgs/data2/rsignell/gdrive/' 'nsf-alpha/Data/MIT_MSEAS/MSEAS_Tides_20160317/mseas_tides_2015071612_2015081612_01h.nc') nc = Dataset(url) vtime = nc['time'] coords = nc['vgrid2'] vbaro = nc['vbaro'] itime = ...
<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: Extract lon, lat variables from vgrid2 and u, v variables from vbaro. Step2: Using iris to create the CF object. Step3: Now the phenomena. Ste...
9,859
<ASSISTANT_TASK:> Python Code: %pylab inline import seaborn as sns sns.set_context("notebook", font_scale=1.5) #import warnings #warnings.filterwarnings("ignore") import pandas as pd tbl2 = pd.read_clipboard(#"http://iopscience.iop.org/0004-637X/785/2/159/suppdata/apj492858t2_ascii.txt", sep='\t', 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: Table 2 - Photometry and Spectral Types for the Objects of Spectral Type M, or Slightly Earlier, Identified Toward Lupus 3 Step2: Table 4-
9,860
<ASSISTANT_TASK:> Python Code: import sklearn sklearn.__version__ import pandas as pd import numpy as np import time import datetime as dt import matplotlib.pyplot as plt from sklearn import tree from sklearn.model_selection import train_test_split %matplotlib inline column_names = pd.read_excel('langevincodebook.xlsx...
<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: Importing the data and the column names from the codebook Step2: The time in the data is measured with MATLAB's absolute time, converting to a ...
9,861
<ASSISTANT_TASK:> Python Code: %load_ext sql %sql mysql://steinam:steinam@localhost/sommer_2015 %%sql select k.kd_id, k.kd_plz, (select count(a.Au_ID) from auftrag a where a.au_kd_id = k.kd_id ) as AnzahlAuftr, (select count(f.`f_id`) from fahrten f, auftrag a where f.f_au_id = a.au_id and a.`au_kd...
<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: Sommer 2015 Step2: Warum geht kein Join ?? Step3: Der Ansatz mit Join funktioniert in dieser Form nicht, da spätestens beim 2. Join die Firma ...
9,862
<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...
<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: HW 10.0 Step2: HW 10.1 Step3: HW 10.1.1 Step4: HW 10.2 Step5: HW 10.3 Step6: The WSSE decreases with the number of iterations from 1 to 20 ...
9,863
<ASSISTANT_TASK:> Python Code: from astropy import time from astropy import units as u from poliastro.bodies import Sun, Earth, Jupiter from poliastro.ephem import Ephem from poliastro.frames import Planes from poliastro.twobody import Orbit from poliastro.plotting import StaticOrbitPlotter from poliastro import iod 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: Parking orbit Step2: Hyperbolic exit Step3: Quoting "New Horizons Mission Design" Step4: So it stays within the same order of magnitude. Whic...
9,864
<ASSISTANT_TASK:> Python Code: from os import environ slack_hook = environ.get('IRE_CFJ_2017_SLACK_HOOK', None) import json import requests # build a dictionary of payload data payload = { 'channel': '#general', 'username': 'IRE Python Bot', 'icon_emoji': ':ire:', 'text': 'helllllllo!' } # turn it in...
<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: Hello JSON Step2: Using requests to post data Step3: Formatting the data correctly Step4: Send it off to Slack
9,865
<ASSISTANT_TASK:> Python Code: # These are all the modules we'll be using later. Make sure you can import them # before proceeding further. from __future__ import print_function import numpy as np import tensorflow as tf from six.moves import cPickle as pickle from six.moves import range pickle_file = 'notMNIST.pickle...
<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: First reload the data we generated in 1_notmnist.ipynb. Step2: Reformat into a shape that's more adapted to the models we're going to train Ste...
9,866
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import matplotlib.pyplot as plt import bokeh.plotting as bkp from mpl_toolkits.axes_grid1 import make_axes_locatable %matplotlib inline # read in readmissions data provided hospital_read_df = pd.read_csv('data/cms_hospital_readmissions.csv') # deal ...
<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: Preliminary analysis
9,867
<ASSISTANT_TASK:> Python Code: import numpy as np import keras from keras.datasets import mnist # fix random seed for reproducibility np.random.seed(7) # load data (x_train,y_train), (x_test,y_test) = mnist.load_data() # show the training size, test size, number of class print("train size : ",x_train.shape) print("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: 2) Display some image samples using matplotlib.pyplot Step2: 3) (If necessary) Reduce the number of training images (for quick training and sma...
9,868
<ASSISTANT_TASK:> Python Code: from theano.sandbox import cuda %matplotlib inline import utils; reload(utils) from utils import * from __future__ import division, print_function #path = "data/dogscats/sample/" path = "data/dogscats/" model_path = path + 'models/' if not os.path.exists(model_path): os.mkdir(model_path) ...
<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: Are we underfitting? Step2: ...and load our fine-tuned weights. Step3: We're going to be training a number of iterations without dropout, so i...
9,869
<ASSISTANT_TASK:> Python Code: def calculate_minimum_split(a , k ) : p =[] n = len(a ) for i in range(1 , n ) : p . append(a[i ] - a[i - 1 ] )  p . sort(reverse = True ) min_sum = sum(p[: k - 1 ] ) res = a[n - 1 ] - a[0 ] - min_sum return res  / * Driver code * / if __name__== "__main __": ar...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
9,870
<ASSISTANT_TASK:> Python Code: import os import zipfile import numpy as np import pandas as pd from sklearn.linear_model import LinearRegression import matplotlib as mpl import matplotlib.pyplot as plt import seaborn as sns sns.set_style('darkgrid') %matplotlib inline # Put files in current direction into a list 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: Unzipping files with house sales data Step2: Loading Sales data, Sales Training data, and Sales Test data Step3: Learning a multiple regressio...
9,871
<ASSISTANT_TASK:> Python Code: from __future__ import print_function import string import operator from functools import reduce s = ''' 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 125406987471585238630507156...
<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: It seems that having s as a big string and repeatedly converting digits to ints is wasteful, so I convert s to be a list of ints and repeat the ...
9,872
<ASSISTANT_TASK:> Python Code: import pyspark sc = pyspark.SparkContext(appName="my_spark_app") sc ## just check that sc variables is not print("is SpartContext loaded?", sc != '') rdd = sc.parallelize([x for x in range(1000)],20) rdd.getNumPartitions() rdd.take(5) rdd.setName("my_rdd").persist(pyspark.StorageLeve...
<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: Interactive programming Step2: Answer 2 Step3: Answer 3 Step4: Answer 4 Step5: Answer 5
9,873
<ASSISTANT_TASK:> Python Code: import os # The Vertex AI Workbench Notebook product has specific requirements IS_WORKBENCH_NOTEBOOK = os.getenv("DL_ANACONDA_HOME") IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists( "/opt/deeplearning/metadata/env_version" ) # Vertex AI Notebook requires dependencies to be install...
<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: Restart the kernel Step2: Before you begin Step3: Get your project number Step4: Region Step5: Timestamp Step6: Authenticate your Google Cl...
9,874
<ASSISTANT_TASK:> Python Code: def kthgroupsum(k ) : cur = int(( k *(k - 1 ) ) + 1 ) sum = 0 while k : sum += cur cur += 2 k = k - 1  return sum  k = 3 print(kthgroupsum(k ) ) <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:
9,875
<ASSISTANT_TASK:> Python Code: url = None key = None import sys from docplex.cp.model import * mdl0 = CpoModel() masonry = mdl0.interval_var(size=35) carpentry = mdl0.interval_var(size=15) plumbing = mdl0.interval_var(size=40) ceiling = mdl0.interval_var(size=15) roofing = mdl0.interval_var(size=5) painting = mdl0.in...
<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: Scheduling building blocks Step2: This code creates a CP model container that allows the use of constraints that are specific to constraint pro...
9,876
<ASSISTANT_TASK:> Python Code: # As usual, a bit of setup 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_gradient_array from cs231n.solver 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: Fully-Connected Neural Nets Step4: Affine layer Step5: Affine layer Step6: ReLU layer Step7: ReLU layer Step8: "Sandwich" layers Step9: Lo...
9,877
<ASSISTANT_TASK:> Python Code: #@title License # 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 ...
<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 image to MPI example Colab Step2: Set up the model Step3: Generate an MPI from an input image, show layers and disparity Step4: Genera...
9,878
<ASSISTANT_TASK:> Python Code: import deepchem as dc import tensorflow as tf import numpy as np tasks, datasets, transformers = dc.molnet.load_tox21() train_dataset, valid_dataset, test_dataset = datasets n_tasks = len(tasks) n_features = train_dataset.X.shape[1] model = dc.models.MultitaskClassifier(n_tasks, n_feature...
<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 want to train the model using the training set, then evaluate it on the test set. As our evaluation metric we will use the ROC AUC, averaged...
9,879
<ASSISTANT_TASK:> Python Code: npz_file = "../model-mlp_n100-e100.txt.npz" # Load network params with np.load(npz_file) as f: param_values = [f['arr_%d' % i] for i in range(len(f.files))] print_statement = "Number of params: %s" % len(param_values) print(print_statement) print("="*len(print_statement)) for i in p...
<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: Inspect params Step2: weights for input to hidden layer Step3: Quick visual of weights Step5: Weight of some regions are more variable than o...
9,880
<ASSISTANT_TASK:> Python Code: !pip install -I "phoebe>=2.0,<2.1" %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_compute() b.set_value_all('mesh_method', 'wd') # TODO: for now only the 'graham'...
<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: Changing Meshing Options ...
9,881
<ASSISTANT_TASK:> Python Code: import numpy as np from sklearn.base import BaseEstimator, ClassifierMixin class MyClassifier(BaseEstimator, ClassifierMixin): An example classifier def __init__(self, param1=1, param2=2): Called when initializing the classifier The constructor is used to ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step4: <!--BOOK_INFORMATION--> Step5: The classifier can be instantiated as follows Step6: You can then fit the model to some arbitrary data Step7: ...
9,882
<ASSISTANT_TASK:> Python Code: #import packages import warnings warnings.simplefilter("ignore") import sys import nibabel as nib import numpy as np import os from PIL import Image, ImageDraw,ImageFont import matplotlib.pyplot as plt from m2g.stats.qa_skullstrip import gen_overlay_pngs def gen_overlay_pngs( brain, ...
<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: gen_overlay_pngs Step4: plot_overlays_skullstrip Step5: Inputs Step6: Run AFNI 3dSkullStrip to do skull strip Step7: Run qa_skullstrip.py
9,883
<ASSISTANT_TASK:> Python Code: from dist_time import * import pandas as pd from collections.abc import Iterator, Iterable, Generator from collections import defaultdict import re from sqlalchemy import create_engine from sqlalchemy.types import Integer, Text, DateTime, Float, VARCHAR from sqlalchemy import Table, MetaD...
<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: NC件 Step2: R类 Step3: D类 Step4: s类 Step5: I类 Step6: U-U类 Step7: concat
9,884
<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', 'toplevel') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("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: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 2...
9,885
<ASSISTANT_TASK:> Python Code: from transitions import Machine import json class Model: def say_hello(self, name): print(f"Hello {name}!") # import json json_config = { "name": "MyMachine", "states": [ "A", "B", { "name": "C", "on_enter": "say_hello" } ], "transitions": [ ["go", "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: Frequently asked questions Step3: Loading a YAML configuration Step4: Exporting YAML or JSON Step5: How to use transitions with django models...
9,886
<ASSISTANT_TASK:> Python Code: # This useful nonsense just goes at the top from datascience import * import numpy as np import matplotlib.pyplot as plots plots.style.use('fivethirtyeight') %matplotlib inline # datascience version number of last run of this notebook version.__version__ raw_berkeley_sal_2011 = Table.rea...
<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: Reading raw data into a Table Step2: Accessing data in a Table Step3: Some prefer the selectors - column and row Step4: Rows in the table can...
9,887
<ASSISTANT_TASK:> Python Code: # http://api.census.gov/data/2010/surname import requests import json import pandas as pd import matplotlib.pyplot as plt # First, get the basic info about the dataset. # References: Dataset API (https://api.census.gov/data/2010/surname.html) # Requests API (http://docs.pyth...
<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: 2. Basic interactions with the Census dataset API Step2: Get surname data Step3: Laying out the API response like a table helps illustrate wha...
9,888
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'ncc', 'noresm2-lmec', 'atmos') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "em...
<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...
9,889
<ASSISTANT_TASK:> Python Code: import json import os import boto3 s3 = boto3.client("s3") # create instance response = !aws ec2 run-instances --image-id ami-a9d276c9 \ --count 1 \ --instance-type t2.micro \ --key-name ec2_rob \ --security-groups ssh_only \ --block-device-mappings file://examples/bl...
<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: <hr> Step2: You can specify a script to run on startup with the <code>--user-data</code> option. This enables you to do things like automatical...
9,890
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt import scipy.sparse as sp import scipy.sparse.linalg as sla # autoreload the lattice module so that we can make changes to it # without restarting the ipython notebook server %load_ext autoreload %autoreload 1 %aimpor...
<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: Next import the dvr_1d module. We import dvr_1d using a series of ipython notebook magic commands so that we can make changes to the module file...
9,891
<ASSISTANT_TASK:> Python Code: #!pip install google-cloud-bigquery %load_ext google.cloud.bigquery PROJECT='cloud-training-demos' # CHANGE THIS %%bigquery --project $PROJECT SELECT start_station_name , AVG(duration) as duration , COUNT(duration) as num_trips FROM `bigquery-public-data`.london_bicycles.cycle_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: Run a query Step2: Run a parameterized query Step3: Into a dataframe
9,892
<ASSISTANT_TASK:> Python Code: # remove display of install details %%capture --no-display !pip install ipyparallel # authorize Google to access Google drive files !pip install -U -q PyDrive from pydrive.auth import GoogleAuth from pydrive.drive import GoogleDrive from google.colab import auth from oauth2client.client i...
<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: End of Warning Step2: Problem 1) Light Curve Data Step3: As we have many light curve files (in principle as many as 37 billion...), we will de...
9,893
<ASSISTANT_TASK:> Python Code: !pip install -I "phoebe>=2.2,<2.3" import phoebe from phoebe import u # units import numpy as np import matplotlib.pyplot as plt logger = phoebe.logger() b = phoebe.default_binary() times = np.linspace(0,1,21) b.add_dataset('lc', times=times, dataset='lc01') b.add_dataset('rv', times=ti...
<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 Datasets Step3: R...
9,894
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE from urllib.request import urlretrieve from os.path import isfile, isdir from tqdm import tqdm import problem_unittests as tests import tarfile cifar10_dataset_folder_path = 'cifar-10-batches-py' # Use Floyd's cifar-10 dataset if ...
<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: Image Classification Step2: Explore the Data Step5: Implement Preprocess Functions Step8: One-hot encode Step10: Randomize Data Step12: Che...
9,895
<ASSISTANT_TASK:> Python Code: import os import sys from glob import glob import json import numpy as np from astropy.table import Table from Chandra.Time import DateTime from Ska.Matplotlib import plot_cxctime from chandra_aca import drift import parse_cm TEST_DIR = '/proj/sot/ska/ops/SFE/JUL0415O/oflso' dynam_table ...
<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: Check dynamic offset file for consistency Step2: Run the ACA model and get new offsets Step3: Compare values to dynamic offset table from Matl...
9,896
<ASSISTANT_TASK:> Python Code: import gachon_autograder_client as g_autograder EMAIL = "#YOUR_EMAIL" PASSWORD = "#YOUR_PASSWORD" ASSIGNMENT_NAME = "nb_test" g_autograder.get_assignment(EMAIL, PASSWORD, ASSIGNMENT_NAME) def addition(a, b): result = None return result # 실행결과 print (addition(5, 3)) print (additio...
<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: 위 소스 코드를 .py 파일 또는 jupyter notebook에 입력하여 파이썬으로 실행 시키면 "nb_arithmetic_functions.ipynb" 파일이 생성되며, jupyter notebook으로 실행하거나, 콘솔창(cmd)에서 해당 파일이 있는 ...
9,897
<ASSISTANT_TASK:> Python Code:: from sklearn.metrics import mean_squared_error rmse = mean_squared_error(y_test, y_pred, squared = False) <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:
9,898
<ASSISTANT_TASK:> Python Code: import numpy as np import scipy.io import scipy.optimize import matplotlib.pyplot as plt %matplotlib inline # uncomment for console - useful for debugging # %qtconsole ex3data1 = scipy.io.loadmat("./ex4data1.mat") X = ex3data1['X'] y = ex3data1['y'][:,0] m, n = X.shape m, n input_layer_si...
<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: Part 1 Step2: Part 2 Step3: Unrolling the parameters into one vector Step4: Part 3 Step5: The cost at the given parameters should be about 0...
9,899
<ASSISTANT_TASK:> Python Code: import py2neo import pandas as pd graph= py2neo.Graph() query= MATCH (s1:Subdomain)<-[:BELONGS_TO]- (type:Type)-[r:DEPENDS_ON*0..1]-> (dependency:Type)-[:BELONGS_TO]->(s2:Subdomain) RETURN s1.name as from, s2.name as to, COUNT(r) as x_number result = graph.run(query).data() 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: Step1: Optimierung des fachlichen Schnitts Step2: Graph-Abfrage-Ergebnis Step3: Visualisierungsdaten