Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
5,800
<ASSISTANT_TASK:> Python Code: import numpy as np A = np.array([[56.0, 0.0, 4.4, 68.0], [1.2,104.0,52.0,8.0], [1.8,135.0,99.0,0.9]]) print(A) cal = A.sum(axis=0) print(cal) percentage = 100*A/cal.reshape(1,4) print(percentage) import numpy as np a = np.random.randn(5) print(a) print(a.shape...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 15 Note on numpy
5,801
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'snu', 'sandbox-3', 'atmoschem') # 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...
5,802
<ASSISTANT_TASK:> Python Code: matplotlib inline import pandas as pd import numpy as np from numpy import log import statsmodels.formula.api as smf data = pd.read_csv("trade_data.csv") data.head() data.columns formula = "log(value) ~ log(egdp) + log(igdp) + log(dist)" model = smf.ols(formula, data) result = model.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: First we read in the data. Step2: Let's see what it looks like. Step3: Let's get a full list of columns. Step4: Let's regress 'value' on 'egd...
5,803
<ASSISTANT_TASK:> Python Code: import nengo import numpy as np import cPickle from nengo_extras.data import load_mnist from nengo_extras.vision import Gabor, Mask from matplotlib import pylab import matplotlib.pyplot as plt import matplotlib.animation as animation import random import scipy.ndimage # --- load the 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: Load the MNIST database Step2: Each digit is represented by a one hot vector where the index of the 1 represents the number Step3: Load the sa...
5,804
<ASSISTANT_TASK:> Python Code: # Load library import numpy as np import pandas as pd # Create feature matrix X = np.array([[1, 2], [6, 3], [8, 4], [9, 5], [np.nan, 4]]) # Remove observations with missing values X[~np.isnan(X).any(axis=1)] # Load data as a 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: Create Data Frame Step2: Drop Missing Values Using NumPy Step3: Drop Missing Values Using pandas
5,805
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np from IPython.html.widgets import interact, interactive, fixed from IPython.display import display def random_line(m, x, b, sigma, size=10): Create a line y = m*x + b + N(0,sigma**2) between x=[-1.0,1.0] Pa...
<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: Line with Gaussian noise Step5: Write a function named plot_random_line that takes the same arguments as random_line and creates a random line ...
5,806
<ASSISTANT_TASK:> Python Code: from sklearn.datasets import load_iris iris = load_iris() print(iris.data.shape) measurements = [ {'city': 'Dubai', 'temperature': 33.}, {'city': 'London', 'temperature': 12.}, {'city': 'San Francisco', 'temperature': 18.}, ] from sklearn.feature_extraction import DictVectori...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: These features are Step2: Derived Features Step3: Here is a broad description of the keys and what they mean Step4: We clearly want to discar...
5,807
<ASSISTANT_TASK:> Python Code: import sys sys.path.append('../') import cPickle as pickle import re import glob import os from generators import DataLoader import time import holoviews as hv import theano import theano.tensor as T import numpy as np import pandas as p import lasagne as nn from utils import hms, archite...
<SYSTEM_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're going to test on some train images, so loading the training set labels. Step2: Using the DataLoader to set up the parameters, you could r...
5,808
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import pandas as pd import matplotlib.pyplot as plt import matplotlib as mpl import seaborn as sns from matplotlib.ticker import LinearLocator sns.set_style('whitegrid') mpl.rcParams['font.size'] = 16 mpl.rcParams['axes.labelsize'] = 16 mpl.rcParams['...
<SYSTEM_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 observations Step2: Model simulation Step3: Structural options Step4: Run the model Step5: Focus on a subperiod to plot Step6: Plot th...
5,809
<ASSISTANT_TASK:> Python Code: cities = ["Bristol", "London", "Manchester", "Edinburgh", "Belfast", "York"] print("The position of Manchester in the list is: " + str(cities.???('Manchester'))) print("The position of Manchester in the list is: " + str(cities.index('Manchester'))) print(cities[2 + ???]) print(cities[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: b) Replace the ??? so that it prints the position of Manchester in the list Step2: c) Replace the ??? so that it prints Belfast Step3: d) Use ...
5,810
<ASSISTANT_TASK:> Python Code: from impact.core.features import BaseAnalyteFeature, BaseAnalyteFeatureFactory class ODNormalizedData(BaseAnalyteFeature): # The constructor should accept all required analytes as parameters def __init__(self, biomass, reporter): self.biomass = biomass self.repor...
<SYSTEM_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, we can build our features Step2: Finally, we register the feature Step3: and test it
5,811
<ASSISTANT_TASK:> Python Code: # run this once per session to bring in a required library !pip --quiet install sparqlwrapper | grep -v 'already satisfied' from SPARQLWrapper import SPARQLWrapper, JSON import pandas as pd import io import requests # This function shows how to use rdflib to query a REMOTE sparql dataset ...
<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: <a href="https Step3: Examples
5,812
<ASSISTANT_TASK:> Python Code: ### START CODE HERE ### (≈ 1 line of code) test = "Hello World" ### END CODE HERE ### print ("test: " + test) # GRADED FUNCTION: basic_sigmoid import math def basic_sigmoid(x): Compute sigmoid of x. Arguments: x -- A scalar Return: s -- sigmoid(x) #...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: Expected output Step3: Expected Output Step4: In fact, if $ x = (x_1, x_2, ..., x_n)$ is a row vector then $np.exp(x)$ will apply the exponent...
5,813
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mpi-m', 'sandbox-1', '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...
5,814
<ASSISTANT_TASK:> Python Code: texts = [ "Penny bought bright blue fishes.", "Penny bought bright blue and orange fish.", "The cat ate a fish at the store.", "Penny went to the store. Penny ate a bug. Penny saw a fish.", "It meowed once at the bug, it is still meowing at the bug and the fish", "...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: When you process text, you have a nice long series of steps, but let's say you're interested in three things Step2: The scikit-learn package do...
5,815
<ASSISTANT_TASK:> Python Code: %matplotlib inline # Imports from clr import AddReference AddReference("System") AddReference("QuantConnect.Common") AddReference("QuantConnect.Jupyter") AddReference("QuantConnect.Indicators") from System import * from QuantConnect import * from QuantConnect.Data.Market import TradeBar, ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Selecting Asset Data Step2: Historical Data Requests Step3: Historical Options Data Requests Step4: Get Fundamental Data Step5: Indicators
5,816
<ASSISTANT_TASK:> Python Code: import emcee import halomod import numpy as np import matplotlib.pyplot as plt from scipy.stats import norm from multiprocess import Pool import corner %matplotlib inline emcee.__version__ halomod.__version__ model = halomod.TracerHaloModel( z=0.2, transfer_model='EH', rnum...
<SYSTEM_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 Some Mock Data Step2: Now, let's create some mock data with some Gaussian noise Step3: Define a likelihood Step4: Define an emcee-comp...
5,817
<ASSISTANT_TASK:> Python Code: from IoTPy.agent_types.simple import f_item def f(item, M, multiples_stream, non_multiples_stream): if item%M: multiples_stream.append(item) else: non_multiples_stream.append(item) x = Stream(name='input stream') y = Stream(name='even numbers in stream x') z = Str...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Second step Step2: Third step Step3: ANOTHER EXAMPLE of f_item Step4: SLIDING WINDOWS OF STREAMS Step5: Synchronous Join Step6: Asynchronou...
5,818
<ASSISTANT_TASK:> Python Code: from abc import ABC, abstractmethod from collections import namedtuple Customer = namedtuple('Customer', 'name fidelity') class LineItem: def __init__(self, product, quantity, price): self.product = product self.quantity = quantity self.price = price 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: Python 3.4 中,声明抽象基类的最简单方式是子类化 abc.ABC。我们的例子就是这么做的,从 Python 3.0 到 Python 3.3,必须在 class 语句使用 metaclas = 关键字 Step2: 用函数实现 “策略” 模式 Step3: 新的 Order...
5,819
<ASSISTANT_TASK:> Python Code: baseDir = '/home/nick/notebook/SIPSim/dev/priming_exp/' workDir = os.path.join(baseDir, 'exp_info') otuTableFile = '/var/seq_data/priming_exp/data/otu_table.txt' otuTableSumFile = '/var/seq_data/priming_exp/data/otu_table_summary.txt' metaDataFile = '/var/seq_data/priming_exp/data/allsamp...
<SYSTEM_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 Step2: Loading OTU table (filter to just bulk samples) Step3: Which gradient(s) to simulate? Step4: Notes Step5: Total richness of star...
5,820
<ASSISTANT_TASK:> Python Code: # Importing pandas and numpy import pandas as pd import numpy as np # Reading the csv file into a pandas DataFrame data = pd.read_csv('student_data.csv') # Printing out the first 10 rows of our data data[:10] # Importing matplotlib import matplotlib.pyplot as plt # Function to help us pl...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Plotting the data Step2: Roughly, it looks like the students with high scores in the grades and test passed, while the ones with low scores did...
5,821
<ASSISTANT_TASK:> Python Code: import numpy as np from scipy.stats import powerlaw import scipy as sp import seaborn as sns sns.set() %matplotlib inline edges =[] for line in open('facebook_combined.txt'): if line[0] != '#': # print(line.replace('\n','').split(' ')) # \n es salto de linea, .split(' ') -> se...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Generative Network Model
5,822
<ASSISTANT_TASK:> Python Code:: import numpy as np import gpt_2_simple as gpt2 from datetime import datetime from google.colab import files from tensorflow.python.framework import ops gpt2.download_gpt2(model_name="124M") from transformers import GPT2Tokenizer tokenizer = GPT2Tokenizer.from_pretrained("gpt2") sess = gp...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
5,823
<ASSISTANT_TASK:> Python Code: from tvb.simulator.lab import * LOG.info("Configuring...") #Initialize a Model, Coupling, and Connectivity. oscillator = models.Generic2dOscillator() white_matter = connectivity.Connectivity.from_file("connectivity_96.zip") white_matter.speed = numpy.array([4.0]) white_matter_coupling = ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Perform the simulation Step2: Plot pretty pictures of what we just did
5,824
<ASSISTANT_TASK:> Python Code: !pip install git+https://github.com/google/starthinker from starthinker.util.configuration import Configuration CONFIG = Configuration( project="", client={}, service={}, user="/content/user.json", verbose=True ) FIELDS = { 'auth_read':'user', # Credentials used for reading...
<SYSTEM_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. Set Configuration Step2: 3. Enter DV360 Report Emailed To BigQuery Recipe Parameters Step3: 4. Execute DV360 Report Emailed To BigQuery
5,825
<ASSISTANT_TASK:> Python Code: primeNumbers = [2, 3, 5, 7] for prime in primeNumbers: 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, 219, 390,...
<SYSTEM_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: 3.Drucke die Zahlen 3,4,5 aus Step3: 4.Baue einen For-Loop, indem Du alle geraden Zahlen ausdr...
5,826
<ASSISTANT_TASK:> Python Code: 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 = (20, 30) import numpy as np print('Dataset Stats') print('Roughly the number of unique w...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Explore the Data Step3: Preprocessing Step5: Tokenize Punctuation Step6: Preprocess all the data and save it Step7: Check Point Step8: Buil...
5,827
<ASSISTANT_TASK:> Python Code: from learntools.ml_explainability.ex4 import * print("Setup Complete") import pandas as pd data = pd.read_csv('../input/hospital-readmissions/train.csv') data.columns import pandas as pd from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_s...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The Scenario Step2: Here are some quick hints at interpreting the field names Step3: Now use the following cell to create the materials for th...
5,828
<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: 色空間変換 Step2: サンプル画像をダウンロードする Step3: 使い方 Step4: 画像は以下の方法で表示できます。 Step5: RGB からグレースケールに変換する Step6: RGB から BGR に変換する Step7: RGB から CIE XYZ に変...
5,829
<ASSISTANT_TASK:> Python Code: ## Augumenting functions based on Naoki Shibuya's work! Thank you! ## https://github.com/naokishibuya/car-traffic-sign-classification import cv2 import numpy as np def resizeImage(image): return cv2.resize(img, (48,48)) def random_brightness(image, ratio): hsv = cv2.cvtColor(image...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: With this we have expanded our dataset by factor 8. Let's look at the distribution of datapoints over all classes Step2: All preprocessing step...
5,830
<ASSISTANT_TASK:> Python Code: print("Exemplo 8.9\n") from sympy import * t = symbols('t') V = 12 C = 1/2 L = 1 #Para t < 0 i0 = 0 v0 = V print("i(0):",i0,"A") print("v(0):",v0,"V") #Para t = oo i_f = V/(4 + 2) vf = V*2/(4 + 2) print("i(oo):",i_f,"A") print("v(oo):",vf,"V") #Para t > 0 #desativar fontes independentes #...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Problema Prático 8.9 Step2: Exemplo 8.10 Step3: Problema Prático 8.10
5,831
<ASSISTANT_TASK:> Python Code: import os import numpy as np import mne sample_data_folder = mne.datasets.sample.data_path() sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample', 'sample_audvis_filt-0-40_raw.fif') raw = mne.io.read_raw_fif(sample_data_raw_file) 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: Step1: Loading data Step2: By default, ~mne.io.read_raw_fif displays some information about the file Step3: ~mne.io.Raw objects also have several bui...
5,832
<ASSISTANT_TASK:> Python Code: # Authors: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr> # # License: BSD (3-clause) import numpy as np import matplotlib.pyplot as plt import mne from mne import io from mne.datasets import sample print(__doc__) data_path = sample.data_path() raw_fname = data_path + '/MEG...
<SYSTEM_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: Show event-related fields images
5,833
<ASSISTANT_TASK:> Python Code: # IMPORT LIBRARIES import pandas as pd, numpy as np, os, gc # LOAD AND FREQUENCY-ENCODE FE = ['EngineVersion','AppVersion','AvSigVersion','Census_OSVersion'] # LOAD AND ONE-HOT-ENCODE OHE = [ 'RtpStateBitfield','IsSxsPassiveMode','DefaultBrowsersIdentifier', 'AVProductStatesIdenti...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Statistically Encode Variables Step2: Example - Census_OEMModelIdentifier Step3: Predict Test and Submit to Kaggle
5,834
<ASSISTANT_TASK:> Python Code: #@title Licensed under the Apache License, Version 2.0 (the "License") # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The 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: Filter Step2: Examples Step3: <table align="left" style="margin-right Step4: <table align="left" style="margin-right Step5: <table align="le...
5,835
<ASSISTANT_TASK:> Python Code: def safe_str(obj): return the byte string representation of obj if obj is None: return unicode("") return unicode(obj) def dedupe_pings(rdd): return rdd.filter(lambda p: p["meta/clientId"] is not None)\ .map(lambda p: (p["meta/documentId"], p))\ ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Take the set of pings, make sure we have actual clientIds and remove duplicate pings. Step2: We're going to dump each event from the pings. Do ...
5,836
<ASSISTANT_TASK:> Python Code: import numpy as np points_in = 0 for i in range(100): x = np.random.rand() y = np.random.rand() r = np.sqrt(x**2 + y**2) if r <= 1: points_in += 1 pi_4 = points_in/(i+1) print("pi = {}".format(pi_4 * 4.)) %matplotlib nbagg import matpl...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Animations Step2: So animation plotting is based off creating a function. So in this case, we are animating a line plot. Step3: This works! An...
5,837
<ASSISTANT_TASK:> Python Code: a_list = [10, 32.4, -14.2, "a", "b", [], [1,2]] for item in a_list: try: print(item * item) except TypeError: print(item + item) item = 0 try: item / item except TypeError: print(item + item) x = 0 # The bad fix first... try: x / x exc...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: So what’s going on here? Well, we have list which contains several different data-types. For every 'item' we try to multiply item by itself. If ...
5,838
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np df = pd.read_csv('../data/train.csv') df.head(10) df = df.drop(['Name', 'Ticket', 'Cabin'], axis=1) df.info() df = df.dropna() df['Sex'].unique() df['Gender'] = df['Sex'].map({'female': 0, 'male':1}).astype(int) df['Embarked'].unique() df['Port...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Pandas - Cleaning data Step2: We notice that the columns describe features of the Titanic passengers, such as age, sex, and class. Of particula...
5,839
<ASSISTANT_TASK:> Python Code: class_port = titanic[['PassengerId', 'Pclass', 'Embarked']] print class_port.isnull().any() print class_port = class_port.dropna() print class_port.isnull().any() passengers_by_port_class = class_port.groupby(['Embarked', 'Pclass'], as_index=False).count() print passengers_by_port_class ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: We need the number of passengers for each port of embarkment and class Step2: and the total number of passengers for each port Step3: Now we c...
5,840
<ASSISTANT_TASK:> Python Code: from logic import * %psource dpll_satisfiable %psource dpll %psource min_clauses %psource moms %psource momsf %psource posit %psource zm %psource dlis %psource dlcs %psource jw %psource jw2 %psource cdcl_satisfiable %psource conflict_analysis %psource pl_binary_resolution %psou...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: DPLL with Branching Heuristics Step2: Each of these branching heuristics was applied only after the pure literal and the unit clause heuristic ...
5,841
<ASSISTANT_TASK:> Python Code: '{:.2f}'.format(8.499) '{:.2f}%'.format(10.12345) import re def truncate(num,decimal_places): dp = str(decimal_places) return re.sub(r'^(\d+\.\d{,'+re.escape(dp)+r'})\d*$',r'\1',str(num)) truncate(8.499,decimal_places=2) truncate(8.49,decimal_places=2) truncate(8.4,decimal_pla...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: format float as percentage Step2: truncate to at most 2 decimal places Step3: left padding with zeros Step4: right padding with zeros Step5: ...
5,842
<ASSISTANT_TASK:> Python Code: x=range(1,10) y=[1,2,3,4,0,4,3,2,1] plt.plot(x,y) # address = some data set # cars = pd.read_csv(address) # cars.columns = ['car_names','mpg','cyl','disp','hp','drat','wt','qsec','vs','am',gear',carb'] #mpg = cars['mpg'] #mpg.plot() plt.bar(x,y) #Creating bar chart from pandas 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: Plotting a line chart from a Pandas object Step2: Creating bar charts Step3: Creating a pie chart Step4: Defining elements of a plot Step5: ...
5,843
<ASSISTANT_TASK:> Python Code: df=pd.read_csv("311-2014.csv",nrows=20000) df.head() df.columns df.info() dateutil.parser.parse('07/16/1990').month def parse_date (str_date): return dateutil.parser.parse(str_date)#dateutil is a module, import parser class, then transform a string into a python time object df['Create...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: What was the most popular type of complaint, and how many times was it filed? Step2: Make a horizontal bar graph of the top 5 most frequent com...
5,844
<ASSISTANT_TASK:> Python Code: # Author: Martin Luessi <mluessi@nmr.mgh.harvard.edu> # # License: BSD (3-clause) import numpy as np import mne from mne import io from mne.connectivity import spectral_connectivity, seed_target_indices from mne.datasets import sample from mne.time_frequency import AverageTFR print(__doc_...
<SYSTEM_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
5,845
<ASSISTANT_TASK:> Python Code: df['x4'] = 1 X = df.iloc[:,(0,1,2,4)].values y = df.y.values inv_XX_T = inv(X.T.dot(X)) w = inv_XX_T.dot(X.T).dot(df.y.values) w qr(inv_XX_T) X.shape #solve(X,y)##只能解方阵 def f(w,X,y): return ((X.dot(w)-y)**2/(2*1000)).sum() def grad_f(w,X,y): return (X.dot(w) - y).dot(X)/10...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: $y = Xw$ Step2: Results Step3: 梯度下降法求解 Step4: 随机梯度下降法求解
5,846
<ASSISTANT_TASK:> Python Code: %matplotlib inline from parcels import FieldSet, ParticleSet, JITParticle, Variable, AdvectionRK4 import numpy as np import matplotlib.pyplot as plt from matplotlib import cm import xarray as xr dims = [5, 4] dx, dy = 1./dims[0], 1./dims[1] dimensions = {'lat': np.linspace(0., 1., dims[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: We create a small 2D grid where P is a tracer that we want to interpolate. In each grid cell, P has a random value between 0.1 and 1.1. We then ...
5,847
<ASSISTANT_TASK:> Python Code: !pip install git+https://github.com/google/starthinker from starthinker.util.configuration import Configuration CONFIG = Configuration( project="", client={}, service={}, user="/content/user.json", verbose=True ) FIELDS = { 'account':'', 'auth_cm':'user', # Credentials us...
<SYSTEM_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. Set Configuration Step2: 3. Enter CM360 Conversion Upload From BigQuery Recipe Parameters Step3: 4. Execute CM360 Conversion Upload From Bi...
5,848
<ASSISTANT_TASK:> Python Code: %%writefile Snakefile rule: input: 'fileA.txt' output: 'fileB.txt' shell: 'cp fileA.txt fileB.txt' %%sh snakemake fileB.txt %%writefile -a Snakefile rule: output: 'fileA.txt' shell: 'touch fileA.txt' %%sh snakemake %%sh snakemake --dag | dot | display snakemake --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: For snakemake the workflow definition needs to be specified in a Snakefile and can be executed by calling snakemake in a terminal in the same lo...
5,849
<ASSISTANT_TASK:> Python Code: import datetime print(datetime.datetime.now()) %pylab inline !ls #Example of how to compute the sum of two lists def add(x,y): add=0 for element_x in x: add=add+element_x for element_y in y: add=add+element_y return add my_list = range(0,100) print(my_li...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: More info on notebooks and cells is here. Step2: The magic %pylab sets up the interactive namespace from numpy and matplotlib and inline adds t...
5,850
<ASSISTANT_TASK:> Python Code: from straightline_utils import * %matplotlib inline from matplotlib import rcParams rcParams['savefig.dpi'] = 100 (x,y,sigmay) = get_data_no_outliers() plot_yerr(x, y, sigmay) def straight_line_log_likelihood(x, y, sigmay, m, b): ''' Returns the log-likelihood of drawing data val...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Bayesian Solution Step2: Short Cut #1 Step3: Similarly, one can derived expressions for the uncertainty for of the least squares fit parameter...
5,851
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd Construtor padrão pd.Series( name="Compras", index=["Leite", "Ovos", "Carne", "Arroz", "Feijão"], data=[2, 12, 1, 5, 2] ) Construtor padrão: dados desconhecidos pd.Series( name="Compras", index=["Leite", "Ovos", "Carne", "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: Step9: Construção Step20: DataFrame Step21: Acessando valores Step22: Slicing Step30: DataFrame Step33: * Atribuição de Valores em DataFrames Step...
5,852
<ASSISTANT_TASK:> Python Code: import numpy as np from matplotlib import pyplot as plt # # get Stull's c_1 and c_2 from fundamental constants # c=2.99792458e+08 #m/s -- speed of light in vacuum h=6.62606876e-34 #J s -- Planck's constant kb=1.3806503e-23 # J/K -- Boltzman's constant c=3.e8 #speed of light in vacuu...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Day 3 Planck problem Step2: so good agreement with 10000 points -- make a plot as well
5,853
<ASSISTANT_TASK:> Python Code: %matplotlib inline from __future__ import division import numpy as np import matplotlib.pyplot as plt np.random.seed(1) D = np.random.rand(100,100) ## This is not symmetric, so we make it symmetric D = (D+D.T)/2 print (D) import math N_steps = 10000 def L(sigma): s=0 for i in rang...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: T = 0.05 Step2: T=10 Step3: Correlation plots Step4: Result Step5: $\alpha$ Step6: $\beta$ Step7: $\alpha+\beta$ Step8: pol
5,854
<ASSISTANT_TASK:> Python Code: labVersion = 'cs190_week4_v_1_3' # Data for manual OHE # Note: the first data point does not include any value for the optional third feature sampleOne = [(0, 'mouse'), (1, 'black')] sampleTwo = [(0, 'cat'), (1, 'tabby'), (2, 'mouse')] sampleThree = [(0, 'bear'), (1, 'black'), (2, 'salm...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Part 1 Step2: (1b) Sparse vectors Step3: (1c) OHE features as sparse vectors Step5: (1d) Define a OHE function Step6: (1e) Apply OHE to a...
5,855
<ASSISTANT_TASK:> Python Code: from jyquickhelper import add_notebook_menu add_notebook_menu(header="Plan") from pyquickhelper.loghelper import fLOG fLOG(OutputPrint=False) # by default fLOG("not printed") fLOG(OutputPrint=True) fLOG("printed") from pyquickhelper.loghelper import run_cmd out,err=run_cmd("help", wait...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Log, run_cmd Step2: The function run_cmd runs a command line and returns the standard output and error Step3: Ask something to the user in a n...
5,856
<ASSISTANT_TASK:> Python Code: %%capture from Q_tool_devo import Q8; U=Q8([1,2,-3,4]) V=Q8([4,-2,3,1]) R=Q8([5,6,7,-8]) print(U) print(R) def rotate_R_by_U(R, U): Given a space-time number R, rotate it by Q. return U.triple_product(R, U.invert()) R_rotated = rotate_R_by_U(R,U) print(R_rotated) print(R_rotate...
<SYSTEM_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 the Q8 class that places these 4 numbers in 8 slots like so Step3: If you are unfamiliar with this notation, the $I^2 = -1,\, i^3=-i,\, j^3...
5,857
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'miroc', 'sandbox-3', 'aerosol') # 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...
5,858
<ASSISTANT_TASK:> Python Code: from sklearn import preprocessing import matplotlib.pyplot as plt import numpy as np import pandas as pd # Encode text values to dummy variables(i.e. [1,0,0],[0,1,0],[0,0,1] for red,green,blue) def encode_text_dummy(df,name): dummies = pd.get_dummies(df[name]) for x in dummies.col...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Training with a Validation Set and Early Stopping Step2: Calculate Classification Accuracy Step3: Calculate Classification Log Loss Step4: Lo...
5,859
<ASSISTANT_TASK:> Python Code: !pip install "thinc>=8.0.0a0" transformers torch "ml_datasets>=0.2.0a0" "tqdm>=4.41" from thinc.api import prefer_gpu, use_pytorch_for_gpu_memory is_gpu = prefer_gpu() print("GPU:", is_gpu) if is_gpu: use_pytorch_for_gpu_memory() CONFIG = [model] @layers = "TransformersTagger.v1" s...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: First, let's use Thinc's prefer_gpu helper to make sure we're performing operations on GPU if available. The function should be called right aft...
5,860
<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:] text[0:500] view_sentence_range = (0, 10) DON'T MODIFY ANYTHING IN THIS CELL ...
<SYSTEM_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...
5,861
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np # Creating a series (with different type of data) s1 = pd.Series([34, 'Material', 4*np.pi, 'Reactor', [100,250,500,750], 'kW']) s1 # Creating a series with specified index lt = [34, 'Material', 4*np.pi, 'Reactor', [100,250,500,750], 'kW'] s2 = pd.S...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 8.1 Data Structures Step2: The index of a Series can be specified during its creation and giving it a similar function to a dictionary. Step3: ...
5,862
<ASSISTANT_TASK:> Python Code: import os import struct import numpy as np def load_mnist(path, kind='train'): Load MNIST data from `path` labels_path = os.path.join(path, '%s-labels-idx1-ubyte' % kind) images_path = os.path.join(path, '%s-image...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Chapter 12 Step2: Show a bunch of 4s Step3: Classifying with tree based models
5,863
<ASSISTANT_TASK:> Python Code: def n_divide(n): pass n_divide(10) def sen2word(xs): pass sen2word("I am learning Python. It's quite interesting.") def fibo(n): pass fibo(5) def second(t): return t[1] def sort_notes(xs): pass L = [("Lee", 45), ("Kim", 30), ("Kang", 70), ("Park", 99), ("Cho", ...
<SYSTEM_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 Step2: 연습 3 Step3: 연습 4 Step4: 연습 5
5,864
<ASSISTANT_TASK:> Python Code: import numpy as np import tensorflow as tf with open('../sentiment_network/reviews.txt', 'r') as f: reviews = f.read() with open('../sentiment_network/labels.txt', 'r') as f: labels = f.read() reviews[:2000] from string import punctuation all_text = ''.join([c for c in reviews if...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Data preprocessing Step2: Encoding the words Step3: Encoding the labels Step4: Okay, a couple issues here. We seem to have one review with ze...
5,865
<ASSISTANT_TASK:> Python Code: # only for the notebook %matplotlib inline # only in the ipython shell # %matplotlib import matplotlib.pyplot as plt # Make the size and fonts larger for this presentation plt.rcParams['figure.figsize'] = (10, 8) plt.rcParams['font.size'] = 16 plt.rcParams['lines.linewidth'] = 2 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: In order to work with Matplotlib, the library must be imported first. So we do not have to type so much, we give it a shorter name Step2: Matpl...
5,866
<ASSISTANT_TASK:> Python Code: import numpy as np # useful for many scientific computing in Python import pandas as pd # primary data structure library from PIL import Image # converting images into arrays df_can = pd.read_excel('https://ibm.box.com/shared/static/lw190pt9zpy5bd1ptyg2aw15awomz9pu.xlsx', ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Let's download and import our primary Canadian Immigration dataset using pandas read_excel() method. Normally, before we can do that, we would n...
5,867
<ASSISTANT_TASK:> Python Code: # get package versions from pkg_resources import require print 'Package versions' print '----------------' print require('genometools')[0] print require('goparser')[0] gene_annotation_file = 'Homo_sapiens.GRCh38.82.gtf.gz' protein_coding_gene_file = 'protein_coding_genes_human.tsv' go_ann...
<SYSTEM_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 all required data Step2: Extract list of human protein-coding genes Step3: Parse human GO annotations Step4: Get information about a...
5,868
<ASSISTANT_TASK:> Python Code: %%capture --no-stderr !pip3 install kfp --upgrade import kfp.components as comp bigquery_query_op = comp.load_component_from_url( 'https://raw.githubusercontent.com/kubeflow/pipelines/01a23ae8672d3b18e88adf3036071496aca3552d/components/gcp/bigquery/query/component.yaml') help(bigquer...
<SYSTEM_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 component using KFP SDK Step2: Sample Step3: Set sample parameters Step4: Run the component as a single pipeline Step5: Compile the...
5,869
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib import rcParams import matplotlib.pyplot as plt import pandas as pd import nilmtk from nilmtk import DataSet, MeterGroup plt.style.use('ggplot') rcParams['figure.figsize'] = (13, 10) redd = DataSet('/data/redd.h5') elec = redd.buildings[1].elec elec ele...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Note that there are two nested MeterGroups Step2: Putting these meters into a MeterGroup allows us to easily sum together the power demand reco...
5,870
<ASSISTANT_TASK:> Python Code: from threeML import * from threeML.analysis_results import * from threeML.io.progress_bar import progress_bar from jupyterthemes import jtplot %matplotlib inline jtplot.style(context="talk", fscale=1, ticks=True, grid=False) import matplotlib.pyplot as plt plt.style.use("mike") import ast...
<SYSTEM_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 take a look at what we can do with an AR. First, we will simulate some data. Step2: MLE Results Step3: We can get our errors as always, ...
5,871
<ASSISTANT_TASK:> Python Code: import DBELA from rmtk.vulnerability.common import utils %matplotlib inline building_model_file = "../../../../../rmtk_data/DBELA/bare_frames.csv" damage_model_file = "../../../../../rmtk_data/damage_model_dbela_low_code.csv" no_assets = 100 building_class_model = DBELA.read_building_c...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load geometric and material properties Step2: Number of samples Step3: Generate the capacity curves Step4: Plot the capacity curves Step5: I...
5,872
<ASSISTANT_TASK:> Python Code: recent_grads = pd.read_csv('recent-grads.csv') recent_grads.head() recent_grads.tail() recent_grads.describe() recent_grads.shape recent_grads.shape[0] - recent_grads.dropna().shape[0] from pandas.tools.plotting import scatter_matrix scatter_matrix(recent_grads[['ShareWomen', 'Unemploym...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: how many rows contain null values? Step2: Data Visualization Step3: Let's compare the share of men and women in engineering major. Step4: fro...
5,873
<ASSISTANT_TASK:> Python Code: %matplotlib inline import inspect, sys # check pydov path import pydov from pydov.search.interpretaties import GeotechnischeCoderingSearch itp = GeotechnischeCoderingSearch() itp.get_description() fields = itp.get_fields() # print available fields for f in fields.values(): print(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: Get information about the datatype 'Geotecnische codering' Step2: A description is provided for the 'Geotechnische codering' datatype Step3: T...
5,874
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np from scipy.integrate import odeint from IPython.html.widgets import interact, fixed def lorentz_derivs(yvec, t, sigma, rho, beta): Compute the the derivatives for the Lorentz system at yvec(t). # YOUR CODE HERE...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: Lorenz system Step4: Write a function solve_lorenz that solves the Lorenz system above for a particular initial condition $[x(0),y(0),z(0)]$. Y...
5,875
<ASSISTANT_TASK:> Python Code: import datapot as dp datapot = dp.DataPot() from datapot.utils import csv_to_jsonlines csv_to_jsonlines('../data/transactions.csv', '../data/transactions.jsonlines') ftr = open('../data/transactions.jsonlines') datapot.detect(ftr, limit=100) datapot.fit(ftr) datapot datapot.remove_trans...
<SYSTEM_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 call the fit method. It automatically finds appropriate transformers for the fields of jsonlines file. The parameter 'limit' means how man...
5,876
<ASSISTANT_TASK:> Python Code: import pandas as pd df = pd.DataFrame([["A", "Z-Y"], ["B", "X"], ["C", "W-U-V"]], index=[1,2,3], columns=['var1', 'var2']) def g(df): return df.join(pd.DataFrame(df.var2.str.split('-', expand=True).stack().reset_index(level=1, drop=True),columns=['var2 '])).\ drop('var2',1).re...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
5,877
<ASSISTANT_TASK:> Python Code: import string import os import time import pickle import json import re import wikipedia import nltk import numpy as np from nltk.corpus import stopwords from nltk.stem.porter import PorterStemmer from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.manifold import TSN...
<SYSTEM_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 example, we are going to cluster all of the links found in the Wikipedia page "Vital articles." First, we will open the page in main, th...
5,878
<ASSISTANT_TASK:> Python Code: import sys def something_dangerous(x): print("computing reciprocal of", x) return 1 / x try: for x in [2, 1, 0, -1]: print("1/{} = {}".format(x, something_dangerous(x))) except ArithmeticError as error: print("Something went terribly wrong:", error) input...
<SYSTEM_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 shows how exceptions are raised and caught, but this approach is somewhat limited. Suppose now, that we weren't expecting this expected une...
5,879
<ASSISTANT_TASK:> Python Code: %load_ext sql %sql sqlite:// %%sql drop table if exists product; create table product( pname varchar primary key, -- имя продукта price money, -- цена продукта category varchar, -- категория manufacturer varchar 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: Давайте создадим таблицу, заполним ее и сделаем какой-нибудь запрос! Step2: Посмотрим на полученную таблицу. Step3: Немного SQL терминологии S...
5,880
<ASSISTANT_TASK:> Python Code: import tensorflow as tf import numpy as np import tensorflow_hub as hub import tensorflow_datasets as ds ## general checks print("Tensor Flow Version : {}".format(tf.__version__)) print("Eager Mode : {}".format(tf.executing_eagerly())) print("Hub Version : {}".format(hub.__version__)) pri...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: IMDB Movie Review Step2: Step 2 Step3: Step 3 Step4: Step 4
5,881
<ASSISTANT_TASK:> Python Code: !pip install git+https://github.com/google/starthinker from starthinker.util.configuration import Configuration CONFIG = Configuration( project="", client={}, service={}, user="/content/user.json", verbose=True ) FIELDS = { 'auth_read':'user', # Credentials used for reading...
<SYSTEM_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. Set Configuration Step2: 3. Enter BigQuery Query to Sheet Recipe Parameters Step3: 4. Execute BigQuery Query to Sheet
5,882
<ASSISTANT_TASK:> Python Code: import rebound sim = rebound.Simulation() sim.add(m=1) sim.add(m=0.1, e=0.041, a=0.4, inc=0.2, f=0.43, Omega=0.82, omega=2.98) sim.add(m=1e-3, e=0.24, a=1.0, pomega=2.14) sim.add(m=1e-3, e=0.24, a=1.5, omega=1.14, l=2.1) sim.add(a=-2.7, e=1.4, f=-1.5,omega=-0.7) # hyperbolic orbit %matpl...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: To plot these initial orbits in the $xy$-plane, we can simply call the OrbitPlot function and give it the simulation as an argument. Step2: Not...
5,883
<ASSISTANT_TASK:> Python Code: %matplotlib inline from pydov.types.fields import XmlField, XsdType from pydov.types.abstract import AbstractDovSubType from pydov.types.sondering import Sondering class Techniek(AbstractDovSubType): rootpath = './/sondering/sondeonderzoek/penetratietest/technieken' fields ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: While performing CPT measurements, different techniques can be used. Since these can have an impact on the results, it can be interesting to dow...
5,884
<ASSISTANT_TASK:> Python Code: # This is regular Python comment inside Jupyter "Code" cell. # You can easily run "Hello world" in the "Code" cell (focus on the cell and press Shift+Enter): print("Hello world!") %%bash echo "Current directory is: "; pwd echo "List of files in the current directory is: "; ls # Module ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: There are also other types of cells, for example, "Markdown". Double click this cell to view raw Markdown markup content. Step2: If you are not...
5,885
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np from sklearn import preprocessing from sklearn.model_selection import train_test_split from sklearn.model_selection import cross_val_score from sklearn.feature_selection import RFE from sklearn.svm import SVR from sklearn.svm import LinearSVC from sk...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Columns Interested Step2: Decriptive Analyss Step3: Fig 1a shows the sorted issued loan amounts from low to high.<br/> Step4: Fig 2a and Fig ...
5,886
<ASSISTANT_TASK:> Python Code: %matplotlib inline %config InlineBackend.figure_format = 'svg' import numpy as np from exact_solvers import acoustics, acoustics_demos from IPython.display import IFrame, HTML, Image %matplotlib inline %config InlineBackend.figure_format = 'svg' import numpy as np from exact_solvers 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: In this chapter we consider our first system of hyperbolic conservation laws. We study the acoustics equations that were introduced briefly in ...
5,887
<ASSISTANT_TASK:> Python Code: %%file my_first_test.py def f(a): return a def test_a(): assert f(1) == 1 !ls *.py !py.test !py.test -q !py.test -v %%file my_second_test.py def f(a): return a def test_a(): assert f(1) == 1 def test_b(): assert f(2) == 1 def test_c(): assert f(3) == 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 file has been saved in the current directory Step2: Launching pytest is as easy as move to the right directory and using the command line S...
5,888
<ASSISTANT_TASK:> Python Code: # Get ftp://ftp.ncbi.nlm.nih.gov/gene/DATA/gene2go.gz from goatools.base import download_ncbi_associations gene2go = download_ncbi_associations() from goatools.associations import read_ncbi_gene2go geneid2gos_human = read_ncbi_gene2go(gene2go, taxids=[9606]) geneid2gos_fly = read_ncbi_ge...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 2. Read associations Step2: 2b. Or you can read 'gene2go' once and load all species... Step3: 3. Import protein-coding information for human a...
5,889
<ASSISTANT_TASK:> Python Code: %%file consumer.py import sys import socket from collections import Counter HOST = sys.argv[1] PORT = int(sys.argv[2]) s = socket.socket() s.bind((HOST, PORT)) s.listen(4) connection, address = s.accept() c = Counter() while True: line = connection.recv(64) words = line.split() ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Producer sends data to server for processing Step2: Using Spark Streaming Step3: Monitor a directory for new or renamed files Step4: Usage St...
5,890
<ASSISTANT_TASK:> Python Code: %matplotlib inline from load_environment import * # python file with imports and basics to set up this computing environment f0 = np.average(data[:32], axis=0) plt.imshow(f0); plt.title("Average of First 32 Frames"); plt.show() plt.subplot(121) f41 = data[41] plt.imshow(f41); plt.title(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: First we will take a look at the fluorescence "base line" Step2: Now compare the fluorescence of a regular signal to its relative fluorescence ...
5,891
<ASSISTANT_TASK:> Python Code: from jyquickhelper import add_notebook_menu add_notebook_menu() %matplotlib inline try: import mkl mkl.set_num_threads(1) except ModuleNotFoundError as e: print('mkl not found', e) import os os.environ['MKL_NUM_THREADS']='1' # int nb = 0; # for(auto it = values.begin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: numpy is multithreaded. For an accurate comparison, this needs to be disabled. This can be done as follows or by setting environment variable MK...
5,892
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pandas as pd import matplotlib.pyplot as plt import seaborn as sns plt.rcParams['figure.figsize'] = (20.0, 10.0) df = pd.read_csv('../../../datasets/movie_metadata.csv') df.head() # split each movie's genre list, then form a set from the unwrapped list of all ge...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: For the bar plot, let's look at the number of movies in each category, allowing each movie to be counted more than once. Step2: Basic plot Step...
5,893
<ASSISTANT_TASK:> Python Code: from __future__ import division import numpy as np from scipy.sparse import diags from scipy.sparse.linalg import svds, eigs import matplotlib.pyplot as plt %matplotlib notebook def pseudo_spec(x, y, mat_A): Compute the pseudospectra of `mat_A` around the point $x + iy ps_spec = n...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: Pseudospectra of matrices Step3: 1. Jordan block Step4: 2. Limacon Step5: 3. Grcar matrix Step6: 4. Wilkinson matrix
5,894
<ASSISTANT_TASK:> Python Code: from sklearn.model_selection import train_test_split import seaborn as sns import os import shutil import pandas as pd %matplotlib inline df = pd.read_csv('list.txt', sep=' ') df.ix[2000:2005] train_cat = df[df['SPECIES'] == 1] train_dog = df[df['SPECIES'] == 2] x = ['cat', 'dog'] y = [l...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Visualize the size of the original train dataset. Step2: Shuffle and split the train filenames Step3: Visualize the size of the processed trai...
5,895
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'miroc', 'nicam16-7s', 'atmos') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", "em...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
5,896
<ASSISTANT_TASK:> Python Code: label_map = list('abcdefghij') fig,axes = pl.subplots(3,3,figsize=(5,5),sharex=True,sharey=True) with h5py.File(cache_file, 'r') as f: for i in range(9): ax = axes.flat[i] idx = np.random.randint(f['test']['images'].shape[0]) ax.imshow(f['test']['image...
<SYSTEM_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 2 Step2: Problem 3 Step3: Problem 4 Step4: OK, so there are about 50000 in each class in the training set Step5: And about 1870 in e...
5,897
<ASSISTANT_TASK:> Python Code: from pyspark.sql import SQLContext sqlContext = SQLContext(sc) import pandas as pd from sklearn.datasets import load_iris data = pd.DataFrame(data=load_iris().data, columns=['sepal_length', 'sepal_width', 'petal_length', 'petal_width']) data.head() from sklearn.preprocessing import Binar...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Initial example Step2: Spark ML Step3: Load Newsgroup Data Step4: Spark ML Step5: Train-Test Split Step6: Spark Step7: Feature engineering...
5,898
<ASSISTANT_TASK:> Python Code: import numpy as np from scipy.special import binom import matplotlib.pylab as plt from scipy.misc import factorial as fact %matplotlib inline def binomial(p, n, k): return binom(n, k) * p ** k * (1 - p) ** (n-k) p = 4. / 100 np.sum(binomial(p, 150, np.arange(5))) np.sum(binomial(p,...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Exercise 1. Step2: b. Step3: Exercise 2. Step4: Exercise 3. Step5: X would be -30 when the sample $\omega$ has no 6s, 50 when has one, 75 wh...
5,899
<ASSISTANT_TASK:> Python Code: num_friends_good = [49,41,40,25,21,21,19,19,18,18,16,15,15,15,15,14,14,13,13,13,13,12,12,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,8,8,8,8,8,8,8,8,8,8,8,8,8,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Of course, we need a better way to figure out how well we’ve fit the data than staring at the graph. Step2: Doing Statistics with statsmodels