Unnamed: 0
int64
0
15.9k
cleaned_code
stringlengths
67
124k
cleaned_prompt
stringlengths
168
30.3k
5,900
<ASSISTANT_TASK:> Python Code: %load_ext ferretmagic for i in [100,500,1000]: %ferret_run -s 300,300 'set text/font=arial ; plot/thick=2 sin(i[i=1:%(i)s]*0.1)' % locals() %%ferret use levitus_climatology for i in range(1,3): %ferret_run -q -s 400,300 'set text/font=arial ; fill salt[k=%(i)s] ; go land' % loca...
<SYSTEM_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 usage of %ferret_run line magic Step2: Another example
5,901
<ASSISTANT_TASK:> Python Code: import os # Google Cloud Notebook if os.path.exists("/opt/deeplearning/metadata/env_version"): USER_FLAG = "--user" else: USER_FLAG = "" ! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG ! pip3 install -U google-cloud-storage $USER_FLAG ! pip3 install $USER kfp --upgra...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Install the latest GA version of google-cloud-storage library as well. Step2: Install the latest GA version of KFP SDK library as well. Step3: ...
5,902
<ASSISTANT_TASK:> Python Code: import nltk nltk.download('gutenberg') # nltk.download('maxent_treebank_pos_tagger') from nltk.corpus import gutenberg # 저장되어 있는 데이터 로드 및 파일 제목 확인 gutenberg_files = gutenberg.fileids() gutenberg_files # 특정 텍스트 확인 gutenberg_doc = gutenberg.open('austen-emma.txt').read() print(gutenberg_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: nltk에서 제공되는 gutenberg data read Step3: Tokenize Step4: PoS tagging Step5: Alphabetical list of part-of-speech tags used in the Penn Treebank ...
5,903
<ASSISTANT_TASK:> Python Code: DON'T MODIFY ANYTHING IN THIS CELL import helper import problem_unittests as tests source_path = 'data/small_vocab_en' target_path = 'data/small_vocab_fr' source_text = helper.load_data(source_path) target_text = helper.load_data(target_path) view_sentence_range = (0, 10) DON'T MODIFY AN...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Language Translation Step3: Explore the Data Step6: Implement Preprocessing Function Step8: Preprocess all the data and save it Step10: Chec...
5,904
<ASSISTANT_TASK:> Python Code: import kmeans; reload(kmeans) from kmeans import Kmeans n_clusters=6 n_samples =250 centroids = np.random.uniform(-35, 35, (n_clusters, 2)) slices = [np.random.multivariate_normal(centroids[i], np.diag([5., 5.]), n_samples) for i in range(n_clusters)] data = np.concatenate(sl...
<SYSTEM_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 easiest way to demonstrate how clustering works is to simply generate some data and show them in action. Step2: To generate our data, we're...
5,905
<ASSISTANT_TASK:> Python Code: import pandas as pd import scipy.sparse as ss import numpy as np from sklearn.decomposition import TruncatedSVD import sklearn.manifold import tsne import re raw_data = pd.read_csv('subreddit-overlap') raw_data.head() subreddit_popularity = raw_data.groupby('t2_subreddit')['NumOverlaps']....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: I hadn't bothered to look if the relevant scikit-learn functions actually accepted sparse matrices when I was just playing, so I did the row nor...
5,906
<ASSISTANT_TASK:> Python Code: from math import log def entropia(p): return -p*log(p,2) - (1.0-p)*log(1.0-p,2) print(entropia(1.0), entropia(0.0)) def entropia(p): if p == 0 or p == 1: return 0.0 else: return -p*log(p,2) - (1.0-p)*log(1.0-p,2) print(entropia(0.0), entropia(1.0), entropia(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: Por conveniência, o valor da entropia para esses dois casos é definida como 0.0. Step2: Nos dois primeiros casos, entropia(0.0) e entropia(1.0)...
5,907
<ASSISTANT_TASK:> Python Code: import vcsn %%automaton a context = "lan_char, b" $ -> s s -> A \e A -> s \e s -> $ ctx = vcsn.context('lal_char, q') aut = lambda e: ctx.expression(e).standard() aut('a+b').star("standard") aut('a+b').star("general") <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: This is what the general algorithm for star outputs, given an automaton A and s being a new state. Step2: Examples Step3: General
5,908
<ASSISTANT_TASK:> Python Code: %matplotlib inline import tensorflow as tf import helper from tensorflow.examples.tutorials.mnist import input_data print('Getting MNIST Dataset...') mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) print('Data Extracted.') # Save the shapes of weights for each layer layer_...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Neural Network Step2: Initialize Weights Step3: As you can see the accuracy is close to guessing for both zeros and ones, around 10%. Step4: ...
5,909
<ASSISTANT_TASK:> Python Code: Image('./res/iterative_policy_evaluation.png') Image('./res/ex4_1.png') class Action(enum.Enum): EAST = enum.auto() WEST = enum.auto() SOUTH = enum.auto() NORTH = enum.auto() @staticmethod def move(x, y, action): if action == Action.EAST: r...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 4.2 Policy Improvement Step2: 4.3 Policy Iteration Step3: 4.4 Value Iteration Step4: 4.5 Asynchronouse Dynamic Programming
5,910
<ASSISTANT_TASK:> Python Code: ## Step 1. Import pyopencga dependecies from pyopencga.opencga_config import ClientConfiguration # import configuration module from pyopencga.opencga_client import OpencgaClient # import client module from pprint import pprint from IPython.display import JSON import matplotlib.pyplot as 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: Define some common variables Step2: 1. Comon Queries for Clinical Analysis Step3: Proband information Step4: Check the interpretation id of a...
5,911
<ASSISTANT_TASK:> Python Code: %pylab inline import numpy as np from chemview import enable_notebook from matscipy.visualise import view enable_notebook() from ase.lattice import bulk from ase.optimize import LBFGSLineSearch from quippy.potential import Potential si = bulk('Si', a=5.44, cubic=True) sw_pot = Potential(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Example Step2: Inline visualisation Step3: DFT example - persistent connection, checkpointing Step4: File-based interfaces vs. Native interf...
5,912
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import xgboost as xgb from xgboost.sklearn import XGBClassifier from sklearn import cross_validation, metrics from sklearn.grid_search import GridSearchCV import matplotlib.pylab as plt %matplotlib inline from matplotlib.pylab import rcParams rcParam...
<SYSTEM_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: Define a function for modeling and cross-validation Step3: Step 1- Find the number of estimators for a high learning rate Ste...
5,913
<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: Multi-task recommenders Step2: Preparing the dataset Step3: And repeat our preparations for building vocabularies and splitting the data into ...
5,914
<ASSISTANT_TASK:> Python Code: from jyquickhelper import add_notebook_menu add_notebook_menu() %matplotlib inline from sklearn.datasets import load_boston from sklearn.model_selection import train_test_split data = load_boston() X, y = data.data, data.target X_train, X_test, y_train, y_test = train_test_split(X, y) 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: Données Step2: Premiers modèles Step3: Pour le modèle, il suffit de copier coller le code écrit dans ce fichier lasso_random_forest_regressor....
5,915
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd import matplotlib.pyplot as plt test = np.random.randn(11,11,4,100) test.shape test_flat = test.flatten() test_flat.shape np.savetxt('test.txt', test_flat) test_back = np.loadtxt('test.txt').reshape((11,11,4,100)) test_back.shape np.mean(test - 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: first just checking that the flattening and reshaping works as expected
5,916
<ASSISTANT_TASK:> Python Code: import json import pymongo from pprint import pprint conn=pymongo.MongoClient() db = conn.mydb conn.database_names() collection = db.my_collection db.collection_names() doc = {"class":"xbus-502","date":"03-05-2016","instructor":"bengfort","classroom":"C222","roster_count":"25"} collec...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Connect Step2: Create and access a database Step3: Collections Step4: Insert data Step5: You can put anything in Step6: A practical example...
5,917
<ASSISTANT_TASK:> Python Code: import pandas as pd import oandapyV20 import oandapyV20.endpoints.positions as positions import configparser config = configparser.ConfigParser() config.read('../config/config_v20.ini') accountID = config['oanda']['account_id'] access_token = config['oanda']['api_key'] client = oandapyV20...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: List all Positions for an Account. Step2: List all open Positions for an Account. Step3: Get the details of a single instrument’s position in ...
5,918
<ASSISTANT_TASK:> Python Code: import numpy as np import matplotlib.pyplot as plt ################## %matplotlib inline # Compute the x and y coordinates for points on a sine curve x = np.arange(0, 3 * np.pi, 0.1) y = np.sin(x) # Plot the points using matplotlib plt.plot(x, y) plt.show() a = np.array([1, 4, 5, 66, 77,...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: NOTE Step2: Subplots Step3: Reading csv file and plotting the data. Step4: Simple plot Step5: Plotting with default settings Step6: Instant...
5,919
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'thu', 'sandbox-2', 'ocnbgchem') # 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,920
<ASSISTANT_TASK:> Python Code: # Authors: Denis Engemann <denis.engemann@gmail.com> # # License: BSD (3-clause) import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import make_axes_locatable from mne.viz import plot_topomap import mne from mne.stats import spatio_temporal_cluster_test from m...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Set parameters Step2: Read epochs for the channel of interest Step3: Load FieldTrip neighbor definition to setup sensor connectivity Step4: C...
5,921
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'awi', 'awi-cm-1-0-lr', 'atmos') # 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,922
<ASSISTANT_TASK:> Python Code: %matplotlib inline import scipy.misc from scipy.stats import signaltonoise from scipy.stats import norm # Gaussian distribution lena=scipy.misc.lena().astype(float) lena+= norm.rvs(loc=0,scale=16,size=lena.shape) signaltonoise(lena,axis=None) import numpy from scipy.stats import 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: Descriptive statistics Step2: Interval estimation, correlation measures, and statistical tests Step3: Distribution fitting Step4: Distances S...
5,923
<ASSISTANT_TASK:> Python Code: from IPython.display import Image Image(filename='images/06_03.jpg', width=1000) Image(filename='images/07_01.png', width=500) <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: <br>
5,924
<ASSISTANT_TASK:> Python Code: # %load script.py from pyomo.environ import * from pyomo.opt import SolverFactory, TerminationCondition def create_model(): model = ConcreteModel() model.x = Var() model.o = Objective(expr=model.x) model.c = Constraint(expr=model.x >= 1) model.x.set_value(1.0) retu...
<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: The basic work flow that takes place above can be summarized as Step3: The first argument to this function is the Pyomo model. The second argum...
5,925
<ASSISTANT_TASK:> Python Code: skchem.data.BursiAmes.available_sets() skchem.data.BursiAmes.available_sources() kws = {'sets': ('train', 'valid', 'test'), 'sources':('X_morg', 'y')} (X_train, y_train), (X_valid, y_valid), (X_test, y_test) = skchem.data.BursiAmes.load_data(**kws) print('train shapes:', X_train.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: And many sources Step2: For this example, we will load the X_morg and the y sources for all the sets. These are circular fingerprints, and the...
5,926
<ASSISTANT_TASK:> Python Code: import sys import os sys.path.append(os.environ.get('NOTEBOOK_ROOT')) import matplotlib.pyplot as plt import xarray as xr from utils.data_cube_utilities.dc_display_map import display_map from utils.data_cube_utilities.dc_rgb import rgb from utils.data_cube_utilities.urbanization import ND...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: <span id="Urbanization_Using_NDBI_plat_prod">Choose Platform and Product &#9652;</span> Step2: Choose the platforms and products Step3: <span ...
5,927
<ASSISTANT_TASK:> Python Code: %load_ext autoreload %autoreload 2 %matplotlib inline import os # Connect to the database backend and initalize a Snorkel session from lib.init import * # Here, we just set how many documents we'll process for automatic testing- you can safely ignore this! n_docs = 1000 if 'CI' in os.envi...
<SYSTEM_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 Corpus Step2: Running a CorpusParser Step3: We can then use simple database queries (written in the syntax of SQLAlchemy, which Sn...
5,928
<ASSISTANT_TASK:> Python Code: # using Tensorflow 2 %tensorflow_version 2.x import math import numpy as np from matplotlib import pyplot as plt import tensorflow as tf print("Tensorflow version: " + tf.__version__) #@title Data formatting and display utilites [RUN ME] def dumb_minibatch_sequencer(data, batch_size, sequ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step2: An stateful RNN model to generate sequences Step3: Generate fake dataset [WORK REQUIRED] Step4: Hyperparameters Step5: Visualize training seq...
5,929
<ASSISTANT_TASK:> Python Code: import pandas as pd import matplotlib.pyplot as plt #shape = (97, 2) data = pd.read_csv('ex1data1.txt', header=None) plt.scatter(data[0], data[1]) plt.xlabel('population') plt.ylabel('profit') plt.close() import numpy as np # Now we want to have our hypothesis function: h_theta = theta' ...
<SYSTEM_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 preparation Step2: Defining cost function Step3: Defining gradient descent Step4: Now, lets plot fit line on the training data
5,930
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'nims-kma', 'sandbox-3', 'toplevel') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name"...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 2...
5,931
<ASSISTANT_TASK:> Python Code: # Python packages used import numpy as np # for array operations from matplotlib import pyplot as plt # for graphic output from math import sqrt # parameters tolerance = 2.5 # max distance from the plane to accept point rep = 1000 # number ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Az ismétlési szám elég magas. Step2: Jelenítsük meg a generált pontokat és az egyenest. Step3: Futtasa többször a fenti kódblokkot és vegye és...
5,932
<ASSISTANT_TASK:> Python Code: import numpy as np import scipy.stats as stats import matplotlib.pyplot as plt import math # Example of ranking data l = [10, 9, 5, 7, 5] print 'Raw data: ', l print 'Ranking: ', list(stats.rankdata(l, method='average')) ## Let's see an example of this n = 100 def compare_correlation_and...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Spearman Rank Correlation Step2: Let's take a look at the distribution of measured correlation coefficients and compare the spearman with the r...
5,933
<ASSISTANT_TASK:> Python Code: !pip install Pillow !pip install pdf2image !pip install pytesseract !pip install opencv-python from PIL import Image import sys from pdf2image import convert_from_path import os # Path of the pdf PDF_file = "Lista inscrisi Admitere Licenta sept 11.09.2015.pdf" if not os.path.exist...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Olvasd el Step2: Olvasd el Step3: 1 Step4: Készítünk egy mappát, ahová a PDF oldalait exportáljuk képként. Step5: 2 Step6: 3 Step7: Felism...
5,934
<ASSISTANT_TASK:> Python Code: %matplotlib inline import matplotlib.pyplot as plt import numpy as np import scipy.optimize as opt def hat(x,a,b): return -1*a*(x**2) + b*(x**4) assert hat(0.0, 1.0, 1.0)==0.0 assert hat(0.0, 1.0, 1.0)==0.0 assert hat(1.0, 10.0, 1.0)==-9.0 a = 5.0 b = 1.0 x = np.linspace(-3,3,100) v...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Hat potential Step2: Plot this function over the range $x\in\left[-3,3\right]$ with $b=1.0$ and $a=5.0$ Step3: Write code that finds the two l...
5,935
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np import re val = 'a, b, guido , bajo' print(val) # splitting the data by , and strip the whitespace val2 = [x.strip() for x in val.split(',')] val2 # tuple assignment first, second, third, four = val2 first + "::" + second + "::" + third # 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: Step2: Python built-in string methods Step3: Regular expression methods
5,936
<ASSISTANT_TASK:> Python Code: labVersion = 'cs190.1x-lab4-1.0.4' print labVersion # 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, ...
<SYSTEM_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: WARNING Step3: (1b) Sparse vectors Step4: (1c) OHE features as sparse vectors Step7: (1d) Define a OHE function Step8: (1e...
5,937
<ASSISTANT_TASK:> Python Code: from pycqedscripts.init.xld.virtual_ATC75_M136_S17HW02_PQSC import * import warnings warnings.filterwarnings("ignore") # If running into problems with the initalization, it could be the AWG wave loading lines at the end of the init file. # Commenting out: # for AWG in AWGs: # pulsar....
<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: Example of use in v3 is based on do_state_tomo_analysis function in pycqedscripts.scripts.characterization.state_tomo Step3: Load two experimen...
5,938
<ASSISTANT_TASK:> Python Code: import nltk from nltk import word_tokenize from nltk.corpus import stopwords import string punctuations = list(string.punctuation) #read the two text files from your hard drive, assign first mystery text to variable 'text1' and second mystery text to variable 'text2' text1 = open('../01-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: Lesson 2 Step2: Lesson 3 Step3: Lesson 4 Step4: Lesson 5 Step7: Lesson 6 Step8: Lesson 6
5,939
<ASSISTANT_TASK:> Python Code: !gunzip ../data/2017-superbowl-tweets.tsv.gz !ls ../data tweets = [] RUTA = '../data/2017-superbowl-tweets.tsv' for line in open(RUTA).readlines(): tweets.append(line.split('\t')) ultimo_tweet = tweets[-1] print('id =>', ultimo_tweet[0]) print('fecha =>', ultimo_tweet[1]) print('auto...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Fíjate en la estructura de la lista Step2: Al lío
5,940
<ASSISTANT_TASK:> Python Code: %matplotlib inline from __future__ import print_function import numpy as np from scipy import stats import pandas as pd import matplotlib.pyplot as plt import statsmodels.api as sm from statsmodels.graphics.api import qqplot print(sm.datasets.sunspots.NOTE) dta = sm.datasets.sunspots.loa...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Sunpots Data Step2: Does our model obey the theory? Step3: This indicates a lack of fit. Step4: Exercise Step5: Let's make sure this model i...
5,941
<ASSISTANT_TASK:> Python Code: import numpy as np try: np except NameError: print('Numpy not correctly imported') Z = np.zeros(10) print(Z) assert type(Z).__module__ == np.__name__ assert len(Z) == 10 assert sum(Z) == 0 Z = np.zeros(10) Z[4] = 1 print(Z) assert type(Z).__module__ == np.__name__ assert len(Z) ...
<SYSTEM_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. Create a null vector Z of size 10. Don't use [0, 0, ...] notation. Step2: 3. Create a null vector of size 10 but the fifth value which is 1...
5,942
<ASSISTANT_TASK:> Python Code: import pandas as pd import numpy as np df = pd.read_csv('data/human_body_temperature.csv') df.info() df.head() # Plots the histogram of temperatures import matplotlib.pyplot as plt import seaborn as sns temperature = df['temperature'] sns.set() plt.hist(temperature, bins='auto', normed=T...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: 1) Is the distribution of body temperatures normal? Step3: It is difficult to conclude whether this data is normally distributed from this hist...
5,943
<ASSISTANT_TASK:> Python Code: import pandas as pd reviews = pd.read_csv("../input/wine-reviews/winemag-data-130k-v2.csv", index_col=0) pd.set_option("display.max_rows", 5) from learntools.core import binder; binder.bind(globals()) from learntools.pandas.indexing_selecting_and_assigning import * print("Setup complete."...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Look at an overview of your data by running the following line. Step2: Exercises Step3: Follow-up question Step4: 2. Step5: 3. Step6: 4. St...
5,944
<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: Customizing AdaNet Step2: Fashion MNIST dataset Step6: Supply the data in TensorFlow Step7: Launch TensorBoard Step8: Establish baselines St...
5,945
<ASSISTANT_TASK:> Python Code: import numpy as np import pandas as pd from scipy import stats import statsmodels.api as sm import statsmodels.tsa as tsa import matplotlib.pyplot as plt # ensures experiment runs the same every time np.random.seed(100) # This function simluates an AR process, generating a new value based...
<SYSTEM_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 how this process fluctuates around some central value. This value is the mean of our time series. As we have a constant mean throughout tim...
5,946
<ASSISTANT_TASK:> Python Code: # Ensure compatibility with Python 2 and 3 from __future__ import print_function, division import xarray as xr url = "http://www.esrl.noaa.gov/psd/thredds/dodsC/Datasets/ncep.reanalysis.derived/surface_gauss/air.2m.mon.1981-2010.ltm.nc" ncep_air2m = xr.open_dataset(url, decode_times=Fal...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Homework questions Step2: The temperature data is called air. Take a look at the details
5,947
<ASSISTANT_TASK:> Python Code: num_samples_left = 50 num_samples_right = 50 delta = 0.5 # width of measure's support per dimension L = unit_center_set(2, num_samples_left, delta) R = unit_center_set(2, num_samples_right, delta) plt.scatter(L._values[:,0], L._values[:,1], c=L._probabilities) plt.xlim([0,1]) plt.ylim([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: Define Metric Step2: Clip and compare Step3: Observe how these are distinctly different objects in memory Step4: Density Emulation Step5: Cl...
5,948
<ASSISTANT_TASK:> Python Code: %%capture --no-stderr KFP_PACKAGE = 'https://storage.googleapis.com/ml-pipeline/release/0.1.14/kfp.tar.gz' !pip3 install $KFP_PACKAGE --upgrade import kfp.components as comp mlengine_deploy_op = comp.load_component_from_url( 'https://raw.githubusercontent.com/kubeflow/pipelines/01a23...
<SYSTEM_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: Example pipeline that uses the component Step4: Compile the pipeline Step5: Submit the...
5,949
<ASSISTANT_TASK:> Python Code: import os import numpy as np from filelock import FileLock import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torchvision import datasets, transforms import ray ray.init() # The number of sets of random hyperparameters to try. num_evaluatio...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step4: Setup Step5: Evaluating the Hyperparameters Step6: Synchronous Evaluation of Randomly Generated Hyperparameters Step7: Launch asynchronous pa...
5,950
<ASSISTANT_TASK:> Python Code: import sympy sympy.init_printing() x = sympy.Symbol('x') y, z0 = sympy.symbols(('y', 'z_0')) z0 a = x + y b = y * z0 print("a={}. b={}.".format(a, b)) a f = sympy.Function('f') c = sympy.sin(x)**2 + sympy.cos(x)**2 c c.simplify() d = sympy.cosh(x)**2 - sympy.sinh(x)**2 d.simplify(...
<SYSTEM_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 standard import command is used. The init_printing command looks at your system to find the clearest way of displaying the output; this isn'...
5,951
<ASSISTANT_TASK:> Python Code: import xarray as xr import numpy as np %matplotlib inline path = 'http://apdrc.soest.hawaii.edu:80/dods/public_data/Argo_Products/monthly_mean/monthly_mixed_layer' ds = xr.open_dataset(path, use_cftime=True) ds ds.load() from xarrayutils.utils import linear_trend # create an array salin...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Lets find out how much the salinity in each grid point changed over the full period (20 years) Step2: Now we can plot the slope as a map Step3:...
5,952
<ASSISTANT_TASK:> Python Code: # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, sof...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step3: Download buildings data for a region in Africa [takes up to 15 minutes for large countries] Step4: Visualise the data Step5: For some countrie...
5,953
<ASSISTANT_TASK:> Python Code: plot_approximation() print("Pi was approximated at %.5f, when the real value is %.5f..." % (best_pi_approximation, real_pi_value)) plot_approximation_evolution_graph() <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: Results Step2: However, this method isn't very fast and can only approximate Pi, never truly compute the exact value.
5,954
<ASSISTANT_TASK:> Python Code: from IPython.display import Image Image(url="http://docs.opencv.org/2.4/_images/separating-lines.png") Image(url="http://docs.opencv.org/2.4/_images/optimal-hyperplane.png") #Imports import numpy as np import matplotlib.pyplot as plt %matplotlib inline from sklearn import datasets # lo...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: In the above picture you can see that there exists multiple lines that offer a solution to the problem. Is any of them better than the others? W...
5,955
<ASSISTANT_TASK:> Python Code: %cd ../.. # Some libraries need to be installed that are not part of Gensim ! pip install click>=6.7 nltk>=3.2.5 prettytable>=0.7.2 pygtrie>=2.2 import csv from collections import OrderedDict from IPython.display import display, HTML import logging import os import pickle import random im...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Please set the variable parent_directory below to change the directory to which the repositories are cloned. Step2: You might need to install a...
5,956
<ASSISTANT_TASK:> Python Code: PROJECT_ID = "[your-project-id]" #@param {type:"string"} ! gcloud config set project $PROJECT_ID import sys # If you are running this notebook in Colab, run this cell and follow the # instructions to authenticate your GCP account. This provides access to your # Cloud Storage bucket and 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: Authenticate your GCP account Step2: Create a Cloud Storage bucket Step3: Only if your bucket doesn't already exist Step4: Finally, validate ...
5,957
<ASSISTANT_TASK:> Python Code: import torch import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline df = pd.read_csv('../Data/iris.csv') df.head() df.shape fig, axes = plt.subplots(nrows=2, ncols=2, figsize=(10,7)) fig.tight_layout() plots = [(0,1),(2,3),(0,2),(1,3)] colors = ['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: Loading data from files Step2: Plot the data Step3: The iris dataset consists of 50 samples each from three species of Iris (<em>Iris setosa</...
5,958
<ASSISTANT_TASK:> Python Code: # DO NOT EDIT ! from pyesdoc.ipython.model_topic import NotebookOutput # DO NOT EDIT ! DOC = NotebookOutput('cmip6', 'mohc', 'hadgem3-gc31-hm', 'land') # Set as follows: DOC.set_author("name", "email") # TODO - please enter value(s) # Set as follows: DOC.set_contributor("name", ...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Document Authors Step2: Document Contributors Step3: Document Publication Step4: Document Table of Contents Step5: 1.2. Model Name Step6: 1...
5,959
<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 mne from mne import find_events, fit_dipole from mne.datasets.brainstorm import bst_phantom_elekta from mne.io import read_raw_fif print(__doc__) data_path = bst_ph...
<SYSTEM_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...
5,960
<ASSISTANT_TASK:> Python Code: %pylab inline %matplotlib inline import os SHOGUN_DATA_DIR=os.getenv('SHOGUN_DATA_DIR', '../../../data') import numpy as np import scipy.io dataset = scipy.io.loadmat(os.path.join(SHOGUN_DATA_DIR, 'ocr/ocr_taskar.mat')) # patterns for training p_tr = dataset['patterns_train'] # patterns 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: Step2: Few examples of the handwritten words are shown below. Note that the first capitalized letter has been removed. Step3: Define Factor Types and ...
5,961
<ASSISTANT_TASK:> Python Code: df = pd.read_csv('npr_articles.csv') df.head() df.info() df['date_published'] = pd.to_datetime(df['date_published']) df.info() # Let's create a mask for all rows that have a non-null value mask = df['author'].notnull() # When the data was saved to a csv, these lists were converted int...
<SYSTEM_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 can now checkout what our data consists of by using the .head() method on our DataFrame. By default, this will show the top 5 rows. Step2: ...
5,962
<ASSISTANT_TASK:> Python Code: # Import packages to visualize the classifer from matplotlib.colors import ListedColormap import matplotlib.pyplot as plt import warnings # Import packages to do the classifying import numpy as np from sklearn.svm import SVC def versiontuple(v): return tuple(map(int, (v.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: Create Function To Visualize Classification Regions Step2: Generate Data Step3: Classify Using a Linear Kernel Step4: Classify Using a RBF Ke...
5,963
<ASSISTANT_TASK:> Python Code: from sklearn import datasets import numpy as np iris = datasets.load_iris() X = iris.data[:, [2, 3]] y = iris.target print('Class labels:', np.unique(y)) # Splitting data into 70% training and 30% test data: from sklearn.model_selection import train_test_split X_train, X_test, y_train, 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: 1. Training a perceptron via scikit-learn Step2: 2. Training a logistic regression model with scikit-learn Step3: 3. Training a support vector...
5,964
<ASSISTANT_TASK:> Python Code: import os import subprocess if os.path.exists("/var/run/secrets/kubernetes.io/serviceaccount"): subprocess.check_call(["pip", "install", "--user", "-r", "requirements.txt"], stderr=subprocess.STDOUT, bufsize=1) # NOTE: The RuntimeWarnings (if any) are harmless. See ContinuumIO/anacond...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Setup Authorization Step3: Unique PR Creators Step4: Number Prs Step6: Release stats per release (quarter) Step8: Get a list of distinct act...
5,965
<ASSISTANT_TASK:> Python Code: !conda install -y torchvision import torch import torch.nn as nn import torchvision.transforms as transforms import torchvision.datasets as dsets import matplotlib.pylab as plt import numpy as np def show_data(data_sample): plt.imshow(data_sample[0].numpy().reshape(28,28),cmap='gray...
<SYSTEM_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 following function to visualize data Step2: <a id="ref1"></a> Step3: Load the testing dataset by setting the parameters train <code>Fa...
5,966
<ASSISTANT_TASK:> Python Code: m n # m grid_plot.sort_values(ascending=False, by='uni').head() # n freeGrid2.sort_values(ascending=False, by='median level').head() check1 = grid_bssid.dropna(subset=['unique_bssid_list']).sort_values(ascending=False, by='uni').head().iloc[0,3] len(check1) <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: 2. free wifi Step2: DataFrame Step3: <br/><br>
5,967
<ASSISTANT_TASK:> Python Code: import helper source_path = 'data/letters_source.txt' target_path = 'data/letters_target.txt' source_sentences = helper.load_data(source_path) target_sentences = helper.load_data(target_path) source_sentences[:50].split('\n') target_sentences[:50].split('\n') def extract_character_voca...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Let's start by examining the current state of the dataset. source_sentences contains the entire input sequence file as text delimited by newline...
5,968
<ASSISTANT_TASK:> Python Code: result_with_lat_long = result_with_lat_long[result_with_lat_long.decimallatitude.notnull() & result_with_lat_long.decimallongitude.notnull()] result_with_lat_long['species'].unique().size grouped_lat_long_year_or_eventdate = pd.DataFrame() grouped_lat_long_year_or_eventdate['count'] = r...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: How many unique species have occurrence records with latitude/longitude? Step2: Best to take into account all observations which have either "y...
5,969
<ASSISTANT_TASK:> Python Code: # Import custom functions and connect to db resa2_basic_path = (r'C:\Data\James_Work\Staff\Heleen_d_W\ICP_Waters\Upload_Template' r'\useful_resa2_code.py') resa2_basic = imp.load_source('useful_resa2_code', resa2_basic_path) engine, conn = resa2_basic.connect_to_resa2(...
<SYSTEM_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.2. Check sites against John's spreadsheet Step2: This looks promising. With a bit of luck, I can just move the four sites listed above from t...
5,970
<ASSISTANT_TASK:> Python Code: from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("data/MNIST",one_hot=True) import tensorflow as tf # Setup our Input placeholder x = tf.placeholder(tf.float32, [None, 784]) # Our Weights and Biases W = tf.Variable(tf.zeros([784, 10])) b = tf.V...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Softmax regression Step2: Training Step3: Validation
5,971
<ASSISTANT_TASK:> Python Code: import pandas as pd import csv import matplotlib.pyplot as plt income_df = pd.read_csv('LifeExpectancyIncome.csv') income_df income_df = income_df.set_index('Country').transpose() income_df income_df['Income / Person'] = income_df['Income / Person'].str.replace(r'[^-+\d.]', '').astype(...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Reading CSV File into Pandas DataFrame Step2: I have a few things to do, first i want to flip the positions of columns with the of row index va...
5,972
<ASSISTANT_TASK:> Python Code: # Authors: Clemens Brunner <clemens.brunner@gmail.com> # Felix Klotzsche <klotzsche@cbs.mpg.de> # # License: BSD-3-Clause import numpy as np import matplotlib.pyplot as plt from matplotlib.colors import TwoSlopeNorm import pandas as pd import seaborn as sns import mne from mne.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: As usual, we import everything we need. Step2: First, we load and preprocess the data. We use runs 6, 10, and 14 from Step3: Now we can create...
5,973
<ASSISTANT_TASK:> Python Code: #@title Licensed under the Apache License, Version 2.0 # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # dis...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: TensorFlowアドオンオプティマイザ:ConditionalGradient Step2: モデルの構築 Step3: データの準備 Step5: カスタムコールバック関数の定義 Step6: トレーニングと評価 Step7: トレーニングと評価 Step8: 重みのフ...
5,974
<ASSISTANT_TASK:> Python Code: %matplotlib inline import math import random import seaborn as sns import matplotlib.pyplot as plt import pandas as pd from sklearn.datasets import load_boston '''Since this is a classification problem, we will need to represent our targets as one-hot encoding vectors (see previous lab)....
<SYSTEM_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. Target data format Step2: 2. Target data encoding Step3: Perfomance measure Step4: 4. Model definition Step5: Now that we have replaced t...
5,975
<ASSISTANT_TASK:> Python Code: import warnings warnings.filterwarnings("ignore") import pandas as pd names = ["Name_2MASS", "RA", "Dec", "Spectral Type", "Membership", "Teff", "AJ", "Lbol", "I", "I-zp","J-H","H-Ks", "Ks", "inIMF", "Night"] tbl3 = pd.read_csv("http://iopscience.iop.org/0004-637X/617/2/1216/ful...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Table 3- New Members of Taurus Step2: Save the data tables locally.
5,976
<ASSISTANT_TASK:> Python Code: def urn_to_dict(urn_list): urn_dict = {} ### BEGIN SOLUTION ### END SOLUTION return urn_dict u1 = ["green", "green", "blue", "green"] a1 = set({("green", 3), ("blue", 1)}) assert a1 == set(urn_to_dict(u1).items()) u2 = ["red", "blue", "blue", "green", "yello...
<SYSTEM_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 Step2: C Step3: D Step4: E
5,977
<ASSISTANT_TASK:> Python Code: !head ../data/temperaturas.csv # Esta línea no funciona en Windows import numpy as np %matplotlib inline import matplotlib.pyplot as plt datos = np.loadtxt("../data/temperaturas.csv", skiprows=1, # Saltamos una línea usecols=(1, 2, 3), # Solo colum...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: La primera columna es un entero con formato "AAAAMMDD" que vamos a ignorar. Las temperaturas están medidas en décimas de grado Celsius, así que ...
5,978
<ASSISTANT_TASK:> Python Code: #IMPORT import numpy as np import copy import operator from tqdm import tqdm file_train = open("cascades_train.txt") file_test = open("cascades_test.txt") data_train=[] for i in file_train.readlines(): tab = [[float(j.split(":")[0]),float(j.split(":")[1])] for j in i.split(";")[:-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: Objectif Step2: Creation des liste de successeurs Step3: Création des graphes Step4: Apprentissage Step5: Poids du graphe assignés en random...
5,979
<ASSISTANT_TASK:> Python Code: import myutils raw_data_training, raw_data_testing = myutils.load_CIFAR_dataset(shuffle=False) # raw_data_training = raw_data_training[:5000] class_names = myutils.load_CIFAR_classnames() n_training = len( raw_data_training ) n_testing = len( raw_data_testing ) print('Loaded CIFAR10 datab...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Preprocessing Step2: Lets look how images looks like Step3: Feature extraction Step4: Visualization of HOG histograms Step5: Short look at t...
5,980
<ASSISTANT_TASK:> Python Code: import pynucastro as pyrl al_mg = pyrl.Rate("al28--mg28-toki") print(al_mg) al_mg.eval(T=1.e8,rhoY=1.e9) al_mg.plot() ne_f = pyrl.Rate("ne23--f23-toki") print(ne_f) ne_f.plot() files = ["c13-pg-n14-nacr", "n13--c13-wc12", "c12-c12n-mg23-cf88", "o14-ap-f17-...
<SYSTEM_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 a tabulated rate Step2: A human readable string describing the rate, and the nuclei involved Step3: Evaluate the electron capture rate [s...
5,981
<ASSISTANT_TASK:> Python Code: '''This is a definition script, so we do not have to rewrite code''' import numpy as np import cv2 import matplotlib.pyplot as mplt # set matplotlib to print inline (Jupyter) %matplotlib inline # path prefix pth = '../data/' # files to be used as samples # list *files* holds the names of ...
<SYSTEM_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>1. </b>Load image from a file and display the image. Determine the size of the image. Finally, save a new copy of the image in a new file.<br...
5,982
<ASSISTANT_TASK:> Python Code: from evoml.subsampling import BasicSegmenter_FEMPO, BasicSegmenter_FEGT, BasicSegmenter_FEMPT df = pd.read_csv('datasets/ozone.csv') df.head(2) X, y = df.iloc[:,:-1], df['output'] print(BasicSegmenter_FEGT.__doc__) from sklearn.tree import DecisionTreeRegressor clf_dt = DecisionTreeRegres...
<SYSTEM_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. Subspacing - sampling in the domain of features - evolving and mutating columns
5,983
<ASSISTANT_TASK:> Python Code: # Put your code here! import random as rand import math def f(x): return 2.0*(x**2) + 3.0 # x min, max: -2, 4 (delta_x = 6) # y min, max: 0, 35 Area = (35-0)*(4+2) real_area = 66.0 samples = [] errors = [] for i in range(1,7): N_samples = 10**i N_below = 0 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: Part 2 Step3: Assignment wrapup
5,984
<ASSISTANT_TASK:> Python Code: import os import numpy as np import imageio import matplotlib from matplotlib import pyplot as plt import pandas as pd # from skimage import img_as_ubyte %matplotlib inline matplotlib.rcParams['figure.figsize'] = (20.0, 10.0) np.random.seed(1) #deal = 2 * np.random.binomial(1,.5,size=(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: Let's load in a meme. I'm partial to 'Deal with it'. Step2: To convert this to a 1 bit image, I convert everything darker than some threshold t...
5,985
<ASSISTANT_TASK:> Python Code: %matplotlib inline from pylab import * from utils import * #------------------------------------------------- # Training # Constants # Number of input elements n = 2 # Learning rate eta = 0.0001 # number of training patterns n_patterns = 2000 # Number of repetitions of # the 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: Let us start by implementing a very simple network. Our network will only have two input units plus a bias unit, as in the figure. Step2: Let'...
5,986
<ASSISTANT_TASK:> Python Code: # A bit of setup import numpy as np import matplotlib.pyplot as plt from cs231n.classifiers.neural_net import TwoLayerNet from __future__ import print_function %matplotlib inline plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots plt.rcParams['image.interpolation'] =...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Implementing a Neural Network Step2: We will use the class TwoLayerNet in the file cs231n/classifiers/neural_net.py to represent instances of o...
5,987
<ASSISTANT_TASK:> Python Code: # import the free sample of the dataset from quantopian.interactive.data.estimize import estimates_free # or if you want to import the full dataset, use: # from quantopian.interactive.data.estimize import estimates # import data operations from odo import odo # import other libraries we 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: Let's go over the columns Step2: How many records do we have now? Step3: Let's break it down by user Step4: Let's convert it over to a Pandas...
5,988
<ASSISTANT_TASK:> Python Code: import pandas as pd #As the datatypes in all of the columns vary, I decided to to make all the values, except for the ones I specify #into str. This also takes care of questions 1. -> dtype=str # The syntax for this is really very nice and clear, an example na_values= {'Vehicle Year' : ...
<SYSTEM_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. I want to make sure my Plate ID is a string. Can't lose the leading zeroes! Step2: 2. I don't think anyone's car was built in 0AD. Discard t...
5,989
<ASSISTANT_TASK:> Python Code: !sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst %%bash sudo pip3 freeze | grep google-cloud-bigquery==1.6.1 || \ sudo pip3 install google-cloud-bigquery==1.6.1 from google.cloud import bigquery query = SELECT weight_pounds, is_male, mother_age, plurali...
<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: The source dataset Step3: Let's create a BigQuery client that we can use throughout the notebook. Step4: Let's now examine the result of a Biq...
5,990
<ASSISTANT_TASK:> Python Code: from __future__ import division, unicode_literals import pandas as pd import numpy as np import matplotlib %matplotlib inline matplotlib.style.use('ggplot') df = pd.read_excel('./input/complete_data.xls') df.head() import datetime import numpy as np import matplotlib.pyplot as plt impor...
<SYSTEM_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.) Preview the raw data Step2: 3.) Now for the charts Step3: 3.2) Pandas Step4: Bar Chart Step5: Histogram Step6: Stacked Bar Chart Step7:...
5,991
<ASSISTANT_TASK:> Python Code: 4*2 import numpy as np print(np.sin(.5)) print(np.random.random(3)) import os # Load the os library import os # Load the request module import urllib.request # Create a directory os.mkdir('img_align_celeba') # Now perform the following 10 times: for img_i in range(1, 11): # create a...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Now press 'a' or 'b' to create new cells. You can also use the toolbar to create new cells. You can also use the arrow keys to move up and dow...
5,992
<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, b, sigma, size=10): Create a line y = m*x + b + N(0,sigma**2) between x=[-1.0,1.0] Param...
<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,993
<ASSISTANT_TASK:> Python Code: #@test {"skip": true} !pip install --quiet --upgrade tensorflow-federated !pip install --quiet --upgrade nest-asyncio import nest_asyncio nest_asyncio.apply() import collections import time import tensorflow as tf import tensorflow_federated as tff source, _ = tff.simulation.datasets.emn...
<SYSTEM_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: 훈련 실행하기
5,994
<ASSISTANT_TASK:> Python Code: import json import numpy as np import torchvision import torch import torch.nn as nn import shap from PIL import Image device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") model = torchvision.models.mobilenet_v2(pretrained=True, progress=False) model.to(device) model.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: Loading Model and Data Step2: Explain one image Step3: Explain multiple images
5,995
<ASSISTANT_TASK:> Python Code: import os #os.chdir('/Users/q6600sl/IPython_NB') from lifemodels import s_models %matplotlib inline #Read the data original_df = pd.read_csv('/Users/q6600sl/Downloads/SP_12-22-15.txt', sep=' ') #1st step: create a survival object surv_df = s_models.survt_df(original_df) original_df.he...
<SYSTEM_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 the data and create a survival object using .survt_df() method Step2: · Specify the model and create the model fit object using .distfit...
5,996
<ASSISTANT_TASK:> Python Code: # Initialize PySpark APP_NAME = "Debugging Prediction Problems" # If there is no SparkSession, create the environment try: sc and spark except NameError as e: import findspark findspark.init() import pyspark import pyspark.sql sc = pyspark.SparkContext() spark = pyspark.sql....
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Hello, World! Step2: Creating Objects from CSV Step3: GroupBy Step4: Map vs FlatMap Step5: Creating Rows Step7: Creating DataFrames from RD...
5,997
<ASSISTANT_TASK:> Python Code: import glob file_list = glob.glob(r'C:/dev/forensic/data/**/*.txt', recursive=True) file_list = [x.replace("\\", "/") for x in file_list] file_list[:5] import pandas as pd dfs = [] for files_file in file_list: try: files_df = pd.read_csv(files_file, names=['sha', 'timest...
<SYSTEM_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 can then import the data by looping through all the files and read in the corresponding files' content. We further extract the information it...
5,998
<ASSISTANT_TASK:> Python Code: import pandas as pd data_df = pd.read_csv('data/hourly_wages.csv') data_df.head() data_df.describe() target = data_df.wage_per_hour.as_matrix() predictors = data_df.drop(['wage_per_hour'], axis=1).as_matrix() n_cols = predictors.shape[1] from keras.models import Sequential from keras.lay...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: My First Model Step2: Validation and Early Stopping Step3: Classification Step4: Convolutional Networks (Working with Images) Step5: Transfe...
5,999
<ASSISTANT_TASK:> Python Code: import platform if platform.system() == "Windows" : # create directory on Windows !mkdir output-01-naive if platform.system() == "Linux" : # create directory on Linux !mkdir -p ./output-01-naive !hybridizer-cuda ./01-naive/01-naive-csharp.cs graybitmap.cs -o ./01-naive/01-naive-...
<SYSTEM_TASK:> Given the following text description, write Python code to implement the functionality described below step by step <END_TASK> <USER_TASK:> Description: Step1: Distributing on CPU Threads Step2: Running on the GPU Step3: Memory Allocation Step4: Feeding the Beast Step5: Distributing 1960 lines by bl...