Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
11,300
<ASSISTANT_TASK:> Python Code: def straight_line(x): return 5 * x + 8 straight_line(25) straight_line(1.254) np.random.seed(5) samples = 150 x_vals = pd.Series(np.random.rand(samples) * 20) y_vals = x_vals.map(straight_line) # Add random noise y_noisy_vals = y_vals + np.random.randn(samples) * 3 df = pd.DataFrame({...
<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: <h4>Training and Evaluation Set</h4> Step2: <h4>Test Set</h4> Step3: <h4>Read the target predicted by AWS ML</h4> Step4: <h4>AWS ML Estimated...
11,301
<ASSISTANT_TASK:> Python Code: import requests url="https://api.forecast.io/forecast/64f4867f7d4c86182f3d1c6ed881dbfc/17.3850,78.4867" response=requests.get(url) data=response.json() data.keys() data['currently'].keys() print("The current wind speed is",data['currently']['windSpeed'],"miles per hour.") apparentTempera...
<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) What's the current wind speed? How much warmer does it feel than it actually is? Step2: 3) The first daily forecast is the forecast for toda...
11,302
<ASSISTANT_TASK:> Python Code: import numpy from rmtk.vulnerability.common import utils from rmtk.vulnerability.derivation_fragility.NLTHA_on_SDOF import MSA_utils from rmtk.vulnerability.derivation_fragility.NLTHA_on_SDOF.read_pinching_parameters import read_parameters from rmtk.vulnerability.derivation_fragility.NLTH...
<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 capacity curves Step2: Load ground motion records Step3: Load damage state thresholds Step4: Calculate fragility function Step5: Fit lo...
11,303
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt %matplotlib inline from IPython.display import HTML HTML('../style/course.css') #apply general CSS from IPython.display import HTML import ephem import matplotlib %pylab inline pylab.rcParams['figure.figsize'] = (15, 10) import matplotl...
<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 specific modules Step2: 3.2 Hour Angle (HA) and Local Sidereal Time (LST)
11,304
<ASSISTANT_TASK:> Python Code: fileName='book.txt' import re def removePunctuation(text): return re.sub('[^a-z| |0-9]', '', text.strip().lower()) shakespeareRDD = (sc .textFile(fileName, 8) .map(removePunctuation)) shakespeareRDD.take(4) print '\n'.join(shakespeareRDD ...
<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: Ahora vamos a eliminar todo aquello que no se consideren cadenas de texto válidas. Para ello definiremos una función que elimine aquello que no ...
11,305
<ASSISTANT_TASK:> Python Code: import NotebookImport from Imports import * import seaborn as sns sns.set_context('paper',font_scale=1.5) sns.set_style('white') matched_rna = pd.read_hdf('/data_ssd/RNASeq_2014_07_15.h5', 'matched_tn') rna_microarray = pd.read_hdf('/data_ssd/GEO_microarray_dx.h5', 'data') matched_rna = ...
<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: Read in matched Gene expression data. Step2: Run a simple screen for DX probes Step3: Pathway and Gene Annotation Analysis Step4: Overexpress...
11,306
<ASSISTANT_TASK:> Python Code: from __future__ import print_function import numpy as np from sklearn.linear_model import Ridge from flexible_linear import FlexibleLinearRegression import matplotlib import matplotlib.pyplot as plt matplotlib.style.use('ggplot') %matplotlib inline np.random.seed(1) N = 500 A = 50 B = 3 ...
<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: Generate some data Step2: Let's try adding Gaussian (normal) noise... Step3: ... or some Cauchy (heavy-tailed) noise Step4: Trying to recover...
11,307
<ASSISTANT_TASK:> Python Code: from jyquickhelper import add_notebook_menu add_notebook_menu() import random X = [random.random() * 16 for i in range(0,1000)] Y = [ int(x**0.5) % 2 for x in X] %matplotlib inline import matplotlib.pyplot as plt plt.plot(X, Y, '.') nuage = [(x,y) for x,y in zip(X,Y)] nuage.sort() nuag...
<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: Q1 - échantillon aléatoire Step2: Q1 - dessiner le nuage de points - donnée Step3: Q2 - tri Step4: Q3 - moyenne Step5: Q4 - distance Step6: ...
11,308
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'nerc', 'sandbox-3', 'seaice') # 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: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 2...
11,309
<ASSISTANT_TASK:> Python Code: from ftplib import FTP import os import numpy as np ftp = FTP('ftp.sltac.cls.fr') ftp.login('pprandi','PierreCMEMS2017') ftp.retrlines('LIST') ftp.cwd('Core/SEALEVEL_GLO_PHY_L4_REP_OBSERVATIONS_008_047/dataset-duacs-rep-global-merged-allsat-phy-l4-v3/2016/') ftp.retrlines('LIST') fil...
<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: init the connection to the ftp server Step2: What is in the current directory ? Step3: change to the directory of level 4 delayed-time global ...
11,310
<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: Passage Ranking using TFR-BERT Step2: Import TensorFlow Ranking and useful libraries through the notebook. Step3: Data preparation Step4: Ove...
11,311
<ASSISTANT_TASK:> Python Code: import pandas as pd import oandapy import configparser config = configparser.ConfigParser() config.read('../config/config_v1.ini') account_id = config['oanda']['account_id'] api_key = config['oanda']['api_key'] oanda = oandapy.API(environment="practice", access_token...
<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 oandapy wraps the Oanda API in a format that make our codes cleaner and the task of extracting information from the API easier. Step2: We i...
11,312
<ASSISTANT_TASK:> Python Code: import wicked as w import time from IPython.display import display, Math, Latex def latex(expr): Function to render any object that has a member latex() function display(Math(expr.latex())) w.reset_space() w.add_space('o','fermion','occupied',['i','j','k','l','m','n']) w.add_spac...
<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: Automatic generation of coupled cluster equations Step2: Define the orbital spaces Step3: Define the Hamiltonian operator Step4: Define a fun...
11,313
<ASSISTANT_TASK:> Python Code: def pretty_print_review_and_label(i): print(labels[i] + "\t:\t" + reviews[i][:80] + "...") g = open('reviews.txt','r') # What we know! reviews = list(map(lambda x:x[:-1],g.readlines())) g.close() g = open('labels.txt','r') # What we WANT to know! labels = list(map(lambda x:x[:-1].uppe...
<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 Step2: Lesson Step3: Project 1 Step4: We'll create three Counter objects, one for words from postive reviews, one for words from negativ...
11,314
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'noaa-gfdl', 'sandbox-1', '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...
11,315
<ASSISTANT_TASK:> Python Code: %load_ext watermark %watermark -v -u -d -p scipy,scikit-learn,numpy,matplotlib from scipy.spatial.distance import pdist, squareform from scipy import exp from scipy.linalg import eigh import numpy as np def stepwise_kpca(X, gamma, n_components): Implementation of a RBF kernel PC...
<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: <font size="1.5em">More information about the watermark magic command extension.</font> Step3: <br> Step4: <br> Step5: As we can see, the res...
11,316
<ASSISTANT_TASK:> Python Code: import numpy as np import os import tensorflow as tf import urllib.request # Define a constant indicating the number of layers in our loaded model. We're loading a # resnet-50 model. RESNET_SIZE = 50 # Model and serving directories MODEL_DIR="resnet_model_checkpoints" SERVING_DIR="esti...
<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 model checkpoint Step2: Import the Model Architecture Step3: Exercise Step4: Build the Servable from the Estimator API Step6: Helpe...
11,317
<ASSISTANT_TASK:> Python Code: import ee ee.Initialize() from geetools import bitreader, cloud_mask options = { '0-1': {0:'clear', 1:'cloud', 2:'mix'}, # cloud state '2-2': {0: 'no_shadow', 1:'shadow'}, # cloud shadow (bit 0 is not needed) '6-7': {0:'climatology', 1:'low', 2:'average', 3:'high'} # land/water flag...
<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: Internally it computes a dict with Step2: DECODE ONE VALUE Step3: MATCH ONE VALUE Step4: ENCODE A VALUE (EXCLUSIVELLY) Step5: ENCODE A VALUE...
11,318
<ASSISTANT_TASK:> Python Code: from zipline.pipeline.data import USEquityPricing as USEP from zipline.pipeline.factors import SimpleMovingAverage # sma30 and sma90 are Factors. # Factors represent computations producing numerical-valued outputs. sma30 = SimpleMovingAverage(inputs=[USEP.close], window_length=30) sma90 =...
<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: Example Step3: Example
11,319
<ASSISTANT_TASK:> Python Code: # this is a hidden cell print( <div class="output_area rendered_html docutils container"> {table} </div> .format(table = table.replace('\n', ""))) import pandas as pd from siuba import _, mutate my_data = pd.DataFrame({ 'g': ['a', 'a', 'b'], 'x': [1,2,3], }) # pandas my_data.as...
<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: Key features Step2: Built on pandas Step3: Note how you can debug both pieces of code by running and inspecting df.a.mean(). Step4: Notice ho...
11,320
<ASSISTANT_TASK:> Python Code: #!pip install -I "phoebe>=2.4,<2.5" import phoebe from phoebe import u # units import numpy as np b = phoebe.default_binary() b = phoebe.default_binary() b.add_dataset('lc', times=phoebe.linspace(0,5,1001)) b.run_compute() times = b.get_value('times@model') fluxes = b.get_value('fluxes@...
<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 get started with some basic imports. Step2: And then we'll build a synthetic "dataset" and initialize a new bundle with those data Step3:...
11,321
<ASSISTANT_TASK:> Python Code: # Uncomment and run this one time only # !pip install http://download.pytorch.org/whl/cu75/torch-0.1.12.post2-cp27-none-linux_x86_64.whl # !pip install torchvision==0.1.8 # !pip install tabulate # !pip install --upgrade scikit-learn # !pip install --upgrade numpy # !pip install h5py # !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: <br> Step2: <br> Step7: <br> Step8: Select a simulation file to test Step9: Load the parameters for the models Step10: <br> Step11: <br> S...
11,322
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline train = pd.read_csv('titanic_train.csv') train.head(25) sns.heatmap(train.isnull(),yticklabels=False,cbar=False,cmap='viridis') sns.set_style('whitegrid') sns.countplot(x='Su...
<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 Data Step2: Exploratory Data Analysis Step3: Roughly 20 percent of the Age data is missing. The proportion of Age missing is likely small ...
11,323
<ASSISTANT_TASK:> Python Code: import numpy as np from scipy import linalg import mne from mne.datasets import sample from mne.viz import plot_sparse_source_estimates data_path = sample.data_path() fwd_fname = data_path + '/MEG/sample/sample_audvis-meg-eeg-oct-6-fwd.fif' ave_fname = data_path + '/MEG/sample/sample_audv...
<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: Auxiliary function to run the solver Step4: Define your solver Step5: Apply your custom solver Step6: View in 2D and 3D ("glass" brain like 3...
11,324
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import json import graphviz import matplotlib.pyplot as plt from sklearn import tree from sklearn.model_selection import train_test_split pd.set_option("display.max_rows",6) %matplotlib inline df_data = pd.read_csv(r'varsom_ml_preproc_3y.csv', index_...
<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: RANDOM FORESTS Step2: The first avalanche problem dictates the danger level - that was expected Step3: Looks like there is little gain when u...
11,325
<ASSISTANT_TASK:> Python Code: # Ignore %load_ext sql %sql sqlite:// %config SqlMagic.feedback = False %%sql -- Create a table of criminals CREATE TABLE criminals (pid, name, age, sex, city, minor); INSERT INTO criminals VALUES (412, 'James Smith', 15, 'M', 'Santa Rosa', 1); INSERT INTO criminals VALUES (234, 'Bill Ja...
<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 Data Step2: Alias Criminals Table A C, Then Select All Names From C
11,326
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL import helper import problem_unittests as tests source_path = 'data/small_vocab_en' target_path = 'data/small_vocab_fr' source_text = helper.load_data(source_path) target_text = helper.load_data(target_path) view_sentence_range = (0, 10) DON'T MODIFY 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: Language Translation Step3: Explore the Data Step6: Implement Preprocessing Function Step8: Preprocess all the data and save it Step10: Chec...
11,327
<ASSISTANT_TASK:> Python Code: #TODO add to cointainer !pip install umap-learn import numpy as np from numpy.random import seed import scipy.stats as stats from scipy.stats import uniform, truncnorm, randint import random import pandas as pd from sklearn.decomposition import PCA from sklearn.preprocessing import Standa...
<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='1_data_cleaning'></a> Step2: Construction "./" means we use the current folder of the script. "../" would mean - one level higher relati...
11,328
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'nerc', 'hadgem3-gc31-hm', 'aerosol') # 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: 1...
11,329
<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: 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 ...
11,330
<ASSISTANT_TASK:> Python Code: PROJECT = "cloud-training-demos" # Replace with your PROJECT BUCKET = "cloud-training-bucket" # Replace with your BUCKET REGION = "us-central1" # Choose an available region for Cloud MLE TFVERSION = "1.14" # TF version for CMLE to use import os os.environ["BUCK...
<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: <h2> Explore data </h2> Step4: Let's write a query to find the unique values for a given column and see how the number of babies and their aver...
11,331
<ASSISTANT_TASK:> Python Code: import os import sys # From https://stackoverflow.com/a/36218558 . def sparkImport(module_name, module_directory): Convenience function. Tells the SparkContext sc (must already exist) to load module module_name on every computational node before executing an RDD...
<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: Tweet Count Analysis Step2: Count 'Em Step3: Less than $1\%$ of our tweets are duplicates, so we have approximately the quantity of tweets tha...
11,332
<ASSISTANT_TASK:> Python Code: import numpy as np import os SHOGUN_DATA_DIR=os.getenv('SHOGUN_DATA_DIR', '../../../data') from scipy.io import loadmat, savemat from numpy import random from os import path mat = loadmat(os.path.join(SHOGUN_DATA_DIR, 'multiclass/usps.mat')) Xall = mat['data'] Yall = np.array(ma...
<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 us plot the first five examples of the train data (first row) and test data (second row). Step2: Then we import shogun components and conve...
11,333
<ASSISTANT_TASK:> Python Code: import espressomd espressomd.assert_features(["ELECTROSTATICS", "ROTATION", "ROTATIONAL_INERTIA", "EXTERNAL_FORCES", "MASS", "VIRTUAL_SITES_RELATIVE", "CUDA", "LENNARD_JONES"]) from espressomd import interactions from espressomd import electrostatics from espre...
<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 parameter <tt>box_l</tt> sets the size of the simulation box. In general, one should check for finite Step2: The skin is used for construct...
11,334
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'ncc', 'noresm2-mh', 'ocnbgchem') # 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: 1...
11,335
<ASSISTANT_TASK:> Python Code: import os import warnings import tqdm import numpy as np import pandas as pd warnings.simplefilter(action='ignore', category=pd.errors.PerformanceWarning) %load_ext autoreload %autoreload 2 import socceraction.spadl as spadl import socceraction.vaep.features as fs import socceraction.vaep...
<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: Select data Step2: Train models
11,336
<ASSISTANT_TASK:> Python Code: !sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst # Ensure the right version of Tensorflow is installed. !pip freeze | grep tensorflow==2.5 from google.cloud import bigquery import tensorflow as tf import numpy as np import shutil print(tf.__version__) CSV_COLUMNS = ['fa...
<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: <h2> 1. Refactor the input </h2> Step2: <h2> 2. Refactor the way features are created. </h2> Step3: <h2> Create and train the model </h2> Step...
11,337
<ASSISTANT_TASK:> Python Code: import os PROJECT = 'cloud-training-demos' # REPLACE WITH YOUR PROJECT ID REGION = 'us-central1' # Choose an available region for Cloud MLE from https://cloud.google.com/ml-engine/docs/regions. BUCKET = 'cloud-training-demos-ml' # REPLACE WITH YOUR BUCKET NAME. Use a regional bucket in th...
<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: Allow the Cloud ML Engine service account to read/write to the bucket containing training data. Step2: <h2> Packaging up the code </h2> Step3: ...
11,338
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np l = [('A', 'a', '1'), ('A', 'b', '2'), ('B','a', '1'), ('A', 'b', '1'), ('B','b', '1'), ('A', 'a', '2')] np.random.seed(1) df = pd.DataFrame(np.random.randn(5, 6), columns=l) def g(df): df=df[sorted(df.columns.to_list())] df.columns = pd.Mu...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
11,339
<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...
11,340
<ASSISTANT_TASK:> Python Code: !sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst # Ensure the right version of Tensorflow is installed. !pip freeze | grep tensorflow==2.1 || pip install tensorflow==2.1 import numpy as np import tensorflow as tf from matplotlib import pyplot as plt print(tf.__version__)...
<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: Operations on Tensors Step2: Point-wise operations Step3: NumPy Interoperability Step4: You can convert a native TF tensor to a NumPy array u...
11,341
<ASSISTANT_TASK:> Python Code: lst_2d = [ [2, 4, 'unicorn'], [False, 39], [None], ] lst_3d = [ [[1, 1, 2], [3, 5], [8, 13]], [[21, 34], [55]] ] matrix = [ [0, 0, 1, 5], [1, 0, 2, 0], [0, 3, 1, 0], ] matrix = [ [0, 0, 1, 5], [1, 0, 2, 0], [0, 3, 1, 0], ] print(matrix[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: Похожим образом можно сделать трёхмерный список. Step2: Чаще всего используются двумерные списки с равным количеством элементов в каждой строке...
11,342
<ASSISTANT_TASK:> Python Code: import numpy as np import h5py import matplotlib.pyplot as plt from testCases_v2 import * from dnn_utils_v2 import sigmoid, sigmoid_backward, relu, relu_backward %matplotlib inline plt.rcParams['figure.figsize'] = (5.0, 4.0) # set default size of plots plt.rcParams['image.interpolation'] ...
<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: 2 - Outline of the Assignment Step4: Expected output Step6: Expected output Step8: Expected output Step10: Expected output Step12: <table s...
11,343
<ASSISTANT_TASK:> Python Code: #type your code here runningTotal = 0 listOfNumbers = [4,7,9,1,8,6] #type your code here print(listOfNumbers) print("The average of these numbers is {0:.2f}".format(average)) word = "Python" print(len(word)) #type your code here numbers = (1, 2, 3, 4, 5, 6, 7, 8, 9) # Declaring the tup...
<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.1 Step2: 1.1 Step3: 1.2 Step4: 1.3 Step5: 1.4 Step6: 1.5 (Multi-Part) Step7: b. Use the print() function to print your list. Step8: c. ...
11,344
<ASSISTANT_TASK:> Python Code: # Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr> # Stefan Appelhoff <stefan.appelhoff@mailbox.org> # Richard Höchenberger <richard.hoechenberger@gmail.com> # # License: BSD (3-clause) import os.path as op import numpy as np import matplotlib.pyplot as plt 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: Set parameters Step2: Frequency analysis Step3: Now let's take a look at the spatial distributions of the PSD. Step4: Alternatively, you can ...
11,345
<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: Use XLA with tf.function Step2: Then define some necessary constants and prepare the MNIST dataset. Step3: Finally, define the model and the o...
11,346
<ASSISTANT_TASK:> Python Code: # Basic imports import os import pandas as pd import matplotlib.pyplot as plt import numpy as np import datetime as dt import scipy.optimize as spo import sys from time import time from sklearn.metrics import r2_score, median_absolute_error from multiprocessing import Pool %matplotlib inl...
<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 show the symbols data, to see how good the recommender has to be. Step2: Let's run the trained agent, with the test set Step3: And now a...
11,347
<ASSISTANT_TASK:> Python Code: import scipy.integrate import math import numpy as np def NDfx(x): return((1/math.sqrt((2*math.pi)))*(math.e**((-.5)*(x**2)))) x = 2.5 u = 1 o2 = 3 norm = (x-u)/o2 prob = scipy.integrate.quad(NDfx, -np.inf, norm)[0] <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:
11,348
<ASSISTANT_TASK:> Python Code: # Author: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr> # Daniel Strohmeier <daniel.strohmeier@tu-ilmenau.de> # # License: BSD (3-clause) import numpy as np import mne from mne.datasets import sample from mne.minimum_norm import make_inverse_operator, apply_inverse ...
<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 solver Step2: Plot dipole activations Step3: Show the evoked response and the residual for gradiometers Step4: Generate stc from dipoles ...
11,349
<ASSISTANT_TASK:> Python Code: #%matplotlib inline import warnings warnings.filterwarnings("ignore") import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import numpy as np from scipy import stats from sklearn.model_selection import train_test_split from sklearn.linear_model import LogisticRegressi...
<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: Luego se cargan los datos de la competencia Step2: Visualización de datos y estudio inicial Step3: Como puede observarse hay un total de 12 co...
11,350
<ASSISTANT_TASK:> Python Code: def quad_roots(a=1.0, b=2.0, c=0.0): Returns the roots of a quadratic equation: ax^2 + bx + c = 0. INPUTS ======= a: float, optional, default value is 1 Coefficient of quadratic term b: float, optional, default value is 2 Coefficient of linear term ...
<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: Lecture 7 Step3: Documenting Invariants Step4: Accessing Documentation (1) Step5: Accessing Documentation (2) Step6: Testing Step7: Princip...
11,351
<ASSISTANT_TASK:> Python Code: # to make sure things are working, run this import pandas as pd print('Pandas version: ', pd.__version__) import pandas as pd import matplotlib.pyplot as plt import datetime as dt %matplotlib inline url = 'http://pages.stern.nyu.edu/~dbackus/Data/beer_production_1947-2004.xlsx' beer ...
<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 get something like "Pandas version Step2: Remind yourself Step3: Question. Can you see consolidation here? Step4: Answer these questio...
11,352
<ASSISTANT_TASK:> Python Code: %%bash pip install apache-beam[gcp] import os PROJECT = 'cloud-training-demos' # REPLACE WITH YOUR PROJECT ID BUCKET = 'cloud-training-demos-ml' # REPLACE WITH YOUR BUCKET NAME REGION = 'us-central1' # REPLACE WITH YOUR BUCKET REGION e.g. us-central1 MODEL_TYPE = 'tpu' # do not change th...
<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: After doing a pip install, click on Reset Session so that the Python environment picks up the new package Step2: Preprocess JPEG images to TF R...
11,353
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import astropy.io.fits as fits ## make matplotlib appear in the notebook rather than in a new window %matplotlib inline datadir = '' objname = '2016HO3' def plotfits(imno): img = fits.open(datadir+objname+'_{0:02d}.fits'.format(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: 0.1 Directory Set up Step2: 0.2 Display images Step3: 1. Photometry set up Step4: Define starting values. Fill in values here Step5: Apertur...
11,354
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'awi', 'awi-cm-1-0-hr', 'land') # 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...
11,355
<ASSISTANT_TASK:> Python Code: import warnings warnings.filterwarnings('ignore') import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline #Reading the dataset in a dataframe using Pandas df = pd.read_csv('../data/master.csv') #Print first observations df.head() ...
<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. Import dataset Step2: Throughout the Machine Learning part of this project we will be using scikit-learn, an open source machine learning li...
11,356
<ASSISTANT_TASK:> Python Code: # Author: Annalisa Pascarella <a.pascarella@iac.cnr.it> # # License: BSD (3-clause) import os.path as op import matplotlib.pyplot as plt import mne from mne.datasets import sample from mne import setup_volume_source_space from mne import make_forward_solution from mne.minimum_norm import ...
<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 our source space. Step2: Export source positions to nift file
11,357
<ASSISTANT_TASK:> Python Code: plt.figure(figsize=(10,6)); plt.scatter(Peaks,Energy); plt.xlim(0,240) plt.ylim(0,1000) plt.xlabel('x (mm)'); plt.ylabel('y (mm)'); plt.plot(xlots,yfit); plt.legend(['data','Fit'],loc='lower right'); plt.text(5,900,'a = %.3f +/- %.3f keV' % (plsq[0], np.sqrt(pcov[0,0])),size=17) plt.text(...
<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
11,358
<ASSISTANT_TASK:> Python Code: from learning import * from notebook import * train_img, train_lbl, test_img, test_lbl = load_MNIST() print("Training images size:", train_img.shape) print("Training labels size:", train_lbl.shape) print("Testing images size:", test_img.shape) print("Testing labels size:", test_lbl.shap...
<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: CONTENTS Step2: Check the shape of these NumPy arrays to make sure we have loaded the database correctly. Step3: Visualizing Data Step4: Let'...
11,359
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import numpy as np import pickle %matplotlib inline def read_weather(): with open('data/weather.pkl', 'rb') as f: return pickle.load(f) # The file weather.pkl contains a list of dictionaries Data = read_weather() Data[0] # Implement Q1 part 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: The purpose of the exersise is to manipulate and plot the current weather of a number of European cities. The data has been downloaded from Open...
11,360
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pandas as pd import numpy as np import cProfile from pstatsviewer import StatsViewer from qgrid import nbinstall nbinstall() # Construct two 5000 x 8 frames with random floats. df1 = pd.DataFrame( np.random.randn(5000, 8), columns=[chr(ord('A') + i) for 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: Generating stats files with cProfile Step2: Table/Grid View Step3: Chart View Step5: Comparing Alternative Implementations Step6: Comparison...
11,361
<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: Making new Layers and Models via subclassing Step2: The Layer class Step3: You would use a layer by calling it on some tensor input(s), much l...
11,362
<ASSISTANT_TASK:> Python Code: import os.path as op import numpy as np import matplotlib.pyplot as plt import mne data_path = mne.datasets.sample.data_path() fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis-ave.fif') evoked = mne.read_evokeds(fname, baseline=(None, 0), proj=True) print(evoked) evoked_l_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: In this tutorial we focus on plotting functions of Step2: Notice that evoked is a list of Step3: Let's start with a simple one. We plot even...
11,363
<ASSISTANT_TASK:> Python Code: import numpy as np # Intialize random number generator np.random.seed(123) # True parameter values alpha, sigma = 1, 1 beta = [1, 2.5] # Size of dataset size = 100 # Predictor variable X1 = np.linspace(0, 1, size) X2 = np.linspace(0,.2, size) # Simulate outcome variable Y = alpha + beta[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: Here is what the simulated data look like. We use the pylab module from the plotting library matplotlib. Step2: Model Specification Step3: Now...
11,364
<ASSISTANT_TASK:> Python Code: ## import ipyrad and give it a shorter name import ipyrad as ip ## create a test assembly data = ip.Assembly("data") data.set_params('project_dir', 'test') data.set_params('raw_fastq_path', 'ipsimdata/rad_example_R1_.fastq.gz') data.set_params('barcodes_path', 'ipsimdata/rad_example_barc...
<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: Either create a new ipyrad assembly or load an existing one Step2: Or load a finished assembly from its JSON file Step3: Look at the stats sum...
11,365
<ASSISTANT_TASK:> Python Code: from pandas import Series, DataFrame import pandas as pd f = r'/home/hase/Documents/ZHAW/InfoEng/Lectures/Scripting/data/titanic3_test.csv' fo = r'/home/hase/Documents/ZHAW/InfoEng/Lectures/Scripting/data/submit/titanic3_test_gender.csv' df = pd.read_csv(f, sep=';', index_col='id', usec...
<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 path to working csv files, input and output Step2: Create a dataframe from the csv file Step3: Add a new column named "survived" Step4:...
11,366
<ASSISTANT_TASK:> Python Code: !pip install hanlp_restful -U from hanlp_restful import HanLPClient HanLP = HanLPClient('https://www.hanlp.com/api', auth=None, language='zh') # auth不填则匿名,zh中文,mul多语种 doc = HanLP('2021年HanLPv2.1为生产环境带来次世代最先进的多语种NLP技术。', tasks='srl') print(doc) doc.pretty_print() for i, pas in enumera...
<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: 返回值为一个Document Step4: doc['srl']字段为语义角色标注结果,每个四元组的格式为[论元或谓词, 语义角色标签, 起始下标, 终止下标]。其中,谓词的语义角色标签为PRED,起止下标对应以tok开头的第一个单...
11,367
<ASSISTANT_TASK:> Python Code: #### Libraries # Third Party Libraries import numpy as np from sklearn.model_selection import train_test_split import theano import theano.tensor as T from theano.tensor.nnet import conv2d from theano.tensor.signal import pool class ConvLayer(object): def __init__(self, input, filter...
<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: Convolution Layer Step2: Pooling layer Step3: Fully Connected Layer Step5: Building The Model Step6: Convolutional Neural Network Step7: Co...
11,368
<ASSISTANT_TASK:> Python Code: from pydna.all import * frags = parse(''' >1|random sequence|A: 0.25|C: 0.25|G: 0.25|T: 0.25|length: 50 bp ccagaatacagtgccttagatctacggatcgtatctgcgatttggccgat >2|random sequence|A: 0.25|C: 0.25|G: 0.25|T: 0.25|length: 50 bp gccctgcttggtagatcaggcgagccaataacattctatagtgtagcctt >3|random sequ...
<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 sequences below were generated here. Step2: We make a list of amplicons (sequences with pairs of primers from the Dseqrecords) Step3: We n...
11,369
<ASSISTANT_TASK:> Python Code: %matplotlib inline # All the imports from __future__ import print_function, division from math import * import random import sys import matplotlib.pyplot as plt # TODO 1: Enter your unity ID here __author__ = "pwang13" class O: Basic Class which - Helps dynamic updates ...
<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: Optimizing Real World Problems Step12: The Generic Problem Class Step14: Great. Now that the class and its basic methods is defined, lets exte...
11,370
<ASSISTANT_TASK:> Python Code: from numpy.random import choice from scipy.stats import beta class DirichletProcessSample(): def __init__(self, base_measure, alpha): self.base_measure = base_measure self.alpha = alpha self.cache = [] self.weights = [] self.total_stic...
<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 illustrate again with a standard normal base measure. We can construct a function base_measure that generates samples from it. Step2: Bec...
11,371
<ASSISTANT_TASK:> Python Code: def pretty_print_review_and_label(i): print(labels[i] + "\t:\t" + reviews[i][:80] + "...") g = open('reviews.txt','r') # What we know! reviews = list(map(lambda x:x[:-1],g.readlines())) g.close() g = open('labels.txt','r') # What we WANT to know! labels = list(map(lambda x:x[:-1].uppe...
<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: Lesson Step2: Project 1 Step5: Transforming Text into Numbers
11,372
<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 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: Step1: Spectral Representations of Natural Images Step2: Image Upload Step3: We rescale images to a reasonable resolution, otherwise this would take ...
11,373
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import sklearn import matplotlib.pyplot as plt import seaborn as sns from IPython.display import display %matplotlib inline train_data = pd.read_csv("train.csv") train_data = train_data.drop('Id', axis=1) test_data = pd.read_csv("test.csv") test_data...
<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 for a bit of exploratory data analysis so we can get to know our data Step2: Plot the data Step3: I'm sure there are more creative and inf...
11,374
<ASSISTANT_TASK:> Python Code: # install Pint if necessary try: import pint except ImportError: !pip install pint # download modsim.py if necessary from os.path import exists filename = 'modsim.py' if not exists(filename): from urllib.request import urlretrieve url = 'https://raw.githubusercontent.com/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: Step4: Here the code from previous chapters we'll reuse. Step5: In the previous chapter we defined metrics that quantify the performance of bike shari...
11,375
<ASSISTANT_TASK:> Python Code: wadiz_df = pd.DataFrame(columns=["project_id", "title", "area", "category", "target", "result", "duration", "comment_all", "comment_user", "comment_provider", "money_supporter", "sign_supporter"]) project_money_all = pd.DataFrame() for page in range(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: 2. wadiz_df Data 정리 Step2: 3. Project_money Data 처리 Step3: 4. Project_money_all, Wadiz_df 합치기 Step4: 5. Data 추가 Step5: 5. Comment Crawling S...
11,376
<ASSISTANT_TASK:> Python Code: import json import numpy as np import pandas as pd import matplotlib as mpl import matplotlib.pyplot as plt import seaborn as sns sns.set_style('darkgrid') %matplotlib inline loans = pd.read_csv("lending-club-data_assign_2.csv") # safe_loans = 1 => safe # safe_loans = -1 => risky loans...
<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 LendingClub Loans dataset Step2: The target column (label column) of the dataset that we are interested in is called bad_loans. In this co...
11,377
<ASSISTANT_TASK:> Python Code: # Load library import cv2 import numpy as np from matplotlib import pyplot as plt # Load image as grayscale image = cv2.imread('images/plane.jpg', cv2.IMREAD_GRAYSCALE) # Show image plt.imshow(image, cmap='gray'), plt.axis("off") plt.show() # Save image cv2.imwrite('images/plane_new.jpg...
<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 Image As Greyscale Step2: Save Image
11,378
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'miroc', 'sandbox-3', 'landice') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "e...
<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...
11,379
<ASSISTANT_TASK:> Python Code: # print("\x1b[30;1m\"red\"\x1b[0m") # print("\x1b[31;1m\"red\"\x1b[0m") # print("\x1b[32;1m\"red\"\x1b[0m") # print("\x1b[33;1m\"red\"\x1b[0m") # print("\x1b[34;1m\"red\"\x1b[0m") # print("\x1b[35;1m\"red\"\x1b[0m") # print("\x1b[36;1m\"red\"\x1b[0m") # print("\x1b[37;1m\"red\"\x1b[0m") #...
<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: Insults package Step2: Identifying quotation marks Step3: We need to clean up the open and closed inverted commas with straight ones. Step4: ...
11,380
<ASSISTANT_TASK:> Python Code: # Author: Denis A. Engemann <denis.engemann@gmail.com> # Victoria Peterson <victoriapeterson09@gmail.com> # License: BSD-3-Clause import matplotlib.pyplot as plt import mne from mne import Epochs from mne.datasets.fieldtrip_cmc import data_path from mne.decoding import SSD fname ...
<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 parameters Step2: Let's investigate spatial filter with max power ratio. Step3: Let's also look at the power spectrum of that source an...
11,381
<ASSISTANT_TASK:> Python Code: # Author: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr> # # License: BSD (3-clause) # sphinx_gallery_thumbnail_number = 3 import matplotlib.pyplot as plt import numpy as np import mne from mne.datasets import sample from mne.beamformer import make_lcmv, apply_lcmv print(__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: Get epochs Step2: Run beamformers and look at maximum outputs Step3: We can also look at the spatial distribution
11,382
<ASSISTANT_TASK:> Python Code: # Authors: Denis Engemann <denis.engemann@gmail.com> # # License: BSD (3-clause) import mne from mne.preprocessing import ICA, create_ecg_epochs from mne.datasets import sample print(__doc__) data_path = sample.data_path() raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw....
<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: Fit ICA model using the FastICA algorithm, detect and inspect components
11,383
<ASSISTANT_TASK:> Python Code: import h2o # Start an H2O Cluster on your local machine h2o.init() # This will not actually do anything since it's a fake IP address # h2o.init(ip="123.45.67.89", port=54321) #csv_url = "http://www.stat.berkeley.edu/~ledell/data/eeg_eyestate_splits.csv" csv_url = "https://h2o-public-tes...
<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 already have an H2O cluster running that you'd like to connect to (for example, in a multi-node Hadoop environment), then you can specify...
11,384
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import seaborn as sns import openmc import openmc.mgxs as mgxs from openmc.source import Source from openmc.stats import Box import openmoc from openmoc.compatible import get_openmoc_geometry import pyne.ace %matplotlib inline # Instanti...
<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 need to define materials that will be used in the problem. Before defining a material, we must create nuclides that are used in the mat...
11,385
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline sns.set_style('darkgrid') sns.set_context('talk') def errorbarjitter(df, groupByCol, statsCol, fig=None, xlab='group', ylab='units', rotate = 0): grouped = df.groupby([grou...
<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: errorbarjitter function Step2: Example 1 Step3: Iris dataset example Step4: References Step5: Learning Index
11,386
<ASSISTANT_TASK:> Python Code: from beakerx import * f = EasyForm("Form and Run") f.addTextField("first") f.addTextField("last") f['first'] = "First" f['last'] = "Last" f.addButton("Go!", tag="run") f "Good morning " + f["first"] + " " + f["last"] f['last'][::-1] + '...' + f['first'] f['first'] = 'Beaker' f['last'] = '...
<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: Default Values and placeholder Step2: JupyterJSWidgets work with EasyForm
11,387
<ASSISTANT_TASK:> Python Code: import requests import string import random lorem = requests.get('http://loripsum.net/api/plaintext').text WORDS = [word.lower() for word in filter(lambda c: c not in string.punctuation, lorem).split()] def random_words(n=2): return '_'.join(random.choice(WORDS) for i in ran...
<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 Provenance in Adama Step2: Connect the adama Python object to your API server of choice. The official one is https Step3: Create a rand...
11,388
<ASSISTANT_TASK:> Python Code: !pip install -q tf-models-official import tensorflow as tf import tensorflow_hub as hub tfhub_handle_encoder = 'https://tfhub.dev/tensorflow/bert_en_uncased_L-12_H-768_A-12/3' bert_saved_model_path = 'bert_base' bert_model = hub.load(tfhub_handle_encoder) tf.saved_model.save(bert_model, 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: 2. Inference Step2: 2.1 Helper functions Step3: 2.2 Convert the model with TF-TRT Step4: 2.3 Run inference with converted model Step5: Compa...
11,389
<ASSISTANT_TASK:> Python Code: cisla = [(1, 1), (2, 4), (3, 9), (4, 16), (5, 25), (6,36), (7, 49), (8, 64), (9, 81), (10, 100)] mocniny = dict(cisla) print(mocniny) import random while True: odpoved = input('Na kolik odpovědí chceš hrát? ') try: odpoved = int(odpoved) break except ValueErro...
<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: Skautská hra Step2: Řešení bez slovníků, ale hlavně takové, kde by nebylo úplně snadné přidat další otázky. Step3: Řešení, kde přidání, změna ...
11,390
<ASSISTANT_TASK:> Python Code: import numpy as np import tensorflow as tf import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline def calc_diff_err_p1(n): h = 2.*np.pi/n x = tf.range(1., n+1.)[:, None]*h - np.pi u = tf.exp(tf.sin(x)) u_prime = tf.cos(x) * u e = tf.cast(tf.ones(tf.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: Program 1 Step2: Program 2
11,391
<ASSISTANT_TASK:> Python Code: writer = pytablewriter.LatexMatrixWriter() writer.table_name = "B" writer.value_matrix = [ ["a_{11}", "a_{12}", "\\ldots", "a_{1n}"], ["a_{21}", "a_{22}", "\\ldots", "a_{2n}"], [r"\vdots", "\\vdots", "\\ddots", "\\vdots"], ["a_{n1}", "a_{n2}", "\\ldots", "a_{nn}"], ] write...
<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: \begin{equation} Step4: \begin{array}{r | r | l | l | l | l} \hline
11,392
<ASSISTANT_TASK:> Python Code: from __future__ import absolute_import, division, print_function import os import numpy as np import pandas as pd %matplotlib inline import matplotlib.pyplot as plt import seaborn as sns sns.set() # Import from monitor from desc.monitor import RefLightCurves import desc.monitor as monitor...
<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: Observations Step2: Obtaining the parameters from the database Step3: The RefLightCurves Class Step4: Find the number of objects in the table...
11,393
<ASSISTANT_TASK:> Python Code: from bigbang.archive import Archive import matplotlib.pyplot as plt import numpy as np import pandas as pd url = "ipython-user" arx = Archive(url) fernandos = Archive(arx.data[arx.data.From.map(lambda x: 'Fernando' in x)]) fernandos.data[:3] [x for x in fernandos.get_activity()] not_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: Let's get all the available date from the IPython community. For now, this is just the mailing lists. One day, BigBang will also get its issue t...
11,394
<ASSISTANT_TASK:> Python Code: # The usual imports %pylab inline from ipywidgets import * # Some extra imports for 3D from mpl_toolkits.mplot3d import * # These are only needed to make things pretty.. # they are mostly refered to in the formatting part of the figures # and enshure us to have the figures also present ...
<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 control freak sequence Step2: Below we write a generic function that takes the functions $u(t)$,$v(t)$ and $w(t)$ as an argument and then v...
11,395
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pickle as pkl import numpy as np import tensorflow as tf import matplotlib.pyplot as plt from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets('MNIST_data') def model_inputs(real_dim, z_dim): inputs_real = tf.placeholde...
<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 Inputs Step2: Generator network Step3: Discriminator Step4: Hyperparameters Step5: Build network Step6: Discriminator and Generator L...
11,396
<ASSISTANT_TASK:> Python Code: from jyquickhelper import add_notebook_menu add_notebook_menu() import os os.stat("c:/temp/fr.openfoodfacts.org.products.csv").st_size / 2**30, 'Go' import pyensae %load_ext pyensae %head -n 2 c:/temp/fr.openfoodfacts.org.products.csv import pandas df = pandas.read_csv("c:/temp/fr.openf...
<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 quoi ça ressemble Step2: C'est gros. Step3: Idée de la compétation Step4: Le code qui suit est construit après plusieurs essais en fonction...
11,397
<ASSISTANT_TASK:> Python Code: import random import numpy as np import tensorflow as tf import matplotlib.pyplot as plt import csv import scipy.misc import time import collections import os import utils as ut import importlib import copy importlib.reload(ut) # This is a bit of magic to make matplotlib figures appear 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: Load the data from *.csv file Step2: Explore the correct data Step3: Prepare the Data for CNN Step4: Prepare the data for CNN Step5: Model 1...
11,398
<ASSISTANT_TASK:> Python Code: # Show matplotlib plots inline (nicely formatted in the notebook) %matplotlib inline # Import libraries necessary for this project import numpy as np import pandas as pd import renders as rs import seaborn as sns from matplotlib import pylab as plt from IPython.display import display # ...
<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 Exploration Step2: Implementation Step3: Question 1 Step4: Answer Step5: The heatmap above shows the percentile ranks of samples' categ...
11,399
<ASSISTANT_TASK:> Python Code: from collections import OrderedDict INPUT_PATH = "gauss/" (MIN_PREFIX, MAX_PREFIX) = ("C015", "C055") # for instance filenames OUTPUT_PATH = "plots/" WINDOW = 150 # size of the subsets of instances used as a moving window SOLVER_NAMES = OrderedDict([ ("GeneticGroup", "Grouping GA"), ...
<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: Tools Step2: Reading the instances Step3: Statistical difficulty and average multiplicity Step4: The dispersion of the pagination sizes could...