Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
7,500
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt from sklearn import svm %matplotlib inline mu,sigma=3,0.1 x=np.random.normal(mu,sigma,1000) y=np.random.normal(mu,sigma,1000) x_0=np.random.normal(2,sigma,1000) y_0=np.random.normal(2,sigma,1000) X_train_normal=np.ndarray(shape=(2000,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: Use the np.random module to generate a normal distribution of 1,000 data points in two dimensions (e.g. x, y) - choose whatever mean and sigma^2...
7,501
<ASSISTANT_TASK:> Python Code: from IPython.display import Image # create a new git repository called gitdemo: !git init gitdemo !git clone https://github.com/qutip/qutip !git clone gitdemo gitdemo2 !git status %%file README A file with information about the gitdemo repository. !git status !git add README !git 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: In any software development, one of the most important tools are revision control software (RCS). Step2: If we want to fork or clone an existin...
7,502
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib import pyplot as plt import numpy as np from IPython.html.widgets import interact, interactive, fixed from IPython.display import display, SVG s = <svg width="100" height="100"> <circle cx="50" cy="50" r="20" fill="aquamarine" /> </svg> SVG(s) def 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: Step2: Interact with SVG display Step4: Write a function named draw_circle that draws a circle using SVG. Your function should take the parameters of ...
7,503
<ASSISTANT_TASK:> Python Code: #nltk.download() mycorpus = nltk.corpus.reuters n_docs = 500000 filenames = mycorpus.fileids() fn_train = [f for f in filenames if f[0:5]=='train'] corpus_text = [mycorpus.raw(f) for f in fn_train] # Reduced dataset: n_docs = min(n_docs, len(corpus_text)) corpus_text = [corpus_text[n] fo...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Para evitar problemas de sobrecarga de memoria, o de tiempo de procesado, puede reducir el tamaño el corpus, modificando el valor de la variable...
7,504
<ASSISTANT_TASK:> Python Code: import gzip import pickle from os import path from collections import defaultdict from numpy import sign Load buzz data as a dictionary. You can give parameter for data so that you will get what you need only. def load_buzz(root='../data', data=['train', 'test', 'questions'], format='pklz...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Model10 Step2: Feature functions(private) Step3: Feature function(public) Step4: Utility functions Step5: GMM Step7: B. Modeling Step8: Tr...
7,505
<ASSISTANT_TASK:> Python Code: %matplotlib inline from matplotlib import pyplot as plt import os import numpy as np os.environ['DES_BACKEND'] = 'numpy' import desolver as de import desolver.backend as D D.set_float_fmt('gdual_real128') # Definition of the controller in terms of some weights parameters def u(state, wei...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Controller representation and “simulator” Step2: Numerical Integration - Runge-Kutta 8(7) Dormand-Prince Method Step3: We integrate the system...
7,506
<ASSISTANT_TASK:> Python Code: #hide ! pip install -U git+git://github.com/fastai/fastcore@master ! pip install -U git+git://github.com/fastai/nbdev@master ! pip install -U numpy from fastcore.foundation import * from fastcore.meta import * from fastcore.utils import * from fastcore.test import * from nbdev.showdoc imp...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Making **kwargs transparent Step2: Without reading the source code, it might be hard for me to know that foo also accepts and additional parame...
7,507
<ASSISTANT_TASK:> Python Code: def write_answer_to_file(answer, filename): with open(filename, 'w') as f_out: f_out.write(str(round(answer, 3))) import pandas as pd adver_data = pd.read_csv('advertising.csv') # Ваш код здесь adver_data.head(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: 1. Загрузите данные из файла advertising.csv в объект pandas DataFrame. Источник данных. Step2: Посмотрите на первые 5 записей и на статистику ...
7,508
<ASSISTANT_TASK:> Python Code: import pandas as pd def get_pdb_divide_params(frequency, F_BUS=int(48e6)): mult_factor = np.array([1, 10, 20, 40]) prescaler = np.arange(8) clock_divide = (pd.DataFrame([[i, m, p, m * (1 << p)] for i, m in enumerate(mult_factor) for p in presc...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Overview Step2: Configure ADC sample rate, etc. Step3: Pseudo-code to set DMA channel $i$ to be triggered by ADC0 conversion complete. Step4: ...
7,509
<ASSISTANT_TASK:> Python Code: import numpy as np import scipy.stats as sps import matplotlib.pyplot as plt import pandas as pd %matplotlib inline from scipy.linalg import inv from numpy.linalg import norm class LinearRegression: def __init__(self): super() def fit(self, X, Y, alpha=0.95): ...
<SYSTEM_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: Загрузите данные о потреблении мороженного в зависимости от температуры воздуха и цены (файл ice_cream.txt). Step3...
7,510
<ASSISTANT_TASK:> Python Code: from wanderer import wanderer def clipOutlier2D(arr2D, nSig=10): arr2D = arr2D.copy() medArr2D = median(arr2D,axis=0) sclArr2D = np.sqrt(((scale.mad(arr2D)**2.).sum())) outliers = abs(arr2D - medArr2D) > nSig*sclArr2D inliers = abs(arr2D - medArr2D) <= nSig*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: As an example, Spitzer data is expected to be store in the directory structure Step2: Load Wanderer Class Step3: Load Stored Instance from Sav...
7,511
<ASSISTANT_TASK:> Python Code: %pylab notebook r1 = 0.641 # Stator resistance x1 = 1.106 # Stator reactance r2 = 0.332 # Rotor resistance x2 = 0.464 # Rotor reactance xm = 26.3 # Magnetization branch reactance v_phase = 460 / sqrt(3) #...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: First, initialize the values needed in this program. Step2: Calculate the Thevenin voltage and impedance from Equations 7-41a Step3: Now calcu...
7,512
<ASSISTANT_TASK:> Python Code: from IPython.display import IFrame IFrame('https://plot.ly/~empet/13475/', width=800, height=350) IFrame('https://plot.ly/~empet/13503/', width=600, height=475) IFrame('https://plot.ly/~empet/13497/', width=550, height=550) IFrame('https://plot.ly/~empet/13479/', width=825, height=...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: If $T$ is the set of points defining a $k$-simplex, then any proper subset of $T$ defines an $\ell$-simplex, $\ell<k$. Step2: Triangular meshes...
7,513
<ASSISTANT_TASK:> Python Code: import numpy as np import mne from mne.datasets import sample data_path = sample.data_path() raw_fname = data_path + '/MEG/sample/sample_audvis_raw.fif' proj_fname = data_path + '/MEG/sample/sample_audvis_eog_proj.fif' tmin, tmax = 0, 20 # use the first 20s of data # Setup for reading th...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Removing power-line noise with notch filtering Step2: Removing power-line noise with low-pass filtering Step3: High-pass filtering to remove s...
7,514
<ASSISTANT_TASK:> Python Code: from __future__ import division from __future__ import print_function %matplotlib inline import matplotlib.pyplot as plt import numpy as np from math import sin, pi, tan def lbf2N(w): return w*4.448 def deg2rad(d): return d*pi/180 def in2mm(i): return i*25.4 def Nm2lbfin(nm):...
<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: R2 isn't expected to do a lot of up hill climbing. For reference, power wheelchair ramp slope is 7.2 degrees to bound what kind of slope R2 coul...
7,515
<ASSISTANT_TASK:> Python Code: from google.cloud import bigquery compute_alpha = #standardSQL SELECT SAFE_DIVIDE( SUM(arrival_delay * departure_delay), SUM(departure_delay * departure_delay)) AS alpha FROM ( SELECT RAND() AS splitfield, arrival_delay, departure_delay FROM ...
<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: <h3> Create a simple machine learning model </h3> Step4: <h3> What is wrong with calculating RMSE on the training and test data as follows? </h...
7,516
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np %pylab inline pylab.style.use('ggplot') url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/balance-scale/balance-scale.data' balance_df = pd.read_csv(url, header=None) balance_df.columns = ['class_name', 'left_weight', 'left_distance', ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Check for Class Imbalance Step2: Feature Importances
7,517
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np from scipy.interpolate import interp1d x = np.linspace(0, 10, num=11, endpoint=True) y = np.cos(-x**2/9.0) f = interp1d(x, y, kind='linear') # default if kind=None f2 = interp1d(x, y, kind='cubic') f3 = interp1d(x, y, ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 1D data Step2: nD data Step3: Splines Step4: 2D splines are also available
7,518
<ASSISTANT_TASK:> Python Code: Sudoku = [ ["*", 3 , 9 , "*", "*", "*", "*", "*", 7 ], ["*", "*", "*", 7 , "*", "*", 4 , 9 , 2 ], ["*", "*", "*", "*", 6 , 5 , "*", 8 , 3 ], ["*", "*", "*", 6 , "*", 3 , 2 , 7 , "*"], ["*", "*", "*", "*", 4 , "*", 8 , "*", "*"]...
<SYSTEM_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 sudoku_csp(Puzzle) takes a given sudoku Puzzle as its argument and returns a CSP that encodes the given sudoku as a CSP. The varia...
7,519
<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: 사용자가 존재하는 코드를 최소한으로 변경하면서 tf.distribute 전략을 사용할 수 있도록 tf.data.Dataset 인스턴스를 배포하고 분산 데이터세트 객체를 반환하는 두 개의 API가 도입되었습니다. 그런 다음 사용자는 이...
7,520
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import os from pandas import DataFrame from pandas import read_csv from numpy import mean from numpy import std import matplotlib.pyplot as plt import matplotlib %matplotlib inline matplotlib.style.use('ggplot') import seaborn as sns results = read_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: Basic Statistics results suggest Step2: Dotplots with grouping by Subject, Age and Sex
7,521
<ASSISTANT_TASK:> Python Code: %matplotlib inline import numpy as np import matplotlib.pyplot as plt u=np.random.random() print u v=np.random.random(5) print v A=np.random.random((2,3)) print A x=np.random.random(2000) histo=plt.hist(x, bins=15, normed=True, color='g') plt.plot([0,1], [1,1], 'r')# graficul densitatii ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Seed-ul se seteaza in perioada de debugging a codului, pentru ca avandu-l setat in orice rulare se genereaza acelasi sir de numere. Step2: Fun...
7,522
<ASSISTANT_TASK:> Python Code: from __future__ import print_function import numpy as np import matplotlib.pylab as plt import padasip as pa %matplotlib inline plt.style.use('ggplot') # nicer plots np.random.seed(52102) # always use the same random seed to make results comparable %config InlineBackend.print_figure_kwar...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Construction of Input Vectors (Input Matrix) from a Time Series Step2: If the series is only an input of the adaptive filter, the input matrix ...
7,523
<ASSISTANT_TASK:> Python Code: fname = io.download_occultation_times(outdir='../data/') print(fname) tlefile = io.download_tle(outdir='../data') print(tlefile) times, line1, line2 = io.read_tle_file(tlefile) tstart = '2021-01-08T10:00:00' tend = '2021-01-08T17:00:00' orbits = planning.sunlight_periods(fname, tstart, ...
<SYSTEM_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 the NuSTAR TLE archive. Step2: Here is where we define the observing window that we want to use.
7,524
<ASSISTANT_TASK:> Python Code: HOME_DIR = 'd:/larc_projects/job_analytics/'; DATA_DIR = HOME_DIR + 'data/clean/' RES_DIR = HOME_DIR + 'results/' skill_df = pd.read_csv(DATA_DIR + 'skill_index.csv') doc_skill = buildDocSkillMat(jd_docs, skill_df, folder=DATA_DIR) with(open(DATA_DIR + 'doc_skill.mtx', 'w')) as f: mm...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Build feature matrix Step2: Get skills in each JD Step3: Extract features of new documents
7,525
<ASSISTANT_TASK:> Python Code: response = requests.get('https://api.spotify.com/v1/search?q=lil&type=artist&?country=US&limit=50') data = response.json() type(data) data.keys() data['artists'].keys() artists = data['artists']['items'] for artist in artists: print(artist['name'], artist['popularity']) for artist in...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 2) What genres are most represented in the search results? Edit your previous printout to also display a list of their genres in the format "GEN...
7,526
<ASSISTANT_TASK:> Python Code: data_id = '17d' ph_sel_name = "None" data_id = "17d" from fretbursts import * sns = init_notebook() import os import pandas as pd from IPython.display import display, Math import lmfit print('lmfit version:', lmfit.__version__) figure_size = (5, 4) default_figure = lambda: plt.subplots(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: Multi-spot vs usALEX FRET histogram comparison Step2: 8-spot paper plot style Step3: Data files Step4: Check that the folder exists Step5: L...
7,527
<ASSISTANT_TASK:> Python Code: a = 243748.890365 b = 501771.703058 - 243748.890365 c = 752464.582 - 501771.703058 d = 981305.261623 - 752464.582 e = 1.175989e+06 - 981305.261623 ghi_CaseA_Boulder = [a, b, c, d, e] ghi_CaseA_Boulder epwfile = r'C:\Users\sayala\Documents\GitHub\internStuff\weatherFiles\USA_CO_Boulder-Bro...
<SYSTEM_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. Gencumsky Step2: C. Option Step3: <a id='step2'></a> Step4: GencumSky1axis, looping over tracker_angles
7,528
<ASSISTANT_TASK:> Python Code: import sklearn import numpy import chaospy samples = numpy.linspace(0, 5, 50) numpy.random.seed(1000) noise = chaospy.Normal(0, 0.1).sample(50) evals = numpy.sin(samples) + noise from matplotlib import pyplot pyplot.rc("figure", figsize=[15, 6]) pyplot.scatter(samples, evals) pyplot.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: As en example to follow, consider the following artificial case Step2: Least squares regression Step3: Least squares regression is also suppor...
7,529
<ASSISTANT_TASK:> Python Code: # access yelp.csv using a relative path import pandas as pd yelp = pd.read_csv('/GA-SEA-DAT2/data/yelp.csv') yelp.head(1) # read the data from yelp.json into a list of rows # each row is decoded into a dictionary named "data" using using json.loads() import json import pandas as pd with ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Task 1 (Bonus) Step2: Task 2 Step3: Task 3 Step4: Task 4 Step5: Task 5 Step6: Task 6 Step7: Task 7 (Bonus) Step8: Task 8 (Bonus)
7,530
<ASSISTANT_TASK:> Python Code: import random with open('rt-polarity.neg.utf8', 'r') as f: negative_list = ['-1 '+i for i in f] with open("rt-polarity.pos.utf8", "r") as f: positive_list = ["+1"+i for i in f] #for sentence in temp: # positive_list.append('+1 '+"".join([i.encode('replace') for i in sentence])...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 71. ストップワード Step2: 72. 素性抽出 Step3: No.73 Step4: TfidfVectorizer.fit()の引数は単語"リスト"
7,531
<ASSISTANT_TASK:> Python Code: import numpy as np x = np.array([-2+1j, -1.4, -1.1, 0, 1.2, 2.2+2j, 3.1, 4.4, 8.3, 9.9, 10+0j, 14, 16.2]) result = x[x.imag !=0] <END_TASK>
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description:
7,532
<ASSISTANT_TASK:> Python Code: import numpy as np import holoviews as hv %reload_ext holoviews.ipython x,y = np.mgrid[-50:51, -50:51] * 0.1 image = hv.Image(np.sin(x**2+y**2), group="Function", label="Sine") coords = [(0.1*i, np.sin(0.1*i)) for i in range(100)] curve = hv.Curve(coords) curves = {phase: hv.Curve([(0.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: Rendering and saving objects from Python <a id='python-saving'></a> Step2: We could instead have used the default Store.renderer, but that woul...
7,533
<ASSISTANT_TASK:> Python Code: %xmode Minimal from larray import * from larray import __version__ __version__ s = 1 + 2 # In the interactive mode, there is no need to use the print() function # to display the content of the variable 's'. # Simply typing 's' is enough s # In the interactive mode, there is no need 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: To know the version of the LArray library installed on your machine, type Step2: <div class="alert alert-warning"> Step3: Create an array Step...
7,534
<ASSISTANT_TASK:> Python Code: # Question 1 # Question 2 # Question 3.1 # Question 3.2 # Question 3.3 # Initialize parameters for the simulation (A, s, T, delta, alpha, g, n, K0, A0, L0) # Initialize a variable called tfp as a (T+1)x1 array of zeros and set first value to A0 # Compute all subsequent tfp values by it...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Question 2 Step2: Question 3 Step3: Question 4 Step4: Question 5
7,535
<ASSISTANT_TASK:> Python Code: import pyspark.sql.functions as F import pyspark.sql.types as T from pyspark.sql import SparkSession # Initialize PySpark with MongoDB and Elastic support spark = ( SparkSession.builder.appName("Exploring Data with Reports") # Load support for MongoDB and Elasticsearch .config...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Extracting Airlines (Entities) Step2: Compound Records in RDDs Step3: Compound DataFrames in MongoDB Step4: Storing to MongoDB Step5: Verify...
7,536
<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 = { 'recipe_name':'', # Name of document to deploy 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: 2. Set Configuration Step2: 3. Enter CM360 Campaign Auditor Recipe Parameters Step3: 4. Execute CM360 Campaign Auditor
7,537
<ASSISTANT_TASK:> Python Code: # Author: Eric Larson <larson.eric.d@gmail.com> # # License: BSD-3-Clause import numpy as np import mne from mne.datasets import sample from mne.source_space import compute_distance_to_sensors from mne.source_estimate import SourceEstimate import matplotlib.pyplot as plt print(__doc__) da...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Compute sensitivity maps Step2: Show gain matrix a.k.a. leadfield matrix with sensitivity map Step3: Compare sensitivity map with distribution...
7,538
<ASSISTANT_TASK:> Python Code: import numpy as np import random import h5py import time from keras.models import Sequential from keras.layers import Dense, Flatten, BatchNormalization, Dropout, Input from keras.layers.convolutional import Conv1D, MaxPooling1D, AveragePooling1D from keras.optimizers import Adam from ker...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Hyper parameters for the model Step2: Build and compile model Step3: Load non-normalized spectra Step4: Spectra Normalization Step5: Plot th...
7,539
<ASSISTANT_TASK:> Python Code: from __future__ import print_function # Python 2/3 compatibility import numpy as np import pandas as pd from IPython.display import Image train_df = pd.read_csv("data/train.tsv", sep="\t") train_df.sample(10) from sklearn.model_selection import train_test_split X_train, X_valid, y_trai...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load Data Step2: Training process Step3: Vectorize Data (a.k.a. covert text to numbers) Step4: Model - Logistic Regression Step5: Model 2 - ...
7,540
<ASSISTANT_TASK:> Python Code: sc # Importation des packages import time from numpy import array # Répertoire courant ou répertoire accessible de tous les "workers" du cluster DATA_PATH="" # Chargement des fichiers import urllib.request f = urllib.request.urlretrieve("https://www.math.univ-toulouse.fr/~besse/Wikistat...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Gestion des données Step2: Conversion des données au format DataFrame Step3: Sous-échantillon d'apprentissage Step4: Méthode de classificatio...
7,541
<ASSISTANT_TASK:> Python Code: # Image from https://vene.ro/images/wmd-obama.png import matplotlib.pyplot as plt import matplotlib.image as mpimg img = mpimg.imread('wmd-obama.png') imgplot = plt.imshow(img) plt.axis('off') plt.show() # Initialize logging. import logging logging.basicConfig(format='%(asctime)s : %(lev...
<SYSTEM_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 method was introduced in the article "From Word Embeddings To Document Step2: These sentences have very similar content, and as such the W...
7,542
<ASSISTANT_TASK:> Python Code: for i in locations: print i if i not in sch:sch[i]={} #march 11-24 = 2 weeks for d in range (11,25): if d not in sch[i]: try: url=airportialinks[i] full=url+'arrivals/201703'+str(d) m=requests.get(full).co...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: sch checks out with source Step2: mdf checks out with source
7,543
<ASSISTANT_TASK:> Python Code: import numpy as np from os.path import basename, exists def download(url): filename = basename(url) if not exists(filename): from urllib.request import urlretrieve local, _ = urlretrieve(url, filename) print("Downloaded " + local) download("https://github.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: Examples Step2: And compute the distribution of birth weight for first babies and others. Step3: We can plot the PMFs on the same scale, but i...
7,544
<ASSISTANT_TASK:> Python Code: # useful math functions from math import pi, cos, acos, sqrt # importing the QISKit from qiskit import Aer, IBMQ from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, execute # import basic plot tools from qiskit.tools.visualization import plot_histogram # useful addition...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step3: We prepare the controlled-Hadamard and controlled-u3 gates that are required in the encoding as below. Step4: Encoding 7 bits into 2 qubits wit...
7,545
<ASSISTANT_TASK:> Python Code: from IPython.display import Image # Add your filename and uncomment the following line: Image(filename='TheoryAndPracticeEx01graph.png') <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: Graphical excellence and integrity
7,546
<ASSISTANT_TASK:> Python Code: from PIL import Image import numpy as np %matplotlib inline import matplotlib import matplotlib.pyplot as plt from sklearn import datasets, tree matplotlib.style.use('bmh') matplotlib.rcParams['figure.figsize']=(10,7) # windows only hack for graphviz path import os for path in os.envir...
<SYSTEM_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: Q Step3: Q
7,547
<ASSISTANT_TASK:> Python Code: import os # The Vertex AI Workbench Notebook product has specific requirements IS_WORKBENCH_NOTEBOOK = os.getenv("DL_ANACONDA_HOME") IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists( "/opt/deeplearning/metadata/env_version" ) # Vertex AI Notebook requires dependencies to be install...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Restart the kernel Step2: Before you begin Step3: Get your project number Step4: Region Step5: Timestamp Step6: Authenticate your Google Cl...
7,548
<ASSISTANT_TASK:> Python Code: import matplotlib as mpl % matplotlib inline import pandas as pd import seaborn as sns from IPython.display import IFrame import elviz_utils reduced = pd.read_csv('../results/reduced_data--all_phylogeny_remains.csv') sample_info = elviz_utils.read_sample_info('../') sample_info.head() I...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Load Data Step2: Look into samples that have "too high" of Burkold. Step3: Link to Elviz Data for 55_HOW8 (High O2 Rep 1 week 8) Step4: Link ...
7,549
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pandas as pd # data package import matplotlib.pyplot as plt # graphics module import datetime as dt # date and time module import numpy as np # foundation for Pandas url = 'ht...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <a id=wants></a> Step2: Reminders Step3: Wants Step4: Comments. The problem here is that the columns include both the numbers (which we want ...
7,550
<ASSISTANT_TASK:> Python Code: import numpy as np def sigmoid(z): return 1/(1 + np.exp(-z)) assert(sigmoid(0) == 0.5) assert(sigmoid(10000) == 1.0) assert(sigmoid(-10000) == 0.0) plt.plot(np.arange(-10, 10, 0.5), [sigmoid(z) for z in np.arange(-10, 10, 0.5)]) plt.show() # Sebastian Raschka 2015 # mlxtend Machine 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: Step6: Cost Function and Gradient Step7: Iris example
7,551
<ASSISTANT_TASK:> Python Code: # YOUR ACTION REQUIRED: # Execute this cell first using <CTRL-ENTER> and then using <SHIFT-ENTER>. # Note the difference in which cell is selected after execution. print('Hello world!') # YOUR ACTION REQUIRED: # Execute only the first print statement by selecting the first line and press...
<SYSTEM_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 can also only execute one single statement in a cell. Step2: What to do if you get stuck Step3: Importing TensorFlow Step4: Running shell...
7,552
<ASSISTANT_TASK:> Python Code: %matplotlib inline import openmc uo2 = openmc.Material(1, "uo2") print(uo2) mat = openmc.Material() print(mat) help(uo2.add_nuclide) # Add nuclides to uo2 uo2.add_nuclide('U235', 0.03) uo2.add_nuclide('U238', 0.97) uo2.add_nuclide('O16', 2.0) uo2.set_density('g/cm3', 10.0) zirconium...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Defining Materials Step2: On the XML side, you have no choice but to supply an ID. However, in the Python API, if you don't give an ID, one wil...
7,553
<ASSISTANT_TASK:> Python Code: import pandas as pd wine = pd.read_csv("wine.csv") baseline = wine.Price.mean() print (baseline) baseline = wine.Price.mean() %matplotlib inline import matplotlib.pyplot as plt plt.scatter(wine.AGST, wine.Price) plt.hlines(baseline, 15, 18, color = 'red', label="Baseline") plt.legend(loc...
<SYSTEM_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 say the average is 7.07 Step2: As you can see, in this example the baseline never predicts the correct value, only a couple of times goes...
7,554
<ASSISTANT_TASK:> Python Code: import tensorflow as tf import numpy as np from tensorflow.examples.tutorials.mnist import input_data mnist_data = input_data.read_data_sets('/tmp/data', one_hot=True) ## Visualize a sample subset of data import matplotlib.pyplot as plt %matplotlib inline import numpy as np f,a = plt.sub...
<SYSTEM_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 a sample subset of data Step2: Side Note Step3: Tensorflow Session Step4: Evaluating the model
7,555
<ASSISTANT_TASK:> Python Code: #This notebook also uses the `(some) LaTeX environments for Jupyter` #https://github.com/ProfFan/latex_envs wich is part of the #jupyter_contrib_nbextensions package from myhdl import * from myhdlpeek import Peeker import numpy as np import pandas as pd import matplotlib.pyplot as plt %ma...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: \title{Logic Gate Primitives in myHDL} Step2: Table of Digital Gate Symbols commonly used Step3: Sympy Exspresion Step5: myHDL Module Step6: ...
7,556
<ASSISTANT_TASK:> Python Code: print('## Model structure summary\n') print(model) params = model.get_params() n_params = {p.name : p.get_value().size for p in params} total_params = sum(n_params.values()) print('\n## Number of parameters\n') print(' ' + '\n '.join(['{0} : {1} ({2:.1f}%)'.format(k, v, 100.*v/total_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: Step1: Train and valid set NLL trace Step2: Visualising first layer weights Step3: Learning rate Step4: Update norm monitoring
7,557
<ASSISTANT_TASK:> Python Code: 1000*(1/10**1.5) bins = np.arange(1,max(date)+1,7) H = pl.histogram(date,bins = bins) x = H[1][:-1] y = H[0] c = (y>0)*(x > 30.0) lx = np.log10(x[c] - min(x[c])+1) ly = np.log10(y[c]) B = binning(lx,ly,20) c = (B[0] >= -1)*(B[0] < 3.0)*(B[1] > 0.1) fit = S.linregress(B[0][c],B[1][c]) 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: Arrival of new vulnerabilities Step2: Arrival of New Researchers Step3: Researcher Arrival following rewards Step4: Inter-time between 2 awar...
7,558
<ASSISTANT_TASK:> Python Code: %matplotlib inline import pylab import numpy as np import pandas as pd from sklearn.svm import OneClassSVM from sklearn.covariance import EllipticEnvelope pylab.rcParams.update({'font.size': 14}) df = pd.read_csv("AnomalyData.csv") df.head() state_code = df["state_code"] data = df.loc[:...
<SYSTEM_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 CSV Step2: Save state_code to label outliers. "data" contains just quantitative variables. Step3: Univariate Outliers Step4: Get quantil...
7,559
<ASSISTANT_TASK:> Python Code: class A(): pass a = A() # create an instance of class A print (a) print (type(a)) class Human(object): name = '' age = 0 human1 = Human() # create instance of Human human1.name = 'Anton' # name him (add data to this object) human1.age = 39 # set ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Use class Step2: Definition of a class with attributes (properties) Step3: Definition of a class with constructor Step4: Create a Human insta...
7,560
<ASSISTANT_TASK:> Python Code: from poppy.creatures import PoppyTorso # Ecrivez votre code ci-dessous et éxecutez le. # Une correction est donnée à titre indicatif : poppy = PoppyTorso(simulator='vrep') # Ecrivez votre code ci-dessous et éxecutez le. # Une correction est donnée à titre indicatif : poppy.motors # 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: Ensuite, vous allez créer un objet s'appellant poppy et étant un robot de type PoppyTorso. Vous pouvez donner le nom que vous souhaitez à votre ...
7,561
<ASSISTANT_TASK:> Python Code: import requests from scrapy.http import TextResponse url = "https://www.fragrantica.com/designers/Dolce%26Gabbana.html" user_agent = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/58: .0.3029.110 Chrome/58.0.3029.110 Safari/537.36'} ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Once we have the response, which is a huge chunk of minimized html tags, we need to navigate through the DOM structure to get exactly the inform...
7,562
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd %matplotlib inline import matplotlib.pyplot as plt import seaborn as sns !pip install -U okpy from client.api.notebook import Notebook ok = Notebook('lab09.ok') scandals = pd.read_csv('scandals.csv') scandals.set_index('scandal_id', inplace=True) sc...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Today's lab has two topics Step3: The following cell defines a function for viewing timelines of events. Step4: Question 2 Step5: Question 3 ...
7,563
<ASSISTANT_TASK:> Python Code: import os import glob import time from SimpleCV import * import scipy import numpy as np import tensorflow as tf import collections import matplotlib.pyplot as plt import cv2 import imutils from skimage.transform import pyramid_gaussian import argparse import cv2 from scipy import ndimage...
<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: After importing the libraries we declare the functions that we need for the fish detection. As introduced above we need a slidding window and a ...
7,564
<ASSISTANT_TASK:> Python Code: import requests import numpy as np import matplotlib.pyplot as plt import matplotlib.cm as cm import time import os import getpass # Directive to matblotlib for creating interactive graphs # Use %matplotlib inline for just creating the plots %matplotlib notebook # Gaia Archive REST URL ga...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Log in to GACS Step2: Create a function for executing asynchronous queries Step3: Python Step4: Define a function for computing the absolute ...
7,565
<ASSISTANT_TASK:> Python Code: from sqlitedict import SqliteDict def harness(key, value): this tests what can be assigned in SqliteDict's keys and values mydict = SqliteDict(":memory:") mydict[key] = value from battle_tested import fuzz, success_map, crash_map fuzz(harness, keep_testing=True) # keep test...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Using battle_tested to feel out new libraries. Step2: Now, we import the tools we need from battle_tested and fuzz it. Step3: Now we can call ...
7,566
<ASSISTANT_TASK:> Python Code: from rmtk.vulnerability.model_generator.point_dispersion import point_dispersion as pd from rmtk.vulnerability.common import utils %matplotlib inline Sa_means = [0.40, 0.40, 0.40, 0.40] Sa_covs = [0.20, 0.20, 0.20, 0.20] Sd_means = [0.03, 0.05, 0.08, 0.1] Sd_covs = [0.20, 0.20, 0.20, ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Capacity curve generator Step2: Include additional information Step3: Save capacity curves
7,567
<ASSISTANT_TASK:> Python Code: a = int(input("Enter first integer: ")) b = int(input("Enter second integer: ")) print("Result is :", format((a/b), '.2f')) a = float(input("Enter first float: ")) b = float(input("Enter second float: ")) print("Result is :", format((a/b), '.6f')) inp = input("Enter a upper or lower cas...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: P2 Step2: P3 Step3: Development Problems Step4: D2
7,568
<ASSISTANT_TASK:> Python Code: #importar los paquetes que se van a usar import pandas as pd import pandas_datareader.data as web import numpy as np from sklearn.cluster import KMeans import datetime from datetime import datetime import scipy.stats as stats import scipy as sp import scipy.optimize as optimize import sci...
<SYSTEM_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. Uso de Pandas para descargar datos de precios de cierre Step2: Una vez cargados los paquetes, es necesario definir los tickers de las accion...
7,569
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd from sklearn.linear_model import SGDClassifier from sklearn.model_selection import GridSearchCV from sklearn.pipeline import Pipeline from sklearn.preprocessing import StandardScaler X, y = load_data() assert type(X) == np.ndarray assert type(y) == 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:
7,570
<ASSISTANT_TASK:> Python Code: path = get_file('nietzsche.txt', origin="https://s3.amazonaws.com/text-datasets/nietzsche.txt") text = open(path).read().lower() print('corpus length:', len(text)) !tail -n 25 {path} chars = sorted(list(set(text))) vocab_size = len(chars)+1 print('total chars:', vocab_size) chars.insert(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: Preprocess and create model Step2: Train
7,571
<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. ...
7,572
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import matplotlib as mpl import plotnine as p9 import matplotlib.pyplot as plt import itertools import warnings warnings.simplefilter("ignore") from sklearn import neighbors, preprocessing, impute, metrics, model_selection, linear_model, svm, 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: Step2: Classification 1 Step3: Evaluating a classifier Step4: Confusion matrix and classification metrics Step5: Comments
7,573
<ASSISTANT_TASK:> Python Code: from flexx import flx %gui asyncio flx.init_notebook() class MyComponent(flx.JsComponent): foo = flx.StringProp('', settable=True) @flx.reaction('foo') def on_foo(self, *events): if self.foo: window.alert('foo is ' + self.foo, + len(events)) m = M...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: In normal operation, one uses flx.launch() to fire up a browser (or desktop app) to run the JavaScript in. This is followed by flx.run() (or flx...
7,574
<ASSISTANT_TASK:> Python Code: df = pd.read_csv('../datasets/UCIrvineCrimeData.csv'); df = df.replace('?',np.NAN) features = [x for x in df.columns if x not in ['state', 'community', 'communityname', 'county' , 'ViolentCrimesPerPop']] df.isnull().sum() df.dropna() df.dr...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Find the number of missing values in every column Step2: Eliminating samples or features with missing values Step3: Similarly, we can drop col...
7,575
<ASSISTANT_TASK:> Python Code: import sqlite3 import pandas as pd pd.set_option('display.width', 500) pd.set_option('display.max_columns', 100) pd.set_option('display.notebook_repr_html', True) db = sqlite3.connect('L18DB_demo.sqlite') cursor = db.cursor() cursor.execute("DROP TABLE IF EXISTS candidates") cursor.exec...
<SYSTEM_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 will also use a basic a pandas feature to display tables in the database. Although this lecture isn't on pandas, I will still have you use i...
7,576
<ASSISTANT_TASK:> Python Code: from sklearn.feature_extraction.text import CountVectorizer corpus = [ 'This is the first document.', 'This is the second second document.', 'And the third one.', 'Is this the first document?', 'The last document?', ] vect = CountVectorizer() vect.fit(corpus) vect....
<SYSTEM_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: 토큰(token) Step3: n-그램 Step4: 빈도수 Step5: TF-IDF Step6: Hashing Trick Step7: 형태소 분석기 이용 Step8: 예
7,577
<ASSISTANT_TASK:> Python Code: import os import os.path as osp import random as rand from pathlib import Path import shutil as sh import warnings from PIL import Image warnings.filterwarnings("ignore") rand.seed(33) ## Inputs and Outputs input_dir = Path("input") outputs_dir = Path("_output") media_dir = input_dir / 'm...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Introduction to Weighted Ensemble Data Analysis in wepy Step2: Running the simulation Step3: First Simulation Step4: Second Simulation Step5:...
7,578
<ASSISTANT_TASK:> Python Code: '{} + {} = {}'.format(10, 10, 20) '{0} + {1} = {2}'.format(10, 10, 20) # esse é o padrão '{0} + {0} = {1}'.format(10, 20) '{1} + {0} = {2}'.format(30, 20, 10) # evite fazer isso para não causar confusão string = '{cidade} é muito bonito(a) durante o(a) {estação}' string.format(cidad...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Porém podemos especificar explicitamente as posições que queremos substituir Step2: Podemos repetir um único argumento Step3: Informar uma ord...
7,579
<ASSISTANT_TASK:> Python Code: from __future__ import division, print_function %matplotlib inline # path = "data/state/" path = "data/state/sample/" from importlib import reload # Python 3 import utils; reload(utils) from utils import * from IPython.display import FileLink batch_size=64 #batch_size=1 %cd data/state %...
<SYSTEM_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 sample Step2: Create batches Step3: Basic models Step4: As you can see below, this training is going nowhere... Step5: Let's first ch...
7,580
<ASSISTANT_TASK:> Python Code: # Authors: Eric Larson <larson.eric.d@gmail.com> # # License: BSD (3-clause) import os.path as op import numpy as np import matplotlib.pyplot as plt import mne from mne import find_events, fit_dipole from mne.datasets.brainstorm import bst_phantom_elekta from mne.io import read_raw_fif fr...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: The data were collected with an Elekta Neuromag VectorView system at 1000 Hz Step2: Data channel array consisted of 204 MEG planor gradiometers...
7,581
<ASSISTANT_TASK:> Python Code: 7 **4 s = 'Hi there Sam!' s.split() planet = "Earth" diameter = 12742 print("The diameter of {} is {} kilometers.".format(planet,diameter)) lst = [1,2,[3,4],[5,[100,200,['hello']],23,11],1,7] lst[3][1][2][0] d = {'k1':[1,2,3,{'tricky':['oh','man','inception',{'target':[1,2,3,'hello']}...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Split this string Step2: Given the variables Step3: Given this nested list, use indexing to grab the word "hello" Step4: Given this nest dict...
7,582
<ASSISTANT_TASK:> Python Code: import gzip import cPickle import numpy as np import theano import theano.tensor as T import lasagne # Load the pickle file for the MNIST dataset. dataset = 'data/mnist.pkl.gz' f = gzip.open(dataset, 'rb') train_set, dev_set, test_set = cPickle.load(f) f.close() #train_set contains 2 entr...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Build the MLP Step2: Create the Train Function Step3: Train the model
7,583
<ASSISTANT_TASK:> Python Code: %run db2odata.ipynb %run db2.ipynb %sql connect reset %sql connect to sample %sql -sampledata %sql SELECT * FROM EMPLOYEE %odata prompt %odata DROP TABLE EMPLOYEE s = %odata -e SELECT lastname, salary from employee where salary > 50000 s = %odata -e SELECT * FROM EMPLOYEE %odata 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: DB2 Extensions Step2: An Brief Introduction to OData Step3: If you connected to the SAMPLE database, you will have the EMPLOYEE and DEPARTMENT...
7,584
<ASSISTANT_TASK:> Python Code: # Author: Denis A. Engemann <denis.engemann@gmail.com> # Alexandre Gramfort <alexandre.gramfort@inria.fr> # Jean-Remi King <jeanremi.king@gmail.com> # Eric Larson <larson.eric.d@gmail.com> # # License: BSD-3-Clause import numpy as np import matplotlib.pyplot as plt...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Set parameters Step2: Compute inverse solution Step3: Decoding in sensor space using a logistic regression Step4: To investigate weights, we ...
7,585
<ASSISTANT_TASK:> Python Code: # Use the chown command to change the ownership of repository to user !sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst # The OS module in python provides functions for interacting with the operating system import os # TODO 1 PROJECT_ID = "cloud-training-demos" # Replac...
<SYSTEM_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 configure our environment. Be sure to change the PROJECT_ID variable in the below cell to your Project ID. This will be the project...
7,586
<ASSISTANT_TASK:> Python Code: import matplotlib.pyplot as plt import csv import os import pickle import skimage import numpy as np from sklearn.utils import shuffle import cv2 ######################### # Initialize constants ######################### training_file = 'data/train.p' validation_file='data/train.p' testin...
<SYSTEM_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: Include an exploratory visualization of the dataset Step3: Step 2 Step4: Model Architecture Step5: Train, Validate and Test th...
7,587
<ASSISTANT_TASK:> Python Code: mu = 0 std = 1 rv = sp.stats.norm(mu, std) rv xx = np.linspace(-5, 5, 100) plt.plot(xx, rv.pdf(xx)) plt.ylabel("p(x)") plt.title("pdf of normal distribution") plt.show() np.random.seed(0) x = rv.rvs(100) x sns.distplot(x, kde=False, fit=sp.stats.norm) plt.show() np.random.seed(0) x = n...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: pdf 메서드를 사용하면 확률 밀도 함수(pdf Step2: 시뮬레이션을 통해 샘플을 얻으려면 rvs 메서드를 사용한다. Step3: Q-Q 플롯 Step4: 정규 분포를 따르지 않는 데이터 샘플을 Q-Q 플롯으로 그리면 다음과 같이 직선이 아닌 휘어진...
7,588
<ASSISTANT_TASK:> Python Code: # Links via http://www.gapminder.org/data/ population_url = "http://spreadsheets.google.com/pub?key=phAwcNAVuyj0XOoBL_n5tAQ&output=xls" fertility_url = "http://spreadsheets.google.com/pub?key=phAwcNAVuyj0TAlJeCEzcGQ&output=xls" life_expectancy_url = "http://spreadsheets.google.com/pub?ke...
<SYSTEM_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 the Data Step2: Get the regions and color them Step4: Build the plot Step5: Embed in your own template Step6: To Do
7,589
<ASSISTANT_TASK:> Python Code: import numpy as np from pandas import date_range import bqplot.pyplot as plt from bqplot import ColorScale security_1 = np.cumsum(np.random.randn(150)) + 100.0 security_2 = np.cumsum(np.random.randn(150)) + 100.0 fig = plt.figure(title="Security 1") axes_options = {"x": {"label": "Index"...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Basic Line Chart Step2: We can explore the different attributes by changing each of them for the plot above Step3: In a similar way, we can al...
7,590
<ASSISTANT_TASK:> Python Code: import pandas as pd import getpass, os os.environ['PSQL_USER']='dengueadmin' os.environ['PSQL_HOST']='localhost' os.environ['PSQL_DB']='dengue' os.environ['PSQL_PASSWORD']=getpass.getpass("Enter the database password: ") os.chdir('..') from infodenguepredict.data.infodengue import get_tem...
<SYSTEM_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: Let's look at the tables Step3: Let's try to join the tables by date. To align them, we must downsample each one to a ...
7,591
<ASSISTANT_TASK:> Python Code: import dir_constants as dc from tqdm import tqdm_notebook def find_dupe_dates(group): return pd.to_datetime(group[group.duplicated('date')]['date'].values) def merge_dupe_dates(group): df_chunks = [] dupe_dates = find_dupe_dates(group) df_chunks.append(group[~group['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: There are loans that have multiple row entries per month (as in multiple pmts in same month) and there are also loans that don't have any entry ...
7,592
<ASSISTANT_TASK:> Python Code: import numpy as np import numpy.random as random mean = 3 std = 2 data = random.normal(loc=mean, scale=std, size=50000) print(len(data)) print(data.mean()) print(data.std()) %matplotlib inline import matplotlib.pyplot as plt import scipy.stats as stats def plot_normal(xs, mean, std, **kw...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: As you can see from the print statements we got 5000 points that have a mean very close to 3, and a standard deviation close to 2. Step2: But w...
7,593
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import kadro as kd %matplotlib inline np.random.seed(42) n = 20 df = pd.DataFrame({ 'a': np.random.randn(n), 'b': np.random.randn(n), 'c': ['foo' if x > 0.5 else 'bar' for x in np.random.rand(n)], 'd': ['fizz' if x > 0.6 else 'bo' 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: This is the data that we'll work with. We won't change the dataframe or it's api, rather we'll wrap it in an object that contains extra methods....
7,594
<ASSISTANT_TASK:> Python Code: from collections import Counter l = [1,2,2,2,2,3,3,3,1,2,1,12,3,2,32,1,21,1,223,1] Counter(l) Counter('aabsbsbsbhshhbbsbs') s = 'How many times does each word show up in this sentence word times each each word' words = s.split() Counter(words) # Methods with Counter() c = Counter(words...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Counter() with lists Step2: Counter with strings Step3: Counter with words in a sentence Step4: Common patterns when using the Counter() obje...
7,595
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE from urllib.request import urlretrieve from os.path import isfile, isdir from tqdm import tqdm import problem_unittests as tests import tarfile cifar10_dataset_folder_path = 'cifar-10-batches-py' class DLProgress(tqdm): last_b...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Image Classification Step2: Explore the Data Step5: Implement Preprocess Functions Step8: One-hot encode Step10: Randomize Data Step12: Che...
7,596
<ASSISTANT_TASK:> Python Code: import nengo import numpy as np import cPickle import matplotlib.pyplot as plt from matplotlib import pylab import matplotlib.animation as animation from scipy import linalg %matplotlib inline import scipy.ndimage #Weight matrices generated by the neural network after training #Maps 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: Step1: Load the weight matrices from the training Step2: Visualize the digit from one hot representation through the activity weight matrix to the ima...
7,597
<ASSISTANT_TASK:> Python Code: from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt %matplotlib inline import numpy as np import urllib2 import scipy.stats as stats np.set_printoptions(precision=3, suppress=True) url = ('https://raw.githubusercontent.com/Upward-Spiral-Science' '/data/master/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: 1) What is the average synapse density per voxel? How does it compare to average and min/max synapse density per bin? Step2: Note the 2 large s...
7,598
<ASSISTANT_TASK:> Python Code: %load_ext sql %sql mysql://steinam:steinam@localhost/versicherung_complete %%sql -- meine Lösung select distinct(Land) from Fahrzeughersteller; %%sql -- deine Lösung select fahrzeughersteller.Land from fahrzeughersteller group by fahrzeughersteller.Land ; %%sql -- meine Lösung sele...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Gesucht wird eine wiederholungsfreie Liste der Herstellerländer 3 P Step2: Listen Sie alle Fahrzeugtypen und die Anzahl Fahrzeuge diese...
7,599
<ASSISTANT_TASK:> Python Code: %matplotlib notebook import matplotlib.pyplot as plt import numpy as np from matplotlib.pyplot import * from numpy import * def problem08(start, max_value, addition): true_val = pi**4/90 total = 0 i = start while i > max_value or i < max_value: ...
<SYSTEM_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 08 Step2: <b>Results without specifying single precision (float32) Step3: We can analyse the graph provided and find out the equation ...