Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
4,100
<ASSISTANT_TASK:> Python Code: import sqlite3 import pandas as pd import numpy as np %matplotlib inline import matplotlib import numpy as np import matplotlib.pyplot as plt import CGATPipelines.Pipeline as P import os import statistics import collections #load R and the R packages required %load_ext rpy2.ipython %R req...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: This is where we are and when the notebook was run Step2: First lets set the output path for where we want our plots to be saved and the databa...
4,101
<ASSISTANT_TASK:> Python Code:: import cv2 import numpy as np %matplotlib notebook %matplotlib inline from matplotlib import pyplot as plt img = cv2.imread("HappyFish.jpg",cv2.IMREAD_GRAYSCALE) _,mask = cv2.threshold(img, 220,255,cv2.THRESH_BINARY_INV) kernal = np.ones((5,5),np.uint8) dilation = cv2.dilate(mask,kernal,...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
4,102
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 %matplotlib inline from __future__ import print_function import matplotlib.pyplot as plt import numpy as np import sklearn from sklearn.cluster import KMeans from dsnmf import DSNMF, appr_seminmf from scipy.io import loadmat mat = loadmat('PIE_pose27.mat...
<SYSTEM_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 order to evaluate the different features we will use a simple k-means clustering with the only assumption of knowing the true number of clas...
4,103
<ASSISTANT_TASK:> Python Code: # To let ray install its own version in Colab !pip uninstall -y pyarrow # You might need to restart the Colab runtime !pip install --upgrade "thinc>=8.0.0a0" "ml_datasets>=0.2.0a0" ray psutil setproctitle import thinc from thinc.api import chain, Relu, Softmax @thinc.registry.layers("rel...
<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: Let's start with a simple model and config file. You can edit the CONFIG string within the file, or copy it out to a separate file and use Confi...
4,104
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import matplotlib import pickle import pandas as pd import numpy as np from IPython.display import display %matplotlib notebook enron_data = pickle.load(open("./ud120-projects/final_project/final_project_dataset.pkl", "rb")) print("Number of people: %d"%le...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: But working with this set of dictionaries would not be nearly as fast or easy as a Pandas dataframe, so I soon converted it to that and went ahe...
4,105
<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: Standalone Model Card Toolkit Demo Step2: Did you restart the runtime? Step3: Model Step4: Dataset Step5: Use the Model Card Toolkit Step6: ...
4,106
<ASSISTANT_TASK:> Python Code: df.plot.line('Time' , ['Sig1', 'Sig2', 'Sig3'], color=['c' , 'm' , 'y']) df.plot.line('Time' , ['Sig1', 'Sig2', 'Sig3'], color=['#800000' , '#008000' , '#000080']) df.plot.line('Time' , ['Sig1', 'Sig2', 'Sig3'], color=['r' , 'g' , 'b']) <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: pre-defined colors
4,107
<ASSISTANT_TASK:> Python Code: # click on this cell and press Shift+Enter import packages.initialization import pioneer3dx as p3dx p3dx.init() # Move forward p3dx.move(2.5,2.5) p3dx.sleep(1) p3dx.stop() # Move backward p3dx.move(-2.5,-2.5) p3dx.sleep(1) p3dx.stop() # Turn left p3dx.move(-2.5,2.5) p3dx.sleep(1) p3dx.st...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Functions Step2: You can also copy and paste the functions several times with different values for a composition of motions
4,108
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pylab as plt N = 100 T = 100 a = 0.9 xm = 0.9 sP = np.sqrt(0.001) sR = np.sqrt(0.01) x1 = np.zeros(N) x2 = np.zeros(N) y = np.zeros(N) for i in range(N): if i==0: x1[0] = xm x2[0] = 0 else: x1[i] = xm ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Stochastic Kinetic Model Step2: State Space Representation Step3: In this model, the state space can be visualized as a 2-D lattice of nonnega...
4,109
<ASSISTANT_TASK:> Python Code: class Heap: sNodeCount = 0 def __init__(self): Heap.sNodeCount += 1 self.mID = str(Heap.sNodeCount) def getID(self): return self.mID # used only by graphviz def _make_string(self, attributes): # get the name of the class of the o...
<SYSTEM_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 function make_string is a helper function that is used to simplify the implementation of the method __str__. Step2: Graphical Representatio...
4,110
<ASSISTANT_TASK:> Python Code: import tensorflow as tf import numpy as np import scipy import matplotlib.pyplot as plt %matplotlib inline import time from urllib.request import urlopen # Python 3+ version (instead of urllib2) CLASS_DIR='./images/cars' #CLASS_DIR='./images/seefood' # for HotDog vs NotHotDog import os...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Add TensorFlow Slim Model Zoo to path Step2: The Inception v1 (GoogLeNet) Architecture| Step3: Build the model and select layers we need - the...
4,111
<ASSISTANT_TASK:> Python Code: primzweibissieben = [2, 3, 5, 7] for prime in primzweibissieben: print(prime) for x in range(5): print(x) for x in range(3, 6): print(x) numbers = [ 951, 402, 984, 651, 360, 69, 408, 319, 601, 485, 980, 507, 725, 547, 544, 615, 83, 165, 141, 501, 263, 617, 865, 575, ...
<SYSTEM_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.Drucke alle die Zahlen von 0 bis 4 aus Step2: 4.Baue einen For-Loop, indem Du alle geraden Zahlen ausdruckst, die tiefer sind als 237. Step3:...
4,112
<ASSISTANT_TASK:> Python Code: import peforth %f version .s %f ." Hello World!" cr # use %f line magic in a python code function definition, def hi(): %f ." Hello World!" cr # believe it or not, it works! hi() %f __main__ :> hi .source %%f Nothing allowed before %%f except white spaces; everything in this line ...
<SYSTEM_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. Hello World! Step2: The amazing thing here is that the %f line magic can be used in python code. . . Step3: 3. line magic is compiled to a ...
4,113
<ASSISTANT_TASK:> Python Code: import time import numpy as np import tensorflow as tf import utils from urllib.request import urlretrieve from os.path import isfile, isdir from tqdm import tqdm import zipfile dataset_folder_path = 'data' dataset_filename = 'text8.zip' dataset_name = 'Text8 Dataset' class DLProgress(tq...
<SYSTEM_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 text8 dataset, a file of cleaned up Wikipedia articles from Matt Mahoney. The next cell will download the data set to the data folder. ...
4,114
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib import pyplot as plt import numpy as np from IPython.html.widgets import interact def char_probs(s): Find the probabilities of the unique characters in the string s. Parameters ---------- s : str A string of characters. ...
<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: Character counting and entropy Step4: The entropy is a quantiative measure of the disorder of a probability distribution. It is used extensivel...
4,115
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl import matplotlib.image as mpimg # Widgets library from ipywidgets import interact %matplotlib inline # We need to load all the files here # Load the file folder = '../results/' name = 'parameter_swep_SLM-0.00-0.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: Now we need to build a function that takes distance, base and value as a parameter and returns the the SLE, STDM, Visualize Cluster Matrix. Step...
4,116
<ASSISTANT_TASK:> Python Code: import pandas as pd # data package import matplotlib.pyplot as plt # graphics import datetime as dt # date tools, used to note current date import requests from bs4 import BeautifulSoup import urllib.request from matplotlib.offsetbox import OffsetImage %matplotli...
<SYSTEM_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 we have displayed the most basic statistics for each of the MVP canidates, such as points, assists, steals and rebounds a game. As we can s...
4,117
<ASSISTANT_TASK:> Python Code: from __future__ import division import tensorflow as tf from os import path import numpy as np import pandas as pd import csv from sklearn.model_selection import StratifiedShuffleSplit from time import time from matplotlib import pyplot as plt import seaborn as sns from mylibs.jupyter_not...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Step 0 - hyperparams Step2: Step 1 - collect data (and/or generate them) Step3: Step 2 - Build model Step4: Step 3 training the network Step5...
4,118
<ASSISTANT_TASK:> Python Code: %matplotlib inline import re import numpy as np import pandas as pd import matplotlib.pyplot as plt import nltk from nltk.corpus import stopwords from nltk.tokenize import regexp_tokenize from nltk.stem.porter import PorterStemmer from sklearn import cross_validation from sklearn.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: Step9: Functions Step10: Data Step11: Clean Step12: Features Step13: Split the training data Step14: tfidf Step15: Combine Step16: Training Step...
4,119
<ASSISTANT_TASK:> Python Code: import os,sys import radical.pilot as rp import ast os.environ["RADICAL_PILOT_DBURL"]="mongodb://ec2-54-221-194-147.compute-1.amazonaws.com:24242/sc15tut" os.environ["RADICAL_PILOT_VERBOSE"]="DEBUG" def print_details(detail_object): if type(detail_object)==str: detail_object =...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 3. Create a Radical Pilot Session Step2: 4. Create Pilot and Unit Managers Step3: 5. Submit the pilot to the Pilot and Unit Managers Step4: 6...
4,120
<ASSISTANT_TASK:> Python Code: from bokeh.plotting import figure, output_file, show, output_notebook, vplot import random import numpy as np import pandas as pd output_notebook() # Use so see output in the Jupyter notebook import bokeh bokeh.__version__ from IPython.display import Image Image(filename='biological_dat...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Objectives Steps Step2: Desired visualization Step 1 Step3: Step 1a Step4: What colors are possible to use? Check out bokeh.palettes Step5: ...
4,121
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'bnu', 'sandbox-2', 'landice') # 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: 1...
4,122
<ASSISTANT_TASK:> Python Code: def sort_third(l: list): l = list(l) l[::3] = sorted(l[::3]) return l <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:
4,123
<ASSISTANT_TASK:> Python Code: from jupyterthemes.stylefx import set_nb_theme set_nb_theme('grade3') import os PREFIX = os.environ.get('PWD', '.') # PREFIX = "../build/outputs" import numpy import pandas import plotly.graph_objs as go import plotly.figure_factory as ff from plotly.offline import init_notebook_mode, ipl...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Inputs Step2: Metabolism Step3: Plotting concentrations of compounds. Step4: Plotting time series of compound concentrations.
4,124
<ASSISTANT_TASK:> Python Code: import sys sys.path.append('/home/jbourbeau/cr-composition') print('Added to PYTHONPATH') from __future__ import division, print_function from collections import defaultdict import numpy as np import pandas as pd import matplotlib.pyplot as plt from matplotlib.colors import ListedColormap...
<SYSTEM_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: Validation curves Step3: Max features Step4: Minimum samples in leaf node Step5: KS-test tuning Step6: Minimum sa...
4,125
<ASSISTANT_TASK:> Python Code: import tushare as ts import pandas as pd stock_selected='600699' df1, data1 = ts.top10_holders(code=stock_selected, gdtype='1') df1 = df1.sort_values('quarter', ascending=True) df1.tail(10) #qts = list(df1['quarter']) #data = list(df1['props']) #name = ts.get_realtime_quotes(stock_select...
<SYSTEM_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、Top 10 share holder Step2: 获取沪深上市公司基本情况。属性包括: Step3: 业绩报告(主表) Step4: 盈利能力 Step5: 营运能力 Step6: 成长能力 Step7: 偿债能力 Step11: 3、CandleStick
4,126
<ASSISTANT_TASK:> Python Code: import os import numpy as np import pandas as pd import mne kiloword_data_folder = mne.datasets.kiloword.data_path() kiloword_data_file = os.path.join(kiloword_data_folder, 'kword_metadata-epo.fif') epochs = mne.read_epochs(kiloword_data_file) epochs.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: Viewing Epochs metadata Step2: Viewing the metadata values for a given epoch and metadata variable is done Step3: Modifying the metadata Step4...
4,127
<ASSISTANT_TASK:> Python Code: import os import re import datetime import getpass import numpy as np import pandas as pd import altair as alt import difflib from timesketch_api_client import client as timesketch_client #!pip install vega from datasketch.minhash import MinHash from six.moves import urllib_parse as ur...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Caveat Step2: Second import statement (only run if you are not using jupyterlab) Step3: Read the Data Step4: The file itself is really large ...
4,128
<ASSISTANT_TASK:> Python Code: # 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 writing, sof...
<SYSTEM_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 Project
4,129
<ASSISTANT_TASK:> Python Code: import brfss import numpy as np %matplotlib inline df = brfss.ReadBrfss(nrows=None) df = df.dropna(subset=['htm3', 'wtkg2']) heights, weights = df.htm3, df.wtkg2 weights = np.log10(weights) import thinkstats2 inter, slope = thinkstats2.LeastSquares(heights, weights) inter, slope 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: 절편과 기울기를 추정한다. Step2: 데이터에 대한 산점도와 적합선을 보여준다. Step3: 동일한 도식화를 하지만, 역변환을 적용해서 선형(log 아님) 척도로 체중을 나타낸다. Step4: 잔차 백분위수를 도식화한다. Step5: 상관을 계산한다...
4,130
<ASSISTANT_TASK:> Python Code: 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.keras.layers import Dense, Flatten, Softmax 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: 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...
4,131
<ASSISTANT_TASK:> Python Code: def reverse_delete(s,c): s = ''.join([char for char in s if char not in c]) return (s,s[::-1] == s) <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:
4,132
<ASSISTANT_TASK:> Python Code: import pandas as pd from astropy.io import fits import numpy as np from desc.sims.GCRCatSimInterface import InstanceCatalogWriter from lsst.sims.utils import SpecMap import matplotlib.pyplot as plt from lsst.utils import getPackageDir from lsst.sims.photUtils import Sed, BandpassDict, Ban...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Make the AGN catalogs Step2: Next we add in the lens properties to go with each of the images. Step3: Make the SNe catalogs Step4: Next we ad...
4,133
<ASSISTANT_TASK:> Python Code: # Example from section 29.4 & 29.6 (Fig 29.14 & 29.15) of https://www.inference.org.uk/itprnn/book.pdf try: import probml_utils as pml except ModuleNotFoundError: %pip install -qq git+https://github.com/probml/probml-utils.git import probml_utils as pml import matplotlib.pyplo...
<SYSTEM_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 genereate samples from following distribution Step2: $x_0 = 10$ Step3: $x_0 = 17$
4,134
<ASSISTANT_TASK:> Python Code: import numpy as np import seaborn as sns import pandas as pd from statsmodels.graphics.tsaplots import plot_acf import scipy.stats import matplotlib.pyplot as plt from IPython.display import HTML, display from io import BytesIO from base64 import b64encode import scipy.misc as smp from mp...
<SYSTEM_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, define some useful functions. These are used in the printing of data later on. Also used for rendering images to the HTML page. Step2: Q...
4,135
<ASSISTANT_TASK:> Python Code: from ipywidgets import Button, Layout b = Button(description='(50% width, 80px height) button', layout=Layout(width='50%', height='80px')) b Button(description='Another button with the same layout', layout=b.layout) from ipywidgets import IntSlider IntSlider(description='A 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: The layout property can be shared between multiple widgets and assigned directly. Step2: Description Step3: You can change the length of the d...
4,136
<ASSISTANT_TASK:> Python Code: def root_tree_at(new_root): Given a node, remove all parents and add as children so that this node becomes the new root # Check to see if the new root has any parents... parents = new_root.xpath("..") if len(parents) > 0: p = root_tree_at(parents[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: Step 1 Step2: 2. Flatten tree Step3: 3. Use regexp path queries over tree!
4,137
<ASSISTANT_TASK:> Python Code: import numpy as np np.random.seed(777) from skopt import gp_minimize from skopt import callbacks from skopt.callbacks import CheckpointSaver noise_level = 0.1 def obj_fun(x, noise_level=noise_level): return np.sin(5 * x[0]) * (1 - np.tanh(x[0] ** 2)) + np.random.randn() * noise_level...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Problem statement Step2: Now let's assume this did not finish at once but took some long time Step3: Continue the search
4,138
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'cams', 'sandbox-2', 'ocean') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "emai...
<SYSTEM_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...
4,139
<ASSISTANT_TASK:> Python Code: import tensorflow as tf # We don't really need to import TensorFlow here since it's handled by Keras, # but we do it in order to output the version we are using. tf.__version__ import os.path from IPython.display import Image from util import Util u = Util() import numpy as np # Explic...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We are using TensorFlow-GPU 0.12.1 on Python 3.5.2, running on Windows 10 with Cuda 8.0. Step2: Definitions Step3: Data load Step4: Model de...
4,140
<ASSISTANT_TASK:> Python Code: def func(D, l, b, dD, dl, db): q = 0.63 alpha = 2.42 rho0 = 5.6 / u.kpc**3 Rsun = 8. * u.kpc x = D*np.cos(l)*np.cos(b) - Rsun y = D*np.sin(l)*np.cos(b) z = D*np.sin(b) / q r = np.sqrt(x**2 + y**2 + z**2) return D**2 * rho0 * (Rsun / r)**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: From mathematica
4,141
<ASSISTANT_TASK:> Python Code: !pip install activitysim !activitysim create -e example_mtc -d example %cd example !activitysim run -c configs -d data -o output import os for root, dirs, files in os.walk(".", topdown=False): for name in files: print(os.path.join(root, name)) for name in dirs: print(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Creating an Example Setup Step2: Run the Example Step3: Inputs and Outputs Overview Step4: Inputs Step5: Outputs Step6: Other notable outpu...
4,142
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt from sklearn.datasets import make_multilabel_classification from sklearn.multiclass import OneVsRestClassifier from sklearn.svm import SVC from sklearn.preprocessing import LabelBinarizer from sklearn.decomposition 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: Play with Multilabel classification format and f1-score
4,143
<ASSISTANT_TASK:> Python Code: import cobra from utils import findBiomarkers, show_map import pandas as pd from IPython.core.interactiveshell import InteractiveShell InteractiveShell.ast_node_interactivity = "all" model = cobra.io.read_sbml_model("models/Shlomi_example.xml") # write a for loop here. # tip: make use o...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <span style="color Step2: Reproducing Figure 1B
4,144
<ASSISTANT_TASK:> Python Code: # special IPython command to prepare the notebook for matplotlib and other libraries %matplotlib inline import numpy as np import pandas as pd import scipy.stats as stats import matplotlib.pyplot as plt import sklearn import seaborn as sns # special matplotlib argument for improved plots...
<SYSTEM_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 2 Step2: Now let's explore the data set itself. Step3: There are no column names in the DataFrame. Let's add those. Step4: Now we have a...
4,145
<ASSISTANT_TASK:> Python Code: # Import library import re # Create text text_data = ['Interrobang. By Aishwarya Henriette', 'Parking And Going. By Karl Gautier', 'Today Is The night. By Jarek Prakash'] # Remove periods remove_periods = [string.replace('.', '') for string in text_data] # Show...
<SYSTEM_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 Text Step2: Replace Character (Method 1) Step3: Replace Character (Method 2)
4,146
<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: Load NumPy data Step2: Load from .npz file Step3: Load NumPy arrays with tf.data.Dataset Step4: Use the datasets Step5: Build and train a mo...
4,147
<ASSISTANT_TASK:> Python Code: def countSetBits(n ) : i = 0 ans = 0 while(( 1 << i ) <= n ) : k = 0 change = 1 << i for j in range(0 , n + 1 ) : ans += k if change == 1 : k = not k change = 1 << i  else : change -= 1   i += 1  return ans  if __name__== "__main __": n = 17 pr...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
4,148
<ASSISTANT_TASK:> Python Code: numeros = [1, 2, 3, 4] numeros len(numeros) # a função len funciona para todas as sequências numeros + [5, 6, 7, 8] numeros numeros += [5, 6, 7, 8] numeros numeros numeros.append(9) numeros aninhada = [1, 2, 3, [4, 5, 6]] aninhada aninhada[3] aninhada[3][2] zeros = [0] * 10 zeros [...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Tamanho da lista Step2: Concatenando listas Step3: Para modificar a lista é necessário usar += Step4: Para anexar elementos no final da lista...
4,149
<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: Convolutional Variational Autoencoder Step2: Load the MNIST dataset Step3: Use tf.data to batch and shuffle the data Step5: Define the encode...
4,150
<ASSISTANT_TASK:> Python Code: # Imports import numpy as np import keras from keras.datasets import imdb from keras.models import Sequential from keras.layers import Dense, Dropout, Activation from keras.preprocessing.text import Tokenizer import matplotlib.pyplot as plt %matplotlib inline np.random.seed(42) # Loading...
<SYSTEM_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. 加载数据 Step2: 2. 检查数据 Step3: 3. 输出的 One-hot 编码 Step4: 同时我们将对输出进行 one-hot 编码。 Step5: 4. 模型构建 Step6: 5. 训练模型 Step7: 6. 评估模型
4,151
<ASSISTANT_TASK:> Python Code: %config InlineBackend.figure_format = 'retina' import matplotlib.pyplot as plt import numpy as np from uncertainties import unumpy as unp import pytheos as eos eta = np.linspace(0., 0.225, 46) print(eta) jamieson_aul = eos.gold.Jamieson1982L() jamieson_auh = eos.gold.Jamieson1982H() jam...
<SYSTEM_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. General note Step2: 3. Compare Step3: <img src='./tables/Jamieson_Au_1.png'>
4,152
<ASSISTANT_TASK:> Python Code: # import cluster_pgm # cluster_pgm.inverse() from IPython.display import Image Image(filename="cluster_pgm_inverse.png") %load_ext autoreload %autoreload 2 import cluster lets = cluster.XrayData() lets.read_in_data() lets.set_up_maps() x0,y0 = 328,328 # The center of the image is 328,...
<SYSTEM_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 PGM illustrates the joint PDF for the parameters and the data, which can be factorised as Step2: Good. Here's the code that is being run, ...
4,153
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mohc', 'hadgem3-gc31-mh', 'seaice') # 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...
4,154
<ASSISTANT_TASK:> Python Code: import sys import h2o from h2o.frame import H2OFrame import numpy as np import pandas as pd h2o.init(strict_version_check=False) N = 1000 cont = 0.05 # ratio of outliers/anomalies regular_data = np.random.normal(0, 0.5, (int(N*(1-cont)), 2)) anomaly_data = np.column_stack((np.random.norm...
<SYSTEM_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 synthetic data Step2: Train Isolation Forest with a validation set Step3: The trained model will have different kind of metrics ...
4,155
<ASSISTANT_TASK:> Python Code: path = untar_data(URLs.LSUN_BEDROOMS) dblock = DataBlock(blocks = (TransformBlock, ImageBlock), get_x = generate_noise, get_items = get_image_files, splitter = IndexSplitter([])) def get_dls(bs, size): dblock = DataBlock(blocks...
<SYSTEM_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 then grab all the images in the folder with the data block API. We don't create a validation set here for reasons we'll explain later. It con...
4,156
<ASSISTANT_TASK:> Python Code: # n numero entero def f(n): l = [] for i in range(len(str(n))-1,-1,-1): x = n/(10**i) l.append(x) n=n %(10**i) return l f(421) # Cargando los datos clientes = [('Don Ramon', 3500, (9, 4, 2014)), ('Miguel', 2785, (30,10, 2014)), ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Solución Step2: Pregunta 2.b Step3: Pregunta 2.c Step4: Pregunta 3 [40%] Step5: Pregunta 3.a Step6: Pregunta 3.b Step7: Pregunta 3.c
4,157
<ASSISTANT_TASK:> Python Code: # For reading data files import os import glob import numpy as np # Numeric calculation import pandas as pd # General purpose data analysis library import squeak # For mouse data # For plotting import matplotlib.pyplot as plt %matplotlib inline # Prettier default settings for plots (opt...
<SYSTEM_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 load our data. Step2: A faster and more concise alternative, using python's list comprehension abilities, would look like thi...
4,158
<ASSISTANT_TASK:> Python Code: from urllib.request import urlopen r = urlopen('http://www.python.org/') data = r.read() print("Status code:", r.getcode()) import requests r = requests.get("http://www.python.org/") data = r.text print("Status code:", r.status_code) import requests r = requests.get("http://api.open-not...
<SYSTEM_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 variable data contains returned HTML code (full page) as string. You can process it, save it, or do anything else you need. Step2: Get JSON...
4,159
<ASSISTANT_TASK:> Python Code: %matplotlib inline from jyquickhelper import add_notebook_menu add_notebook_menu() def compose(x, a, n): return (a * x) % n def crypt(x): return compose(x, 577, 10000) crypt(5), crypt(6) crypt(5+6), (crypt(5) + crypt(6)) % 10000 crypt(6-5), (crypt(6) - crypt(5)) % 10000 crypt(5-6...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Principe Step2: Si $a=47$, on cherche $a',k$ tel que $aa' - nk=1$. Step3: Notes sur l'inverse de a Step4: On considère seulement la fonction ...
4,160
<ASSISTANT_TASK:> Python Code: def get_status(dt, category=None): returns road status given specific datetime if category: return db.session.query(RoadStatus).filter(RoadStatus.timestamp > dt.strftime('%s')).\ filter(RoadStatus.timestamp < (dt+timedelta(0,60)).strftime('%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: Step2: Data validation Step3: Exploratory Data Analysis Step4: SegmentStatus dataframe Step5: It's likely that there is a sort of "snake effect" in ...
4,161
<ASSISTANT_TASK:> Python Code: numlist = [1, 2, 3, 4, 5] for item in numlist: print(item) print('All done!') sublist = ['a', 'b', 'c'] for item in numlist: for subitem in sublist: print(item, subitem) print('All done!') for num in range(1, 11): print(num) for num in range(2, 11, 2): print(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: You probably can figure out what's going on here Step2: Ranges Step3: You can specify an optional third step value if you want to skip over va...
4,162
<ASSISTANT_TASK:> Python Code: import numpy as np from qutip import * import matplotlib.pyplot as plt %matplotlib inline from IPython.display import Image one, two, three = three_level_basis() sig11 = one * one.dag() sig22 = two * two.dag() sig33 = three * three.dag() sig13 = one * three.dag() sig23 = two * three.dag(...
<SYSTEM_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 define the $\hat{\sigma}_{ij}$ operators according to atomic levels shown in the following figure. Decay rates are also indicated.
4,163
<ASSISTANT_TASK:> Python Code: p1000_set1_files = [ "sog_ff_cal_img_2017.1207.083225.fits", "sog_ff_cal_img_2017.1207.083329.fits", "sog_ff_cal_img_2017.1207.083411.fits" ] m1000_set1_files = [ "sog_ff_cal_img_2017.1207.083508.fits", "sog_ff_cal_img_2017.1207.083545.fits", "sog_ff_cal_img_2017.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: Note Step2: -15" of CC_Y went to +15" of CC_X; +10" of CC_X went to -10" of CC_Y
4,164
<ASSISTANT_TASK:> Python Code: import pandas as pd from google.cloud import bigquery bq = bigquery.Client() QUERY_TEMPLATE = SELECT timestamp, inputs.input_pubkey_base58 AS input_key, outputs.output_pubkey_base58 AS output_key, outputs.output_satoshis as satoshis FROM `bigquery-public-data.bitcoin_bloc...
<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: 10,000 bitcoin network Step3: Post-processing the data pulled from BigQuery Step4: Visualizing the network Step5: We use the library networkx...
4,165
<ASSISTANT_TASK:> Python Code: # Import libraries: NumPy, pandas, matplotlib import numpy as np import pandas as pd import matplotlib.pyplot as plt # Tell iPython to include plots inline in the notebook %matplotlib inline # read .csv from provided dataset csv_filename="Wholesale customers data.csv" # df=pd.read_csv(csv...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Feature Transformation Step2: The explained variance is high for the first two dimensions (45.96 % and 40.52 %, respectively), but drops signif...
4,166
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt from ipywidgets import interact, fixed def idealSolution(GA, GB, XB, temperature): Computes the free energy of solution for an ideal binary mixture. Parameters ---------- GA : float The...
<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: Lecture 23 Step4: Correcting the Ideal Solution for Local Chemical Effects Step6: A Small Simplification Step8: Beyond the Bulk Step9: The F...
4,167
<ASSISTANT_TASK:> Python Code: from __future__ import print_function # Some magic to make plots appear within the notebook %matplotlib inline import numpy as np # In case we need to use numpy from pymt import plugins model = plugins.Child() help(model) rm -rf _model # Clean up for the next step config_file, initdir ...
<SYSTEM_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 CHILD in PyMT Step2: You can now see the help information for Child. This time, have a look under the Parameters section (you may have to s...
4,168
<ASSISTANT_TASK:> Python Code: #Physical Constants (SI units) G=6.67e-11 AU=1.5e11 #meters. Distance between sun and earth. daysec=24.0*60*60 #seconds in a day #####run specfic constants. Change as needed##### #Masses in kg Ma=6.0e24 #always set as smaller mass Mb=2.0e30 #always set as larger mass #Time settings t=0.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: Next, we will need parameters for the simulation. These are known as intial condititons. For a 2 body gravitation problem, we'll need to know th...
4,169
<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, unit_impulse from matplotlib import pyplot as plt import mne from mne.simulation import simulate_raw, add_noise from mne.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: Setup Step3: Data simulation Step4: Let's simulate two timeseries and plot some basic information about them. Step5: Now we put the signals a...
4,170
<ASSISTANT_TASK:> Python Code: from sqlalchemy import create_engine # database connection import datetime as dt # for timing import pandas as pd # for data frames #CSV_FILE = 'NYC-311-2M.csv' CSV_FILE = None assert CSV_FILE import re CSV_BASES = re.findall (r'(.*)\.csv$', CSV_FILE, re.I) assert len (CSV_BASES) >= 1 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: Input (CSV) filename Step2: Determine output (SQLite DB) filename from the input filename Step3: Connect to an SQL data source Step4: Convert...
4,171
<ASSISTANT_TASK:> Python Code: !wget -c https://repo.anaconda.com/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh !chmod +x Miniconda3-4.5.4-Linux-x86_64.sh !bash ./Miniconda3-4.5.4-Linux-x86_64.sh -b -f -p /usr/local !conda install -c conda-forge -c bioconda hhsuite !hhsearch %%bash cd /content/ mkdir hh cd hh mkdir ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Be sure to input 'y' into the cell below to allow conda to install hh-suite to this colab. Step2: Using hhsearch Step3: Let's do an example. S...
4,172
<ASSISTANT_TASK:> Python Code: import xarray as xr from metpy.cbook import get_test_data from metpy.plots import ContourPlot, ImagePlot, MapPanel, PanelContainer from metpy.units import units # Use sample NARR data for plotting narr = xr.open_dataset(get_test_data('narr_example.nc', as_file_obj=False)) contour = Conto...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Create a contour plot of temperature Step2: Create an image plot of Geopotential height Step3: Plot the data on a map
4,173
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np from matplotlib import pyplot as plt import seaborn as sns plt.style.use('bmh') %matplotlib inline import random random.seed(42) np.random.seed(42) districts = {1: 'NW', 4: 'C', 5:'N', 6:'NE', 7:'E', 8:'SE', 9:'S', 10:'SW', 11:'W'} data = pd.read_csv...
<SYSTEM_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: Число уникальных значений для этих колонок Step4: И...
4,174
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import matplotlib.pyplot as plt %matplotlib inline planon=pd.read_excel('EIS Assets v2.xlsx',index_col = 'Code') #master_loggerscontrollers_old = pd.read_csv('LoggersControllers.csv', index_col = 'Asset Code') #master_meterssensors_old = pd.read_csv...
<SYSTEM_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 data. There are two datasets Step2: Unify index, caps everything and strip of trailing spaces. Step3: Drop duplicates (shouldn't be any) ...
4,175
<ASSISTANT_TASK:> Python Code: from __future__ import print_function from __future__ import division from __future__ import absolute_import # We're using pandas to read the CSV file. This is easy for small datasets, but for large and complex datasets, # tensorflow parsing and processing functions are more powerful 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: Please Download Step2: Dealing with NaN Step3: Standardize features Step4: Separating training data from testing data Step5: Using Tensorflo...
4,176
<ASSISTANT_TASK:> Python Code: # Create a small example function def add_two(x_input): return x_input + 2 # Import Node and Function module from nipype import Node, Function # Create Node addtwo = Node(Function(input_names=["x_input"], output_names=["val_output"], func...
<SYSTEM_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 simple function takes a value, adds 2 to it, and returns that new value. Step2: Then you can set the inputs and run just as you would with...
4,177
<ASSISTANT_TASK:> Python Code: import os import pandas as pd import time from tqdm import tqdm import glob import numpy as np from utils.input_pipeline import * #TODO: Try the variational approach instead. #TODO: instead of solving for a small dimension representation, then traiing a RF on this...make the dims larger 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: Loading the data Step2: Store the result of dropping the label column from the dataframe as the input data $X$. In order to preserve the number...
4,178
<ASSISTANT_TASK:> Python Code: # Import py_entitymatching package import py_entitymatching as em import os import pandas as pd # Get the datasets directory datasets_dir = em.get_install_path() + os.sep + 'datasets' # Get the paths of the input tables path_A = datasets_dir + os.sep + 'person_table_A.csv' path_B = 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: Then, read the (sample) input tables for blocking purposes. Step2: Generating Features for Blocking Step3: Different Ways to Block Using Rule ...
4,179
<ASSISTANT_TASK:> Python Code: import psycopg2 from psycopg2.extras import RealDictCursor import pandas as pd # import geopandas as gpd # from shapely import wkb # from shapely.geometry import mapping as to_geojson # import folium pd.options.display.max_columns = None pd.options.display.max_rows = None #pd.set_option('...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step5: DB migration/setup Step8: Processing Step9: Results
4,180
<ASSISTANT_TASK:> Python Code: from __future__ import print_function, division import analytic import brfss import nsfg import thinkstats2 import thinkplot import pandas as pd import numpy as np import math %matplotlib inline thinkplot.PrePlot(3) for lam in [2.0, 1, 0.5]: xs, ps = thinkstats2.RenderExpoCdf(lam, 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: This notebook is about ways to model data using analytic distributions. I start with the exponential distribution, which is often a good model ...
4,181
<ASSISTANT_TASK:> Python Code: from datetime import datetime # Pandas and NumPy import pandas as pd import numpy as np # Read the CSV with flights records (separation = ";") flights = pd.read_csv('data/arfsample-date.csv', sep = ';', dtype = str) flights.head() # Lambda function # 1 - Used to adjust date columns to ISO...
<SYSTEM_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, it is time to covert dates from 'object' to 'date' format Step2: Status of the flight Step3: The result, so far Step4: Some EDA (tests) ...
4,182
<ASSISTANT_TASK:> Python Code: from __future__ import division, print_function from spectrum_overload import Spectrum from astropy.io import fits import copy import numpy as np import matplotlib.pyplot as plt x = np.arange(2000, 2050) y = np.random.rand(len(x)) spec_uncalibrated = Spectrum(y, x) spec_calibrated = Spec...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: You create a spectrum object by passing in the flux and the dispersion values. As positional arguments flux is first. If your dispersion axis ha...
4,183
<ASSISTANT_TASK:> Python Code: !pip install nxpd %matplotlib inline import matplotlib.pyplot as plt import networkx as nx import pandas as pd import numpy as np from operator import truediv from collections import Counter import itertools import random import collaboratr #from nxpd import draw #import nxpd #reload(coll...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Step 1 Create a Google Form with these questions Step2: Step 2 Step3: Step 3
4,184
<ASSISTANT_TASK:> Python Code: ! ls -lh ../waffle_network_dir/*.tsv ! wc -l ../waffle_network_dir/network.py.tsv ! head -n 5 ../waffle_network_dir/network.py.tsv | csvlook -t ! ls -lh ../waffle_network_dir/network.py.tsv network = pd.read_csv('../waffle_network_dir/network.py.tsv', skiprows=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: Make a 10k row version of the file for development. Step2: I am only using 3.7% of Waffle's memory at the beginning Step3: Use summary_count...
4,185
<ASSISTANT_TASK:> Python Code: import graphlab def polynomial_sframe(feature, degree): # assume that degree >= 1 # initialize the SFrame: poly_sframe = graphlab.SFrame() # and set poly_sframe['power_1'] equal to the passed feature poly_sframe['power_1'] = feature # first check if degree > 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: Polynomial regression, revisited Step2: Let's use matplotlib to visualize what a polynomial regression looks like on the house data. Step3: As...
4,186
<ASSISTANT_TASK:> Python Code: from __future__ import division import pkg_resources import os import pandas as pd from pandas import concat import seaborn from openfisca_france_indirect_taxation.examples.utils_example import graph_builder_line seaborn.set_palette(seaborn.color_palette("Set2", 12)) %matplotlib inline ...
<SYSTEM_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 de modules spécifiques à Openfisca Step2: Import d'une nouvelle palette de couleurs Step3: Import des fichiers csv donnant les montants...
4,187
<ASSISTANT_TASK:> Python Code: range(2), xrange(2) def gen(r): for i in xrange(r): yield i ** 2 generator = gen(5) generator list(generator) generator = (i ** 2 for i in xrange(5)) generator list(generator) def gen_squares(up_to=100000): s = 0 for sq in (i**2 for i in xrange(up_to)): s += sq...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Moduły Step2: Co można zaimportować? Step3: from module import ( Step4: Uwagi Step5: Zakresy Step6: Co zwróci odpalanie modb.py, a co zaimp...
4,188
<ASSISTANT_TASK:> Python Code: import chaospy from problem_formulation import joint gauss_quads = [ chaospy.generate_quadrature(order, joint, rule="gaussian") for order in range(1, 8) ] sparse_quads = [ chaospy.generate_quadrature( order, joint, rule=["genz_keister_24", "clenshaw_curtis"], sparse=Tr...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Evaluating model solver Step2: Expansion of orthogonal polynomials Step3: Fourier coefficients Step4: Note that if the Fourier coefficients a...
4,189
<ASSISTANT_TASK:> Python Code: ! pip3 install -U google-cloud-aiplatform --user ! pip3 install google-cloud-storage import os if not os.getenv("AUTORUN"): # Automatically restart kernel after installs import IPython app = IPython.Application.instance() app.kernel.do_shutdown(True) PROJECT_ID = "[your...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Install the Google cloud-storage library as well. Step2: Restart the Kernel Step3: Before you begin Step4: Region Step5: Timestamp Step6: A...
4,190
<ASSISTANT_TASK:> Python Code: from learntools.core import binder; binder.bind(globals()) from learntools.python.ex6 import * print('Setup complete.') a = "" length = ____ q0.a.check() b = "it's ok" length = ____ q0.b.check() c = 'it\'s ok' length = ____ q0.c.check() d = hey length = ____ q0.d.check() e = '\n' len...
<SYSTEM_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 start with a string lightning round to warm up. What are the lengths of the strings below? Step2: 0b. Step3: 0c. Step5: 0d. Step6: 0e....
4,191
<ASSISTANT_TASK:> Python Code: from keras.layers import Bidirectional, Concatenate, Permute, Dot, Input, LSTM, Multiply from keras.layers import RepeatVector, Dense, Activation, Lambda from keras.optimizers import Adam from keras.utils import to_categorical from keras.models import load_model, Model import keras.backen...
<SYSTEM_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 - Translating human readable dates into machine readable dates Step2: You've loaded Step3: You now have Step4: 2 - Neural machine translati...
4,192
<ASSISTANT_TASK:> Python Code: # code for loading the format for the notebook import os # path : store the current path to convert back to it later path = os.getcwd() os.chdir(os.path.join('..', 'notebook_format')) from formats import load_style load_style(plot_style = False) os.chdir(path) # 1. magic for inline plot #...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Logistic Regression Step2: Our task is to predict the household column using the al column. Let's visualize the relationship between the input ...
4,193
<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: Post-training integer quantization Step2: Train and export the model Step3: This training won't take long because you're training the model fo...
4,194
<ASSISTANT_TASK:> Python Code: # imports from sklearn.datasets import make_classification from sklearn.ensemble import RandomForestClassifier import time import matplotlib.pyplot as plt import seaborn as sns num_samples = 500 * 1000 num_features = 40 X, y = make_classification(n_samples=num_samples, n_features=num_fea...
<SYSTEM_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 create a training set of size num_samples and num_features. Step2: Next we run a performance test on the created data set. Therefor we...
4,195
<ASSISTANT_TASK:> Python Code: import numpy as np x = [1,2,3] y = [4,5,6] x + y B = np.array([[1,2,3], [4,5,6]]) # habiendo corrido import numpy as np B + 2*B # Python sabe sumar y multiplicar arrays como algebra lineal np.matmul(B.transpose(), B) # B^t*B B[1,1] B[1,:] B[:,2] B[0:2,0:2] B.shape vec = np.array...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Lo que el codigo anterior hace es asociar al nombre np todas las herramientas de la libreria numpy. Ahora podremos llamar funciones de numpy com...
4,196
<ASSISTANT_TASK:> Python Code: numbers_str = '496,258,332,550,506,699,7,985,171,581,436,804,736,528,65,855,68,279,721,120' numbers = [int(i) for i in numbers_str.split(',')] # replace 'None' with an expression, as described above max(numbers) sorted(numbers)[-10:] sorted([i for i in numbers if i % 3 == 0]) from mat...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: In the following cell, complete the code with an expression that evaluates to a list of integers derived from the raw numbers in numbers_str, as...
4,197
<ASSISTANT_TASK:> Python Code: from folium import plugins m = folium.Map([45, 3], zoom_start=4) plugins.ScrollZoomToggler().add_to(m) m.save(os.path.join('results', 'Plugins_0.html')) m import numpy as np N = 100 data = np.array( [ np.random.uniform(low=35, high=60, size=N), # Random latitudes in Europe. ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: MarkerCluster Step2: Terminator Step3: Leaflet.boatmarker Step4: Fullscreen
4,198
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL import helper data_dir = './data/simpsons/moes_tavern_lines.txt' text = helper.load_data(data_dir) # Ignore notice, since we don't use it for analysing the data text = text[81:] view_sentence_range = (0, 10) DON'T MODIFY ANYTHING IN THIS CELL import 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 Preprocessing Functions Step9: Tokenize Punctuation Step11: Preprocess all the...
4,199
<ASSISTANT_TASK:> Python Code: %%bash source activate py2env conda install -y pytz pip uninstall -y google-cloud-dataflow pip install --upgrade apache-beam[gcp]==2.9.0 import tensorflow as tf import apache_beam as beam import shutil print(tf.__version__) import os REGION = 'us-central1' # Choose an available region 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: After doing a pip install, you have to Reset Session so that the new packages are picked up. Please click on the button in the above menu. Step...