Unnamed: 0 int64 0 15.9k | cleaned_code stringlengths 67 124k ⌀ | cleaned_prompt stringlengths 168 30.3k ⌀ |
|---|---|---|
13,700 | <ASSISTANT_TASK:>
Python Code:
#I'm considering only Acquisitions made in USA, with USD (dollars)
acquisitions = pd.read_csv('data/acquisitions.csv')
acquisitions = acquisitions[acquisitions['acquirer_country_code'] == 'USA']
acquisitions[:3]
#acquirer_permalink
#rounds_agg = df_rounds.groupby(['company_permalink', 'fu... | <SYSTEM_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 find the # of investments made by each company
|
13,701 | <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: 医療画像処理向けに DICOM ファイルをデコードする
Step2: 必要なパッケージをインストールし、ランタイムを再起動する
Step3: DICOM 画像をデコードする
Step4: DICOM Metadata をデコードし、タグを操作する
|
13,702 | <ASSISTANT_TASK:>
Python Code:
import nltk
oracion1 = 'This is the lost dog I found at the park'.split()
oracion2 = 'The progress of the humankind as I progress'.split()
print(nltk.pos_tag(oracion1))
print(nltk.pos_tag(oracion2))
oracion3 = 'Green colorless ideas sleep furiously'.split()
print(nltk.pos_tag(oracion3))... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Como primer ejemplo, podemos utilizar la función nltk.pos_tag para etiquetar morfológicamente una oración en inglés, siempre que la especifiquem... |
13,703 | <ASSISTANT_TASK:>
Python Code:
import seaborn as sns
sns.set_context("talk", font_scale=1.5)
iris = sns.load_dataset('iris')
iris.head()
%matplotlib inline
import seaborn as sns;
sns.set()
sns.set_context("talk", font_scale=1)
sns.pairplot(iris, hue='species', size=1.5);
X_iris = iris.drop('species', axis=1)
X_iris.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Each row of the data refers to a single observed flower
Step2: For use in Scikit-Learn, we will extract the features matrix and target array fr... |
13,704 | <ASSISTANT_TASK:>
Python Code:
from sympy import *
from sympy.abc import n, i, N, x, lamda, phi, z, j, r, k, a, alpha
from commons import *
from matrix_functions import *
from sequences import *
import functions_catalog
init_printing()
from sympy.functions.combinatorial.numbers import stirling
m=8
S2 = define(let=Symb... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Stirling array $\mathcal{S}$
Step2: power function
Step3: inverse function
Step4: sqrt function
Step5: expt function
Step6: log function
St... |
13,705 | <ASSISTANT_TASK:>
Python Code:
class AlarmSensor:
def run(self):
print ("Alarm Ring...")
class WaterSprinker:
def run(self):
print ("Spray Water...")
class EmergencyDialer:
def run(self):
print ("Dial 119...")
class Observer:
def update(self):
pass
class AlarmSensor(Obse... | <SYSTEM_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: 观察者中定义了update接口,如果... |
13,706 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'nuist', 'sandbox-3', 'atmoschem')
# 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... |
13,707 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
train=pd.read_csv('post_stockout_train_candidate.csv',parse_dates=['time_stamp_utc'])
pre_stock = pd.read_csv('pre_stockout_train_candidate.csv',parse_dates=['time_stamp_utc'])
order =pd.read_csv('pre_and_post_orders_data_train.csv')
order_test = pd.... | <SYSTEM_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='ll'>2.3 Which data to use?</a>
Step2: <a id='god'>3. Feature Engineering</a>
Step3: i saved a backup here(train_driver.csv which conta... |
13,708 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from astroML.linear_model import NadarayaWatson
import statsmodels.api as sm
import scipy.stats as stats
%matplotlib inline
sns.set_context('talk')
sns.set_style('whitegrid', {"grid.color": ".95", 'grid.linestyle': ... | <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: I will use seaborn as my visualisation choice, but I want to modify the settings slightly to make the grid and plot area a bit less in-your-face... |
13,709 | <ASSISTANT_TASK:>
Python Code:
for x in "Manish":
print(x, end=" ")
# Output: range(0, 10)
print(range(10))
# Output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
print(list(range(10)))
# Output: [2, 3, 4, 5, 6, 7]
print(list(range(2, 8)))
# Output: [2, 5, 8, 11, 14, 17]
print(list(range(2, 20, 3)))
print(list(range(20, 2, -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: In the above example, "Manish Gupta" is a sequence of characters and for loop traverse that sequence of characters. Also you will note that we a... |
13,710 | <ASSISTANT_TASK:>
Python Code:
def list_of_chars(list_chars):
# TODO: Implement me
pass
# %load test_reverse_string.py
from nose.tools import assert_equal
class TestReverse(object):
def test_reverse(self):
assert_equal(list_of_chars(None), None)
assert_equal(list_of_chars(['']), [''])
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Unit Test
|
13,711 | <ASSISTANT_TASK:>
Python Code:
import asyncio
import aiogremlin
# Create event loop and initialize gremlin client
loop = asyncio.get_event_loop()
client = aiogremlin.GremlinClient(url='ws://localhost:8182/', loop=loop) # Default url
@asyncio.coroutine
def add_vertex_routine(name, label):
yield from client.execute... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Functions for graph modification
Step2: Functions for translating a graph to node and edge lists
Step3: Let's start with an empty graph
Step4:... |
13,712 | <ASSISTANT_TASK:>
Python Code:
# Run some setup code for this notebook.
import random
import numpy as np
from cs231n.data_utils import load_CIFAR10
import matplotlib.pyplot as plt
# This is a bit of magic to make matplotlib figures appear inline in the notebook
# rather than in a new window.
%matplotlib inline
plt.rcPa... | <SYSTEM_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 would now like to classify the test data with the kNN classifier. Recall that we can break down this process into two steps
Step2: Inline Qu... |
13,713 | <ASSISTANT_TASK:>
Python Code:
# Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr>
# Romain Trachel <trachelr@gmail.com>
# Jean-Remi King <jeanremi.king@gmail.com>
#
# License: BSD-3-Clause
import mne
from mne import io, EvokedArray
from mne.datasets import sample
from mne.decoding import 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: Set parameters
Step2: Decoding in sensor space using a LogisticRegression classifier
Step3: Let's do the same on EEG data using a scikit-learn... |
13,714 | <ASSISTANT_TASK:>
Python Code:
from DSGRN import *
database = Database("querytest.db")
database.parametergraph.dimension()
database
print(database.network.specification())
monostable_query_object = MonostableQuery(database)
bistable_query_object = BistableQuery(database)
multistable_query_object = MultistableQuery(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: We show here the network being considered in this example
Step2: Query Overview
Step3: Evaluate the query on a few Morse Graph Indices
Step4: ... |
13,715 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import make_s_curve
X, y = make_s_curve(n_samples=1000)
from mpl_toolkits.mplot3d import Axes3D
ax = plt.axes(projection='3d')
ax.scatter3D(X[:, 0], X[:, 1], X[:, 2], c=y)
ax.view_init(10, -60);
from sklearn.decomposition import PCA
X_pca = PCA(n_components=2).fit_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: Este es en realidad un conjunto de datos 2D (que sería la S desenrollada), pero se ha embebido en un espacio 3D, de tal forma que un PCA no es c... |
13,716 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import codecs
import json
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from statsmodels.graphics.gofplots import qqplot
from scipy import stats as ss
import csv
from collections import Counter
from collections import defaultdict
import seaborn ... | <SYSTEM_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 Dataset of Wikipedia Edits by User from the Kaggle Data
Step2: Generate Life Tables
Step3: Kaplan Meier Survival Curve based on Days Sinc... |
13,717 | <ASSISTANT_TASK:>
Python Code:
from pgmpy.models import BayesianModel
student_model = BayesianModel()
student_model.add_nodes_from(['difficulty', 'intelligence', 'grade', 'sat', 'letter'])
student_model.nodes()
student_model.add_edges_from([('difficulty', 'grade'), ('intelligence', 'grade'), ('intelligence', 'sat'), (... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Add nodes and edges
Step2: In a Bayesian network, each node has an associated CPD (conditional probability distribution).
Step3: To check the ... |
13,718 | <ASSISTANT_TASK:>
Python Code:
----------------------------------------------------------------------
Filename : 01_basic_data_structs.py
Date : 12th Dec, 2013
Author : Jaidev Deshpande
Purpose : To get started with basic data structures in Pandas
Libraries: Pandas 0.12 and its dependencies
---------------------... | <SYSTEM_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: pandas is an open source, BSD-licensed library providing high-performance,
Step3: A pandas Series, like a list, doesn't have to... |
13,719 | <ASSISTANT_TASK:>
Python Code:
my_collection = [1, 4, 6, 10]
my_collection.append(100000)
my_collection.remove(1)
my_collection[1] = 'abcdef'
my_collection
a = [10, 20, 30, 40, 50, 60, 70]
low, high = 2, 4
a[:low]
a[low:high]
a[high:]
s = 'qwerty'
s[1:-1]
x = [1, 2, 3]
y = [10, 20, 30]
x + y
x = [2, 3]
x * 3
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: Zero-based indexing
Step2: Works with any index-supporting objects, including strings
Step3: another example
Step4: And multiplication result... |
13,720 | <ASSISTANT_TASK:>
Python Code:
from mesa import Model, Agent
class MoneyAgent(Agent):
An agent with fixed initial wealth.
def __init__(self, unique_id):
# Each agent should have a unique identifier, stored in the unique_id field.
self.unique_id = unique_id
self.wealth = 1
class MoneyMod... | <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: Boltzmann Wealth Model
Step4: With the classes defined, we can now initialize and create the model and populate it with agents.
Step9: Schedul... |
13,721 | <ASSISTANT_TASK:>
Python Code:
# we use matplotlib and specifically pyplot
# the convention is to import it like this:
import matplotlib.pyplot as plt
# We'll also read some data using astropy, so let's import that
import numpy as np
from astropy.io import ascii
# I'm also using this "magic" function to make my plots... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Let's make some sample x and y data, and plot it with the plt.plot command
Step2: You can customize a bunch of features within the plot
Step3: ... |
13,722 | <ASSISTANT_TASK:>
Python Code:
%load_ext autoreload
%autoreload 2
#Load our data
from omicexperiment.experiment.microbiome import MicrobiomeExperiment
mapping = "example_map.tsv"
biom = "example_fungal.biom"
tax = "blast_tax_assignments.txt"
exp = MicrobiomeExperiment(biom, mapping,tax)
exp.data_df
exp.mapping_df
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:
Step1: The apply function
Step2: The Rarefaction Transform
Step3: The rarefaction functions can also take a num_reps argument (default=1), to set the... |
13,723 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import load_breast_cancer
iris = load_breast_cancer()
X = iris.data
y = iris.target
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(
X, y, random_state=13
)
from sklearn.linear_model import LogisticRegress... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Instantiate the individual classifiers
Step2: Assign the individual classifiers to the voting ensemble. Here, we need to pass a
Step3: Fit the... |
13,724 | <ASSISTANT_TASK:>
Python Code:
from dolfin import *
from rbnics import *
@EIM()
class Gaussian(EllipticCoerciveProblem):
# Default initialization of members
def __init__(self, V, **kwargs):
# Call the standard initialization
EllipticCoerciveProblem.__init__(self, V, **kwargs)
# ... 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: 3. Affine decomposition
Step2: 4. Main program
Step3: 4.2. Create Finite Element space (Lagrange P1)
Step4: 4.3. Allocate an object of the Ga... |
13,725 | <ASSISTANT_TASK:>
Python Code:
def create_patients():
Creating a table of patient and ids
ids = list(range(1, 11))
doctor_ids = ['dr' + str((i % 2) + 1) for i in ids]
names = ['john', 'jeremy', 'mark', 'leslie', 'sam', 'matt', 'judy', 'parth', 'kevin', 'joshua']
patients = {
'patient_id': id... | <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: Generating Data for Examples of Unit Testing SQL Queries
Step4: Generate Data for Anomaly Detection Example
|
13,726 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
%matplotlib inline
plt.style.use('ggplot')
from mpl_toolkits.basemap import Basemap
def get_basemap(_resolution):
return Basemap(projection='merc', llcrnrlat=25, urcrnrlat=38, llcrnrlon=275, urcrnrlon=285, lat_ts=... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Charlotte rain gauge dataset 15 min data from 2003 - 2014
Step2: Read in data
Step3: Format data to year, month, day, hour, min and rainfall &... |
13,727 | <ASSISTANT_TASK:>
Python Code:
!sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst
!pip install --user google-cloud-bigquery==1.25.0
import os
from google.cloud import bigquery
%%bash
export PROJECT=$(gcloud config list project --format "value(core.project)")
echo "Your current GCP Project Name is: "$... | <SYSTEM_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 that the Google BigQuery library is installed and if not, install it.
Step2: Note
Step3: Set environment variables.
Step4: Create a Big... |
13,728 | <ASSISTANT_TASK:>
Python Code:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import xarray as xr
from pathlib import Path
import cartopy
import cartopy.crs as ccrs
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
plt.rcParams.update({"font.size": 20})
SMALL_SIZE = 22... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Then we import cartopy itself
Step2: In addition, we import cartopy's coordinate reference system submodule
Step3: A few other modules and fun... |
13,729 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import statsmodels
import scipy as sc
from statsmodels.stats.weightstats import *
%pylab inline
data = pd.read_csv('churn_analysis.csv', index_col=0)
data.head()
data['churn'].value_counts()
data1 = data[data['treatment'] == 1]
data['state'].describe... | <SYSTEM_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 7
Step2: Task 9 Z-criterion
Step3: Fischer
|
13,730 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import lhsmdu
import matplotlib.pyplot as plt
def simpleaxis(axes, every=False):
if not isinstance(axes, (list, np.ndarray)):
axes = [axes]
for ax in axes:
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Params
Step2: Theoretical values
Step3: Emperical mean ($\mu$) and standard deviation ($\sigma$) estimates
Step4: Plotting mean estimates
Ste... |
13,731 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import menpo.io as mio
path_to_lfpw = '/vol/atlas/databases/lfpw/'
images = []
for i in mio.import_images(path_to_lfpw + 'testset/*', max_images=20, verbose=True):
# convert it to greyscale if needed
if i.n_channels == 3:
i = i.as_greyscale(mode='luminos... | <SYSTEM_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. Required Widgets
Step2: We also need a way to define the crop percentage. This can be done with a simple slider that selects float numbers a... |
13,732 | <ASSISTANT_TASK:>
Python Code:
import chainer
import numpy as np
x = np.array([0, 1, 2, 3, 4]).astype('float32').reshape(-1,1)
y = x * 2 + 1
predictor = chainer.links.Linear(1,1)
model = chainer.links.Classifier(predictor, lossfun=chainer.functions.mean_squared_error,
accfun=chainer.fun... | <SYSTEM_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: II. 내장된 trainer를 사용하지 않고 학습하기
Step3: 클래스를 통한 모델 구성
|
13,733 | <ASSISTANT_TASK:>
Python Code:
import warnings
#warnings.filterwarnings("warning")
import traceback
import time
import tensorflow as tf
import matplotlib.pyplot as plt
%matplotlib inline
plt.style.use('ggplot')
from matplotlib import rcParams
rcParams['figure.figsize'] = (13, 10)
import pandas as pd
from tqdm import 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: Carregando os dados da base REDD via NILMTK
Step2: Pré-processamento dos dados
Step3: Chunking Energy Consumption in time-box (1 box = 5 minut... |
13,734 | <ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import load_boston
data = load_boston()
print(data.data.shape)
print(data.target.shape)
print(data.DESCR)
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
plt.hist(data.target)
plt.xlabel('price ($1000s)')
plt.ylabel('count');
for index, featu... | <SYSTEM_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 see that there are just over 500 data points.
Step2: It often helps to quickly visualize pieces of the data using histograms, scatter pl... |
13,735 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ncc', 'sandbox-2', 'landice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "ema... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
13,736 | <ASSISTANT_TASK:>
Python Code:
test_data = pd.read_csv("https://github.com/Evfro/RecSys_ISP2017/raw/master/test_data_new.gz", compression='gzip')
test_data.head()
ml_data = get_movielens_data()
data_model = RecommenderData(ml_data, 'userid', 'movieid', 'rating')
data_model._training = data_model._data #set training ... | <SYSTEM_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 data is not a part of the Movielens-1M dataset, however, it contains ratings for the same movies. You are expected to use this dataset to g... |
13,737 | <ASSISTANT_TASK:>
Python Code:
# Our data file is in ../scikit/tweet.csv
# in a Comma Separated Values format
# this command uses the shell to print out the first ten lines
!head ../scikit/tweets.csv
import pandas as pd # this loads the pandas library, a very useful data exploration library
import numpy as np #... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Ok, that looks good - if a little messy. Let's open the file with some python
Step2: Data frames are pretty cool, for example I can index the ... |
13,738 | <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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in wri... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Environment Preparation
Step2: Step 0
Step3: Time series forecasting using Chronos Forecaster
Step4: Initialize train, valid and test tsdatas... |
13,739 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
#carregando os dados de 2016
import pandas as pd
df = pd.read_csv('https://query.data.world/s/1ae7h2l9lvb1vapjwv9p1oga5', encoding = 'latin1')
df.head()
#Verificando tipo dados das colunas
df.info()
#Sera que temos boletins inclusive desse ano ?
df['ANO_BO'].max()
#Ve... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Sempre tive interesse em investigar todos os crimes diretamente ligados ao tráfico de drogas. Acima posso ver quais são esses.
Step2: Distribui... |
13,740 | <ASSISTANT_TASK:>
Python Code:
from astropy.table import QTable
import astropy.units as u
import numpy as np
a = [0.10, 0.15, 0.2]
b = [10.0, 2.0, 100.0] * u.M_sun / u.yr
c = [1e10, 1e9, 1e11] * u.M_sun
d = [150., 100., 2000.] * u.km / u.s
t = QTable([a, b, c, d],
names=('redshift', 'sfr', 'stellar_mass... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Here we will create a QTable which is a quantity table. The first column is the redshift of the source, the second is the star formation rate (... |
13,741 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'nasa-giss', 'sandbox-2', 'landice')
# 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... |
13,742 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import yaml
import sequenceanalyzer as sa
#import dmarkov
name = 'ternary_even_shift'
tag = 'v1'
import os
if not os.path.exists(name):
os.makedirs(name)
os.makedirs(name + '/sequences')
os.makedirs(name + '/pfsa')
os.makedirs(name + '/results')
os.... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Parameters
Step2: Original Sequence Analysis
Step3: D-Markov Machines
Step4: D-Markov Machine Analysis
Step5: Clustering
Step6: Graph Minim... |
13,743 | <ASSISTANT_TASK:>
Python Code:
from IPython.core.display import HTML
HTML('''<script>
code_show=true;
function code_toggle() {
if (code_show){
$('div.input').hide();
} else {
$('div.input').show();
}
code_show = !code_show
}
$( document ).ready(code_toggle);
</script>
<form action="javascript:code_toggle()"><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: Resolución directa de problemas
Step2: La teoría de la optimización nos dice que debemos derivar esta función e igualar el resultado a 0 para c... |
13,744 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
A = ['33.33', '33.33', '33.33', '33.37']
NA = np.asarray(A)
AVG = np.mean(NA.astype(float), axis = 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:
|
13,745 | <ASSISTANT_TASK:>
Python Code:
def pluck(arr):
if(len(arr) == 0): return []
evens = list(filter(lambda x: x%2 == 0, arr))
if(evens == []): return []
return [min(evens), arr.index(min(evens))]
<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:
|
13,746 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
from beakerx import *
pd.read_csv('../resources/data/interest-rates.csv')
table = TableDisplay(pd.read_csv('../resources/data/interest-rates.csv'))
table.setAlignmentProviderForColumn('m3', TableDisplayAlignmentProvider.CENTER_ALIGNMENT)
table.setRendererForColumn("y10... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Display mode
Step2: Display mode
Step3: Recognized Formats
Step4: Set index to DataFrame
Step5: Update cell
|
13,747 | <ASSISTANT_TASK:>
Python Code:
# Import TensorFlow and enable eager execution
# This code requires TensorFlow version >=1.9
import tensorflow as tf
tf.enable_eager_execution()
# We'll generate plots of attention in order to see which parts of an image
# our model focuses on during captioning
import matplotlib.pyplot as... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Download and prepare the MS-COCO dataset
Step2: Optionally, limit the size of the training set for faster training
Step3: Preprocess the image... |
13,748 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
import theano
import theano.tensor as T
import keras
import numpy as np
import matplotlib.pyplot as plt
from sklearn.preprocessing import LabelEncoder
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection 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: IMDB sentiment classification task
Step2: Model building
Step3: LSTM
Step4: Sentence Generation using RNN(LSTM)
|
13,749 | <ASSISTANT_TASK:>
Python Code:
from GCForest import gcForest
from sklearn.datasets import load_iris, load_digits
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
# loading the data
iris = load_iris()
X = iris.data
y = iris.target
X_tr, X_te, y_tr, y_te = train_test_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: <h2>Before starting, a word about sizes.</h2>
Step2: <p>First calling and training the algorithm.
Step3: <p>Now checking the prediction for th... |
13,750 | <ASSISTANT_TASK:>
Python Code:
print numpy.arange(5)
print numpy.linspace(0, 5, 10, endpoint=False)
print numpy.zeros(5)
print numpy.ones(5)
print numpy.ones((5,2))
print scipy.randn(5) # random Gaussian, zero-mean unit-variance
print scipy.randn(5,2)
x = numpy.arange(10)
print x[2:4]
print x[-1]
print x[0:8:2]
print... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Slicing Arrays
Step2: The optional third parameter indicates the increment value
Step3: If you omit the start index, the slice implicitly star... |
13,751 | <ASSISTANT_TASK:>
Python Code:
import math
import numpy as np
from graphviz import Digraph
import queue
# so our plots get drawn in the notebook
%matplotlib inline
from matplotlib import pyplot as plt
from random import randint
from time import clock
# A timer - runs the provided function and reports the
# run time 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: Utilities to time functions
Step2: Utilities to draw graphs
Step3: Graphs
Step4: Solution
Step5: Draw Graph
Step6: Graph with negative edge... |
13,752 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
# Tells the system to plot in-line, only necessary for iPython notebooks,
# not regular command-line python
import numpy as np
import os
import sys
import matplotlib.pyplot as plt
import time
# Now that we have our packages, we need data. The file 'make_2d_data.py' wil... | <SYSTEM_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 we want to use our shiny python scripts, we'll need to import them too.
Step2: If we want a quick man-page style summary, we can call help(s... |
13,753 | <ASSISTANT_TASK:>
Python Code:
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True, reshape=False)
DO NOT MODIFY THIS CELL
def fully_connected(prev_layer, num_units):
Create a fully connectd layer with the given 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:
Step3: Batch Normalization using tf.layers.batch_normalization<a id="example_1"></a>
Step6: We'll use the following function to create convolutional l... |
13,754 | <ASSISTANT_TASK:>
Python Code:
from cltk.core.data_types import Language
Language(
name="Classical Mongolian",
glottolog_id="",
latitude=0.0,
longitude=0.0,
dates=[],
family_id="",
parent_id="",
level="",
iso_639_3_code="cmg",
type="h",
)
from cltk.languages.glottolog import LANG... | <SYSTEM_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 following records all pre-modern languages as identified by the Glottolog project.
Step2: Word <a name="word"></a>
Step3: Doc <a name="doc... |
13,755 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
from scipy import stats, optimize
from statsmodels.regression.linear_model import WLS
from statsmodels.genmod.generalized_linear_model import GLM
from statsmodels.stats.meta_analysis import (
effectsize_smd,
effectsize_2pro... | <SYSTEM_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: estimate effect size standardized mean difference
Step3: Using one-step chi2, DerSimonian-Laird estimate for random effects var... |
13,756 | <ASSISTANT_TASK:>
Python Code:
import os
import sys
import tensorflow as tf
import inspect
import matplotlib.pyplot as plt
import numpy as np
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0, parentdir)
from util import get_... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Importing all the data
Step2: Visualizing some examples
Step3: The hyperparameters of the model are
Step4: Now, training the model using 1000... |
13,757 | <ASSISTANT_TASK:>
Python Code::
pip install kaggle
mkdir ~/.kaggle
chmod 600 ~/.kaggle/kaggle.json
cp kaggle.json ~/.kaggle/
kaggle datasets download -d 'dataset'
<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:
|
13,758 | <ASSISTANT_TASK:>
Python Code:
import os
import numpy as np
import matplotlib.pyplot as plt
import dnaMD
%matplotlib inline
try:
os.remove('cdna.h5')
except:
pass
# Initialization
dna = dnaMD.DNA(60, filename='cdna.h5') #Initialization for 60 base-pairs DNA bound with the protein
# Read Local base-pair 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: Initializing DNA object with HDF5 file
Step2: Store/Save data to HDF5 file
Step3: Example to extract a parameter
Step4: Example to extract pa... |
13,759 | <ASSISTANT_TASK:>
Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'cas', 'sandbox-2', 'landice')
# Set as follows: DOC.set_author("name", "email")
# TODO - please enter value(s)
# Set as follows: DOC.set_contributor("name", "ema... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Document Authors
Step2: Document Contributors
Step3: Document Publication
Step4: Document Table of Contents
Step5: 1.2. Model Name
Step6: 1... |
13,760 | <ASSISTANT_TASK:>
Python Code:
from igraph import Graph
from igraph import summary
import pandas
import numpy
sif_data = pandas.read_csv("shared/pathway_commons.sif",
sep="\t", names=["species1","interaction_type","species2"])
interaction_types_ppi = set(["interacts-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: Step 1
Step2: Step 2
Step3: Step 3
Step4: Step 4
|
13,761 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import YouTubeVideo
YouTubeVideo('fwNLf4t7MR8', width=800, height=450)
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from tensorflow.python import keras
from tensorflow.python.keras.models import Sequential
from tensorflow... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Exercise
Step2: Sample Model Code
Step3: Adding Strides
Step4: Make Model Larger
Step5: Add Dropout
|
13,762 | <ASSISTANT_TASK:>
Python Code:
import graphlab
sales = graphlab.SFrame('kc_house_data.gl')
sales.head(2) ## view first 2 rows of the data set
train_data,test_data = sales.random_split(.8,seed=0)
example_features = ['sqft_living', 'bedrooms', 'bathrooms']
example_model = graphlab.linear_regression.create(train_data,... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Load in house sales data
Step2: Split data into training and testing.
Step3: Learning a multiple regression model
Step4: Now that we have fit... |
13,763 | <ASSISTANT_TASK:>
Python Code:
# univariate data preparation
import numpy as np
# split a univariate sequence into samples
def split_sequence(sequence, n_steps):
X, y = list(), list()
for i in range(len(sequence)):
# find the end of this pattern
end_ix = i + n_steps
# check if we are beyond the sequence
if en... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Converting shapes
Step2: Input and output of an RNN layer
Step3: What do we see?
Step4: Multi Layer RNNs
Step5: Bidirectional RNNs
Step6: L... |
13,764 | <ASSISTANT_TASK:>
Python Code:
# Uses pip3 to install necessary package (lightgbm)
!pip3 install lightgbm
# Resets the IPython kernel to import the installed package.
import IPython
app = IPython.Application.instance()
app.kernel.do_shutdown(True)
import os
from git import Repo
# Current working directory
repo_dir = ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Necessary packages and functions call
Step2: Data loading & Sample corruption
Step3: Data preprocessing
Step4: Run DVRL
Step5: Evaluations
S... |
13,765 | <ASSISTANT_TASK:>
Python Code:
# bot-vs-bot revert table: https://quarry.wmflabs.org/query/17237
!wget https://quarry.wmflabs.org/run/161084/output/0/tsv?download=true -O botvbot.tsv
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
df = pd.read_csv("botvbot.tsv", sep="\t")
le... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Total reverts by namespace
Step2: Group by reverter and namespace
Step3: Botplots
Step4: Daily reverts subplotted by reverting bot, linear y-... |
13,766 | <ASSISTANT_TASK:>
Python Code:
%load_ext sql
%sql sqlite:///survey.db
%sql SELECT * FROM Person;
%sql mysql://mysqluser:mysqlpass@localhost/
%sql CREATE DATABASE week3demo;
%sql USE week3demo;
%sql SHOW TABLES;
%%sql
CREATE TABLE Person
(ident CHAR(10),
personal CHAR(25),
family CHAR(25));
%sql SHOW TABLES;
%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: There are warnings, but that's okay - this happens a lot these days due to the whole ipython/jupyter renaming process. You can ignore them.
Ste... |
13,767 | <ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
df = pd.read_csv('titanic-train.csv')
df.head(3)
df.info()
df['Pclass'].value_counts()
df['SibSp'].value_counts()
df['Parch'].value_counts()
df[['Ticket', 'Fare', 'Cabin']].head(3)
df['Embarked... | <SYSTEM_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) Explore the dataset
Step2: What's the content of df ?
Step3: Describe each attribute (is it discrete? is it continuous? is it a number? is ... |
13,768 | <ASSISTANT_TASK:>
Python Code:
import sys
import os
from test_helper import Test
baseDir = os.path.join('data')
inputPath = os.path.join('cs100', 'lab4', 'small')
ratingsFilename = os.path.join(baseDir, inputPath, 'ratings.dat.gz')
moviesFilename = os.path.join(baseDir, inputPath, 'movies.dat')
numPartitions = 2
rawRa... | <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: Part 0
Step4: In this lab we will be examining subsets of the tuples we create (e.g., the top rated movies by users). Whenever we examine only ... |
13,769 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from IPython.display import HTML
HTML('../style/course.css') #apply general CSS
import math
from IPython.display import HTML
HTML('../style/code_toggle.html')
import math
from matplotlib import rcParams
rcParams['tex... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Import section specific modules
Step4: 2.5. Convolution<a id='math
Step5: Figure 2.5.1
Step7: Figure 2.5.2
Step9: Figure 2.5.3
|
13,770 | <ASSISTANT_TASK:>
Python Code:
import os, shutil
# The path to the directory where the original
# dataset was uncompressed
original_dataset_dir = '/Users/fchollet/Downloads/kaggle_original_data'
# The directory where we will
# store our smaller dataset
base_dir = '/Users/fchollet/Downloads/cats_and_dogs_small'
os.mkdir... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: As a sanity check, let's count how many pictures we have in each training split (train/validation/test)
Step2: So we have indeed 2000 training ... |
13,771 | <ASSISTANT_TASK:>
Python Code:
from IPython.display import display
from sympy import init_printing
from sympy import symbols, expand, together, as_finite_diff, collect
from sympy import Function, Eq, Subs
from collections import deque
init_printing()
def finiteDifferenceOfOneTerm(factors, wrt, stencil):
Finds ... | <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: Derivation of the inversion stencil using a non-symmetric forward-backward scheme
Step3: We are here discretizing the equation
Step4: Calculat... |
13,772 | <ASSISTANT_TASK:>
Python Code:
# Common imports
import numpy as np
import pandas as pd
import zipfile as zp
from termcolor import colored
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
#To wrap long text lines
from IPython.display import HTML, 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: 1. What is spaCy
Step2: In order to use a specific model you need to download it first. If working locally, you will need to download the model... |
13,773 | <ASSISTANT_TASK:>
Python Code:
# Use matplotlib for inline graphing
import matplotlib.pyplot as plt
%matplotlib inline
from mesa import Agent, Model
from mesa.time import RandomActivation
import random
class MoneyAgent(Agent):
An agent with fixed initial wealth.
def __init__(self, unique_id):
self.un... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Simple Model
Step4: Next, create the agent and model classes
Step5: Create a model and run it for 10 steps
Step6: And display a histogram of ... |
13,774 | <ASSISTANT_TASK:>
Python Code:
((((10 + 10) * 5) / 10)**2) + 5.00 - 4.75
# Will produce 0 in python 2. produces 0.66 in python 3 because of "true" division
2/3
# the following import will change the outcome
from __future__ import division
2/3
# 4 * (6 + 5) = 44
4 * (6 + 5)
# 4 * 6 + 5 = 29
4 * 6 + 5
# 4 + 6 * 5 = 34
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Explain what the cell below will produce and why. Can you change it so the answer is correct?
Step2: Answer these 3 questions without typing co... |
13,775 | <ASSISTANT_TASK:>
Python Code:
import sympy as sp
sp.init_session(quiet=True)
var('U_LHS U_RHS')
var('dt dx beta u1:7 b1:7')
hpad = ones(0, 1); vpad = ones(1, 0)
mainDiag = 2*beta+1; offDiag = -beta
M = (sp.diag(vpad, offDiag, offDiag, offDiag, offDiag, offDiag, hpad)+ \
sp.diag(hpad, offDiag, offDiag, offDiag, ... | <SYSTEM_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 define the symbols we want to use in our linear system. For this demonstration, I don't add the time index but I keep my subscripts consiste... |
13,776 | <ASSISTANT_TASK:>
Python Code:
# Initialize the counter
i = 1
# Loop while printing out and incrementing the values of the counter
while i <= 10:
print(i)
# Increment the counter inside the loop
i = i + 1
# Obtain the required number of passes from the user
num_passes = int(input("How many rows would you ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: U sledećem primeru, broj ponavljanja zavisiće od broja koji korisnik unese s tastature, a prvi i poslednji prolazak kroz petlju razlikovaće se o... |
13,777 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pandas as pd
import seaborn as sns
from scipy import stats
import numpy as np
import matplotlib.pyplot as plt # side-stepping mpl backend
import warnings
warnings.filterwarnings("ignore") #YOLO
import seaborn as sns
sns.set_context('notebook', font_scale=1.5)
!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: Fetch open data
Step2: It has almost 400,000 rows!
Step3: Yuck, that's a scatter plot. Let's make a 2D (Hess) diagram.
Step4: That looks bet... |
13,778 | <ASSISTANT_TASK:>
Python Code:
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, sof... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: On Variational Bounds of Mutual Information
Step2: Variational bound implementations
Step4: InfoNCE contrastive lower bound
Step8: Interpolat... |
13,779 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
from scipy import stats, integrate
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(color_codes=True)
np.random.seed(sum(map(ord, "distributions")))
x = np.random.normal(size=100) # 单变量分布将绘制 直方图,并绘制 KDE (核心密度函数)
sns.distplot(x) # 分布绘制
pl... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: 核密度KDE的估计是对每个rug进行估计,然后把所有的KDE曲线加起来,之后进行归一化,得到所有的数据的平均KDE曲线
Step2: 还可以使用distplot()拟合参数分布到数据集,并直观地评估它与观察数据的对应关系
Step3: 可视化数据集中的成对关系¶
Step4: 用分... |
13,780 | <ASSISTANT_TASK:>
Python Code:
from pygoose import *
import os
import warnings
import gensim
from fuzzywuzzy import fuzz
from nltk import word_tokenize
from nltk.corpus import stopwords
from scipy.stats import skew, kurtosis
from scipy.spatial.distance import cosine, cityblock, jaccard, canberra, euclidean, minkowski, ... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Config
Step2: Identifier for storing these features on disk and referring to them later.
Step3: The path to the saved GoogleNews Word2Vec mode... |
13,781 | <ASSISTANT_TASK:>
Python Code:
import ROOT
%%cpp -d
//Define functions for fitting
// Quadratic background function
double background(double *x, double *par) {
return par[0] + par[1]*x[0] + par[2]*x[0]*x[0];
}
// Lorenzian Peak function
double lorentzianPeak(double *x, double *par) {
return (0.5*par[0]*par[1]/TMa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Inject into the interpreter the functions.
Step2: Construct the histogram containing the input data
Step3: Create the function and try to fit ... |
13,782 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns; sns.set()
from sklearn.datasets import make_blobs
X, y = make_blobs(100, 2, centers=2, random_state=2, cluster_std=1.5)
plt.scatter(X[:, 0], X[:, 1], c=y, s=50, cmap='RdBu');
from sklearn.naive_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: Scikit-Learn 中的 make_blobs 方法常被用来生成聚类算法的测试数据,直观地说,make_blobs 会根据用户指定的特征数量、中心点数量、范围等来生成几类数据,这些数据可用于测试聚类算法的效果。接下来,我们导入朴素贝叶斯分类函数 GaussianNB ,构建并拟合模... |
13,783 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import scipy.special as sp
def newfig(title='?', xlabel='?', ylabel='?', xlim=None, ylim=None,
xscale='linear', yscale='linear', size_inches=(14, 8)):
'''Setup a new axis for plotting'''
fig, ax = plt.subplots(... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Convenience function for setting up graphs
Step2: Compare this result with the that of the analytical formula on page 63 of the syllabus, which... |
13,784 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import scipy.signal as signal
import seawater as sw
from pyspec import spectrum as spec
fni = "data/lg0703_nb150.npz"
data = np.load(fni)
fmax = 135
lon,lat = data['lon1'][:fmax],data['lat1'][:fmax]
u, v = data['u1'][... | <SYSTEM_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: Select a gap-free segment
Step3: Plot spectra
|
13,785 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
import functools
from scipy.optimize import bisect
%matplotlib inline
%config InlineBackend.figure_format = 'svg'
plt.rcParams['mathtext.fontset'] = 'cm'
plt.figure(figsize=(2,5))
x = [0,1,1,0,0]
y = [1,1,1.5,1.5,1]
plt.text(-0.6,1.02,'$... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Posing the problem
Step2: Porosity decrease with depth
Step3: While the compaction trends for mud happen to be fairly similar in the plot abov... |
13,786 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pyfolio as pf
stock_rets = pf.utils.get_symbol_rets('FB')
pf.create_returns_tear_sheet(stock_rets, live_start_date='2015-12-1')
<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: Fetch the daily returns for a stock
Step2: Create a full tear sheet for the single stock
|
13,787 | <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: Custom layers
Step2: Layers
Step3: The full list of pre-existing layers can be seen in the documentation. It includes Dense (a fully-connected... |
13,788 | <ASSISTANT_TASK:>
Python Code:
import os; os.chdir('../choicemodels')
import choicemodels
import numpy as np
import pandas as pd
import statsmodels.api as sm # for binary logit
from collections import OrderedDict # for MNL model specifications
# Import or generate estimation data
Y = np.random.randint(2, size=50) #... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Binary Logit
Step3: Multinomial Logit
Step5: This is what the data looks like
Step7: MNL with random sampling of alternatives
|
13,789 | <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:
Step2: Inspecting Quantization Errors with Quantization Debugger
Step3: We can see that the original model has a much higher top-5 accuracy for our
St... |
13,790 | <ASSISTANT_TASK:>
Python Code:
# Copyright 2018 The TensorFlow Hub Authors. All Rights Reserved.
#
# 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
#
# http://www.apache.org/licenses/LICENSE... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: DELF と TensorFlow Hub を使用して画像を一致させる方法
Step2: データ
Step3: 画像のダウンロード、サイズ変更、保存、および表示を行います。
Step4: データに DELF モジュールを適用する
Step5: ベクトルのロケーションと説明を使用し... |
13,791 | <ASSISTANT_TASK:>
Python Code:
?
%quickref
help
a = 1
a?
!cd /
!pwd
%cd /
!pwd
%cd ~/YAPT
!pwd
%whos
a
%time a=3
a
a
%timeit a=4
a
%run hello_world.py
# %load module.py
a = 1
%run module.py
%whos
a
!cat substract_curves.py
!paste dataset1.txt dataset2.txt
%run -t substract_curves.py dataset1.txt dataset2.txt
... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: %quickref
Step2: help
Step3: object?
Step4: ! <command>
Step5: %cd
Step6: who/whos
Step7: %time <Python statement/expression>
... |
13,792 | <ASSISTANT_TASK:>
Python Code:
%pylab inline
from IPython.display import Image
Image(filename='images/optimizing-what.png')
%%file hellofortran.f
C File hellofortran.f
subroutine hellofortran (n)
integer n
do 100 i=0, n
print *, "Fortran says hello"
100 continue
... | <SYSTEM_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 advantage of Python is that it is flexible and easy to program. The time it takes to setup a new calulation is therefore short. But for cert... |
13,793 | <ASSISTANT_TASK:>
Python Code:
!hybridizer-cuda ./01-Naive/01-naive.cs ./Common_Files/SparseMatrixNaive.cs -o ./01-Naive/naive.exe -run
!hybridizer-cuda ./02-Parallel/01-parallelism.cs ./Common_Files/SparseMatrixNaive.cs -o ./02-Parallel/01-parallelism.exe -run
!hybridizer-cuda ./03-GPU/01-gpu.cs ./Common_Files/Spars... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Parallelism
Step2: GPU
Step3: Resident Array
|
13,794 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
%config InlineBackend.figure_format = 'svg'
%load_ext autoreload
%autoreload 2
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import numpy as np
import tensorflow as tf
from matplotlib.animation import FuncAnimation
from matplotlib.path import Path... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Getting the Pre-Trained Models and Data
Step2: We look at the layer normalized model trained on the aaron_sheep dataset for now.
Step3: The re... |
13,795 | <ASSISTANT_TASK:>
Python Code:
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import pickle
import os
import gzip
import numpy as np
import theano
import lasagne
from lasagne import layers
from lasagne.updates import nesterov_momentum
from nolearn.lasagne import NeuralNet
from nolearn.lasa... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: MNIST Dataset
Step2: Convolution Networks
Step3: Prediction
Step4: Theano & Feature Extraction
|
13,796 | <ASSISTANT_TASK:>
Python Code:
from bisect import bisect_left
def solve(N , X , Y ) :
p =[]
for i in range(N ) :
p . append([ X[i ] , Y[i ] ] )
p = sorted(p )
s = { }
s[p[0 ][1 ] ] = 1
for i in range(N ) :
arr = list(s . keys() )
it = bisect_left(arr , p[i ][1 ] )
if(it == len(s ) ) :
s[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:
|
13,797 | <ASSISTANT_TASK:>
Python Code:
from jyquickhelper import add_notebook_menu
add_notebook_menu()
from flask import Flask # pip install flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
# if __name__ == "__main__":
# app.run()
from flask import Flask
app = Flask(__name__)
def hell... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Comment ça marche ?
Step2: Explication du code pas à pas
Step3: On donne ensuite un nom à l'application ici ce sera app
Step4: Ensuite vient ... |
13,798 | <ASSISTANT_TASK:>
Python Code:
import numpy as np
import matplotlib.pyplot as plt
from ipywidgets import interact, fixed, FloatSlider
%matplotlib inline
rho = 0
N = 5
T = 15
V = 1
def shocks(rho=0, N=N, T=T):
'''Returns an N by T matrix of multivariate normally distributed shocks with correlation rho'''
mea... | <SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1: Default parameters
Step2: Examples
Step3: Correlated incomes
Step4: Negatively correlated
|
13,799 | <ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import pymc3 as pm
import theano.tensor as T
import theano
import sklearn
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('white')
from sklearn import datasets
from sklearn.preprocessing import scale
from sklearn.cross_validation 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: Model specification
Step2: That's not so bad. The Normal priors help regularize the weights. Usually we would add a constant b to the inputs bu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.