Unnamed: 0 int64 0 16k | text_prompt stringlengths 110 62.1k | code_prompt stringlengths 37 152k |
|---|---|---|
5,800 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Saving models
It is possible to save fitted Prophet models so that they can be loaded and used later.
In R, this is done with saveRDS and readRDS
Step1: In Python, models should not be save... | Python Code:
%%R
saveRDS(m, file="model.RDS") # Save model
m <- readRDS(file="model.RDS") # Load model
Explanation: Saving models
It is possible to save fitted Prophet models so that they can be loaded and used later.
In R, this is done with saveRDS and readRDS:
End of explanation
import json
from prophet.serialize i... |
5,801 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Exploring the H-2B Visa Programme
H-2B visas are nonimmigrant visas, which allow foreign nationals to enter the U.S. temporarily and engage in nonagricultural employment which is seasonal, i... | Python Code:
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
df = pd.read_excel("H-2B_Disclosure_Data_FY15_Q4.xlsx")
df.head()
#df.info()
Explanation: Exploring the H-2B Visa Programme
H-2B visas are nonimmigrant visas, which allow foreign nationals to enter the U.S. temporarily and engage in non... |
5,802 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
ES-DOC CMIP6 Model Properties - Seaice
MIP Era
Step1: Document Authors
Set document authors
Step2: Document Contributors
Specify document contributors
Step3: Document Publication
Specify ... | Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'fio-ronm', 'sandbox-1', 'seaice')
Explanation: ES-DOC CMIP6 Model Properties - Seaice
MIP Era: CMIP6
Institute: FIO-RONM
Source ID: SANDBOX-1
Topic: Seaice
Sub-Topics: Dynamics, Therm... |
5,803 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
TensorFlow Basics & Convolution
TensorFlow does not do computation immediately but constructs a graph. We define everything that we want to compute, in a graph and running it requires a sess... | Python Code:
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
x = np.linspace(-3, 3, 5) # Computes values immediately
print x
Explanation: TensorFlow Basics & Convolution
TensorFlow does not do computation immediately but constructs a graph. We define everything that we want... |
5,804 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
ipython
ipython is an interactive version of the python interpreter. It provides a number of extras which are helpful when writing code. ipython code is almost always python code, and the di... | Python Code:
## Try the autocomplete ... it works on functions that are in scope
# pr
# it also works on variables
# long_but_helpful_variable_name = 1
# long_b
Explanation: ipython
ipython is an interactive version of the python interpreter. It provides a number of extras which are helpful when writing code. ipython c... |
5,805 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Moving from Python 2 to Python 3
Python 2 has a limited lifetime, and by 2020, there will no longer be any active development on Python 2.
http
Step1: A (non-exhaustive) list of differences... | Python Code:
import sys
print(sys.version)
Explanation: Moving from Python 2 to Python 3
Python 2 has a limited lifetime, and by 2020, there will no longer be any active development on Python 2.
http://legacy.python.org/dev/peps/pep-0373/
Why? Apparently it was easier to make a shiny new python by breaking backwards c... |
5,806 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Symca
Symca is used to perform symbolic metabolic control analysis [1] on metabolic pathway models in order to dissect the control properties of these pathways in terms of the different chai... | Python Code:
mod = pysces.model('lin4_fb')
mod.doLoad() # this method call is necessary to ensure that future `doLoad` method calls are executed correctly
sc = psctb.Symca(mod)
Explanation: Symca
Symca is used to perform symbolic metabolic control analysis [1] on metabolic pathway models in order to dissect the control... |
5,807 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<h1 align="center">Simple Conditional Statements</h1>
<h2>01.Excellent Result</h2>
The first task of this topic is to write a console program that introduces an estimate (decimal number) and... | Python Code:
num = float(input())
if num >= 5.50:
print("Excellent!")
Explanation: <h1 align="center">Simple Conditional Statements</h1>
<h2>01.Excellent Result</h2>
The first task of this topic is to write a console program that introduces an estimate (decimal number) and prints "Excellent!" if the score is 5.50 o... |
5,808 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Convergence
Description of the UCI protocol
Step1: The Speed of Search
The number of nodes searched depend linearly on time
Step2: So nodes per second is roughly constant
Step3: The hasht... | Python Code:
%pylab inline
! grep "multipv 1" log4.txt | grep -v lowerbound | grep -v upperbound > log4_g.txt
def parse_info(l):
D = {}
k = l.split()
i = 0
assert k[i] == "info"
i += 1
while i < len(k):
if k[i] == "depth":
D[k[i]] = int(k[i+1])
i += 2
eli... |
5,809 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Part 1
Step1: The following assumes that the folder containing the 'dat' files is in a directory called 'fixtures' in the same directory as this script. You can also enter a full path to t... | Python Code:
import warnings
import scipy as sp
import numpy as np
import openpnm as op
np.set_printoptions(precision=4)
np.random.seed(10)
%matplotlib inline
Explanation: Part 1: Import Networks from Statoil Files
This example explains how to use the OpenPNM.Utilies.IO.Statoil class to import a network produced by the... |
5,810 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
The
Step1: Continuous data is stored in objects of type
Step2: <div class="alert alert-info"><h4>Note</h4><p>Accessing the `._data` attribute is done here for educational
purpo... | Python Code:
from __future__ import print_function
import mne
import os.path as op
from matplotlib import pyplot as plt
Explanation: The :class:Raw <mne.io.Raw> data structure: continuous data
End of explanation
# Load an example dataset, the preload flag loads the data into memory now
data_path = op.join(mne.dat... |
5,811 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Sheet Copy
Copy tab from a sheet to a sheet.
License
Copyright 2020 Google LLC,
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance... | Python Code:
!pip install git+https://github.com/google/starthinker
Explanation: Sheet Copy
Copy tab from a sheet to a sheet.
License
Copyright 2020 Google LLC,
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 L... |
5,812 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Anna KaRNNa
In this notebook, I'll build a character-wise RNN trained on Anna Karenina, one of my all-time favorite books. It'll be able to generate new text based on the text from the book.... | Python Code:
import time
from collections import namedtuple
import numpy as np
import tensorflow as tf
Explanation: Anna KaRNNa
In this notebook, I'll build a character-wise RNN trained on Anna Karenina, one of my all-time favorite books. It'll be able to generate new text based on the text from the book.
This network ... |
5,813 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Introduction to Python programming
This crash course on python is take from two souces
Step1: built in magic commands start with
A good list of the commands are found in
Step2: Character e... | Python Code:
ls ..\..\Scripts\hello-world*.py
Explanation: Introduction to Python programming
This crash course on python is take from two souces:
http://github.com/jrjohansson/scientific-python-lectures.
and
Chapter 2 of the Datascience from scratch: First principles with python
Python program files
Python code is usu... |
5,814 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Machine Learning Engineer Nanodegree
Supervised Learning
Project 2
Step1: Implementation
Step2: Preparing the Data
In this section, we will prepare the data for modeling, training and test... | Python Code:
# Import libraries
import numpy as np
import pandas as pd
from time import time
from sklearn.metrics import f1_score
# Read student data
student_data = pd.read_csv("student-data.csv")
print "Student data read successfully!"
Explanation: Machine Learning Engineer Nanodegree
Supervised Learning
Project 2: Bu... |
5,815 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
A Simple Autoencoder
We'll start off by building a simple autoencoder to compress the MNIST dataset. With autoencoders, we pass input data through an encoder that makes a compressed represen... | Python Code:
%matplotlib inline
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data', validation_size=0)
Explanation: A Simple Autoencoder
We'll start off by building a simple autoencoder to c... |
5,816 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Interact Exercise 6
Imports
Put the standard imports for Matplotlib, Numpy and the IPython widgets in the following cell.
Step1: Exploring the Fermi distribution
In quantum statistics, the ... | Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from IPython.display import Image
from IPython.html.widgets import interact, interactive, fixed
Explanation: Interact Exercise 6
Imports
Put the standard imports for Matplotlib, Numpy and the IPython widgets in the following cell.
End of... |
5,817 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<h1>Table of Contents<span class="tocSkip"></span></h1>
<div class="toc"><ul class="toc-item"><li><span><a href="#Spicing-It-Up!-(Sorry)" data-toc-modified-id="Spicing-It-Up!-(Sorry)-1"><spa... | Python Code:
from IPython.core.display import HTML
HTML(open('custom.css', 'r').read())
Explanation: <h1>Table of Contents<span class="tocSkip"></span></h1>
<div class="toc"><ul class="toc-item"><li><span><a href="#Spicing-It-Up!-(Sorry)" data-toc-modified-id="Spicing-It-Up!-(Sorry)-1"><span class="toc-item-num">1 ... |
5,818 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Fashion MNIST with Keras and TPUs
<table class="tfo-notebook-buttons" align="left">
<td>
<a target="_blank" href="https
Step1: Defining our model
We will use a standard conv-net for th... | Python Code:
import tensorflow as tf
import numpy as np
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.fashion_mnist.load_data()
# add empty color dimension
x_train = np.expand_dims(x_train, -1)
x_test = np.expand_dims(x_test, -1)
Explanation: Fashion MNIST with Keras and TPUs
<table class="tfo-notebook-butto... |
5,819 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Copyright 2018 Google LLC.
Step1: Introduction to ML Fairness
Disclaimer
This exercise explores just a small subset of ideas and techniques relevant to fairness in machine learning; it is ... | 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, software
# distribute... |
5,820 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Simulating with FBA
Simulations using flux balance analysis can be solved using Model.optimize(). This will maximize or minimize (maximizing is the default) flux through the objective reacti... | Python Code:
import pandas
pandas.options.display.max_rows = 100
import cobra.test
model = cobra.test.create_test_model("textbook")
Explanation: Simulating with FBA
Simulations using flux balance analysis can be solved using Model.optimize(). This will maximize or minimize (maximizing is the default) flux through the o... |
5,821 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Composing a pipeline from reusable, pre-built, and lightweight components
This tutorial describes how to build a Kubeflow pipeline from reusable, pre-built, and lightweight components. The f... | Python Code:
import kfp
import kfp.gcp as gcp
import kfp.dsl as dsl
import kfp.compiler as compiler
import kfp.components as comp
import datetime
import kubernetes as k8s
# Required Parameters
PROJECT_ID='<ADD GCP PROJECT HERE>'
GCS_BUCKET='gs://<ADD STORAGE LOCATION HERE>'
Explanation: Composing a pipeline from reusab... |
5,822 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Comparing Russell Westbrook and Oscar Robertson's Triple Double Seasons
Author
Step1: After adjusting Westbrook and Robertson's per game stats to a per minute basis, Westbrook has the edge.... | Python Code:
# importing packages
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
# all data is obtained through basketball-reference.com
# http://www.basketball-reference.com/teams/OKC/2017.html
# http://www.basketball-reference.com/teams/CIN/1962.html
# http://www.basketball-reference.com/leagu... |
5,823 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Lab 3 - Morphological image processing <a class="tocSkip">
Import dependencies
Step1: Erosion / dilation steps | Python Code:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import matplotlib.image as mpimg
import cv2
%%bash
ls -l | grep .tiff
img = mpimg.imread('Lab_3_DIP.tiff')
plt.figure(figsize=(15,10))
plt.imshow(img)
Explanation: Lab 3 - Morphological image processing <a class="tocSkip">
Import depende... |
5,824 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Linear regression using Batch Gradient Descent
Building linear regression from ground up
Step1: Our Linear Regression Model
This python class contains our Linear Regression model/algo. We u... | Python Code:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
Explanation: Linear regression using Batch Gradient Descent
Building linear regression from ground up
End of explanation
class linear_regression():
def __init__(self):
self.weights = None
self.learning_rate =... |
5,825 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<a id="top"></a>
Composites
<hr>
Background
Composites are 2-dimensional representations of 3-dimensional data.
There are many cases in which this is desired. Sometimes composites are used i... | Python Code:
import sys
import os
sys.path.append(os.environ.get('NOTEBOOK_ROOT'))
from utils.data_cube_utilities.clean_mask import landsat_clean_mask_full
# landsat_qa_clean_mask, landsat_clean_mask_invalid
from utils.data_cube_utilities.dc_mosaic import create_hdmedians_multiple_band_mosaic
from utils.data_cube_utili... |
5,826 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
DirectLiNGAM
Import and settings
In this example, we need to import numpy, pandas, and graphviz in addition to lingam.
Step1: Test data
We create test data consisting of 6 variables.
Step2:... | Python Code:
import numpy as np
import pandas as pd
import graphviz
import lingam
from lingam.utils import make_dot
print([np.__version__, pd.__version__, graphviz.__version__, lingam.__version__])
np.set_printoptions(precision=3, suppress=True)
np.random.seed(100)
Explanation: DirectLiNGAM
Import and settings
In this ... |
5,827 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
KMeans
Step1: 2. Scikit
Scikit is a machine learning library for Python built upon numpy and matplotlib. It provides functions for classification, regression, clustering and other common an... | Python Code:
%matplotlib inline
import pandas as pd
import seaborn as sns
import numpy as np
data = pd.read_csv("https://raw.githubusercontent.com/pydata/pandas/master/pandas/tests/data/iris.csv")
data.head()
Explanation: KMeans: Scitkit, Pilot and Spark/MLlib
This is perhaps the best known database to be found in the ... |
5,828 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Executing a python file
Step1: Executing a python function
Step2: Executing a complete notebook
Step3: Executing it with large #CPUs and huge Memory
You Kubernetes cluster should have a n... | Python Code:
%%writefile train.py
print("hello world!")
job = TrainJob("train.py", backend=KubeflowGKEBackend())
job.submit()
Explanation: Executing a python file
End of explanation
def train():
print("simple train job!")
job = TrainJob(train, backend=KubeflowGKEBackend())
job.submit()
Explanation: Executing a pyth... |
5,829 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Aprendizaje out-of-core
Problemas de escalabilidad
Las clases sklearn.feature_extraction.text.CountVectorizer y sklearn.feature_extraction.text.TfidfVectorizer tienen una serie de problemas ... | Python Code:
from sklearn.feature_extraction.text import CountVectorizer
vectorizer = CountVectorizer(min_df=1)
vectorizer.fit([
"The cat sat on the mat.",
])
vectorizer.vocabulary_
Explanation: Aprendizaje out-of-core
Problemas de escalabilidad
Las clases sklearn.feature_extraction.text.CountVectorizer y sklearn.f... |
5,830 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Portuguese Bank Marketing Stratergy- TPOT Tutorial
The data is related with direct marketing campaigns of a Portuguese banking institution. The marketing campaigns were based on phone calls.... | Python Code:
# Import required libraries
from tpot import TPOTClassifier
from sklearn.cross_validation import train_test_split
import pandas as pd
import numpy as np
#Load the data
Marketing=pd.read_csv('Data_FinalProject.csv')
Marketing.head(5)
Explanation: Portuguese Bank Marketing Stratergy- TPOT Tutorial
The data ... |
5,831 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
2A.soft - Jupyter et commandes magiques
Pour être inventif, il faut être un peu paresseux. Cela explique parfois la syntaxe peu compréhensible mais réduite de certaines instructions. Cela ex... | Python Code:
from jyquickhelper import add_notebook_menu
add_notebook_menu()
Explanation: 2A.soft - Jupyter et commandes magiques
Pour être inventif, il faut être un peu paresseux. Cela explique parfois la syntaxe peu compréhensible mais réduite de certaines instructions. Cela explique sans doute aussi que Jupyter offr... |
5,832 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Step4: Loading our Previous Functions...
Step5: Possible Solution
Step6: Okay, so now that we have the reveal and flag functions sorted, we are dangeriously close to actually playing a gam... | Python Code:
import random
def set_square(x, y, new_val, board):
This function indexes into the given board at position (x, y).
We then change that value to new_val. Returns nothing.
board[x][y] = new_val
def get_square(x, y, board):
This function takes a board and returns the value at th... |
5,833 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Introduction
This notebook demonstrates how BioThings Explorer can be used to answer the following query
Step1: Step 1
Step2: Step 2
Step3: The df object contains the full output from Bio... | Python Code:
!pip install git+https://github.com/biothings/biothings_explorer#egg=biothings_explorer
Explanation: Introduction
This notebook demonstrates how BioThings Explorer can be used to answer the following query:
"Finding Marketed Drugs that Might Treat an Un... |
5,834 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Problemas de classificação representam uma ampla categoria de problemas de machine learning que envolvem a previsão de valores dentro de um conjunto finito e discreto de casos.
Neste exemplo... | Python Code:
import pandas as pd
iris = # carregue o arquivo 'datasets/iris.csv'
# Exiba informações sobre o dataset
# Exiba as classes presentes nesse dataset usando o método unique() na coluna "Class"
# Use o método describe() para exibir estatísticas sobre o dataset
Explanation: Problemas de classificação representa... |
5,835 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<h2>This example shows how to create flight track plots using AWOT
Step1: Supply user input information
Step2: <li>Set up some characteristics for plotting.
<li>Use Cylindrical Equidistan... | Python Code:
# Load the needed packages
import numpy as np
import matplotlib.pyplot as plt
from awot.io.flight import read_netcdf
from awot.graph.common import create_basemap
from awot.graph.flight_level import FlightLevel
%matplotlib inline
Explanation: <h2>This example shows how to create flight track plots using AWO... |
5,836 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Working with data 2017. Class 3
Contact
Javier Garcia-Bernardo
garcia@uva.nl
0. Structure
Error debugging
Data visualization theory
Scatter
Histograms, violinplots and two histograms (jointp... | Python Code:
##Some code to run at the beginning of the file, to be able to show images in the notebook
##Don't worry about this cell
#Print the plots in this screen
%matplotlib inline
#Be able to plot images saved in the hard drive
from IPython.display import Image
#Make the notebook wider
from IPython.core.display ... |
5,837 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Regular Expression
| | | |
|----------|--------------------------------------------|---|
| ^ | the start of a line ... | Python Code:
import re
emaildata = open('enron-email-dataset.txt')
for line in emaildata:
line = line.rstrip()
if re.search('^From:', line):
print(line)
x = 'Team A beat team B 38-7. That was the greatest record for team A since 1987.'
y = re.findall('[0-9]+', x)
y
Explanation: Regular Expression
| ... |
5,838 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<a href='http
Step1: Dataset
We will use the famous Iris Data set.
More info on the data set
Step2: Split the Data into Training and Test
Its time to split the data into a train/test set. ... | Python Code:
import numpy as np
Explanation: <a href='http://www.pieriandata.com'> <img src='../Pierian_Data_Logo.png' /></a>
Keras Basics
Welcome to the section on deep learning! We'll be using Keras with a TensorFlow backend to perform our deep learning operations.
This means we should get familiar with some Keras fu... |
5,839 | Given the following text problem statement, write Python code to implement the functionality described below in problem statement
Problem:
How can I get get the position (indices) of the second largest value in a multi-dimensional NumPy array `a`? | Problem:
import numpy as np
a = np.array([[10,50,30],[60,20,40]])
idx = np.unravel_index(a.argmax(), a.shape)
a[idx] = a.min()
result = np.unravel_index(a.argmax(), a.shape) |
5,840 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
View Northeast Pacific SST based on an Ensemble Empirical Mode Decomposition
The oscillation of sea surface temperature (SST) has substantial impacts on the global climate. For example, anom... | Python Code:
%matplotlib inline
import xarray as xr
from PyEMD import EEMD
import numpy as np
import pylab as plt
plt.rcParams['figure.figsize'] = (9,5)
Explanation: View Northeast Pacific SST based on an Ensemble Empirical Mode Decomposition
The oscillation of sea surface temperature (SST) has substantial impacts on t... |
5,841 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Almond Nut Learner
Use published rankings together with distance traveled to play to classify winners + losers
Train to regular season and test on post season
considerations
Step1: Feature ... | Python Code:
def attach_ratings_diff_stats(df, ratings_eos, season):
out_cols = list(df.columns) + ['mean_rtg_1', 'std_rtg_1', 'num_rtg_1', 'mean_rtg_2', 'std_rtg_2', 'num_rtg_2']
rtg_1 = ratings_eos.rename(columns = {'mean_rtg' : 'mean_rtg_1', 'std_rtg' : 'std_rtg_1', 'num_rtg' : 'num_rtg_1'})
rtg_2 = rati... |
5,842 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
An introduction to matplotlib
Matplotlib is a Python package used widely throughout the scientific Python community to produce high quality 2D publication graphics. It transparently supports... | Python Code:
import matplotlib.pyplot as plt
Explanation: An introduction to matplotlib
Matplotlib is a Python package used widely throughout the scientific Python community to produce high quality 2D publication graphics. It transparently supports a wide range of output formats including PNG (and other raster formats)... |
5,843 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
The Lasso
Stats 208
Step1: Wavelet reconstruction
Can reconstruct the sequence by
$$
\hat y = W \hat \beta.
$$
The objective is likelihood term + L1 penalty term,
$$
\frac 12 \sum_{i=1}^T (... | Python Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
## Explore Turkish stock exchange dataset
tse = pd.read_excel('../../data/data_akbilgic.xlsx',skiprows=1)
tse = tse.rename(columns={'ISE':'TLISE','ISE.1':'USDISE'})
def const_wave(T,a,b):
wave = np.zeros(T)
s1 = (b-a) // 2
s... |
5,844 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Inversion sampling example
First find the normalizing constant
Step1: Joint Distribution
Find the normalizing constant
Step2: Find the marginal distribution | Python Code:
%%latex
\begin{align*}
f_X(X=x) &= cx^2, 0 \leq x \leq 2 \\
1 &= c\int_0^2 x^2 dx \\
&= c[\frac{1}{3}x^3 + d]_0^2 \\
&= c[\frac{8}{3} + d - d] \\
&= c[\frac{8}{3}] \\
f_X(X=x) &= \frac{3}{8}x^2, 0 \leq x \leq 2
\end{align*}
u = np.random.uniform(size=100000)
x = 2 * u**.3333
df = pd... |
5,845 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Copyright 2020 The TensorFlow Authors.
Step1: Tensorflow Lattice를 사용한 윤리에 대한 형상 제약 조건
<table class="tfo-notebook-buttons" align="left">
<td><a target="_blank" href="https
Step2: 필수 패키지 가... | 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 writing, software
# dist... |
5,846 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<a href='http
Step1: A simple DynamicMap
Let us now create a simple DynamicMap using three annotation elements, namely Box, Text, and Ellipse
Step2: This example uses the concepts introduc... | Python Code:
import numpy as np
import pandas as pd
import holoviews as hv
hv.extension('bokeh', 'matplotlib')
%opts Ellipse [xaxis=None yaxis=None] (color='red' line_width=2)
%opts Box [xaxis=None yaxis=None] (color='blue' line_width=2)
Explanation: <a href='http://www.holoviews.org'><img src="assets/hv+bk.png" alt="H... |
5,847 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Depression Identification Simulation
Note
Step1: 1. State assumptions about your data
X has size
Step2: Training & Test Utilities
Step3: 4 & 5. Sample data from a simulation setting & Com... | Python Code:
import pandas as pd
import numpy as np
df_feats = pd.read_csv('reduced_data.csv')
df_labels = pd.read_csv('disorders.csv')['Depressed']
Explanation: Depression Identification Simulation
Note: The features are generated using PCA.ipynb.
End of explanation
np.random.seed(12345678) # for reproducibility, set ... |
5,848 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Horizontal Bar Charts
Best suited for categories comparison
Example 1
Step1: You can also save your chart with the save method
Step2: Example 2
Step3: Vertical Bar Charts
Ideal for a smal... | Python Code:
data = dict(
labels=['Bananas','Apples','Oranges','Watermelons','Grapes','Kiwis'],
values=[4000,8000,3000,1600,1000,2500]
)
out = StdCharts.HBar(data)
HTML(out)
Explanation: Horizontal Bar Charts
Best suited for categories comparison
Example 1: default options, "as is"
End of explanation
StdCharts.... |
5,849 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Step1: Dropout and Data Augmentation
In this exercise we will implement two ways to reduce overfitting.
Like the previous assignment, we will train ConvNets to recognize the categories in CI... | Python Code:
# A bit of setup
import numpy as np
import matplotlib.pyplot as plt
from time import time
from cs231n.layers import *
from cs231n.fast_layers import *
%matplotlib inline
plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['im... |
5,850 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Reusable Embeddings
Learning Objectives
1. Learn how to use a pre-trained TF Hub text modules to generate sentence vectors
1. Learn how to incorporate a pre-trained TF-Hub module into a Kera... | Python Code:
import os
from google.cloud import bigquery
import pandas as pd
%load_ext google.cloud.bigquery
Explanation: Reusable Embeddings
Learning Objectives
1. Learn how to use a pre-trained TF Hub text modules to generate sentence vectors
1. Learn how to incorporate a pre-trained TF-Hub module into a Keras model
... |
5,851 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
ES-DOC CMIP6 Model Properties - Landice
MIP Era
Step1: Document Authors
Set document authors
Step2: Document Contributors
Specify document contributors
Step3: Document Publication
Specify... | Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'mri', 'sandbox-3', 'landice')
Explanation: ES-DOC CMIP6 Model Properties - Landice
MIP Era: CMIP6
Institute: MRI
Source ID: SANDBOX-3
Topic: Landice
Sub-Topics: Glaciers, Ice.
Proper... |
5,852 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Using the BISON API
The USGS provides an API for accessing species observation data. https
Step1: Yikes, that's much less readable than the NWIS output!
Well, that's because the response fr... | Python Code:
#First, import the wonderful requests module
import requests
#Now, we'll deconstruct the example URL into the service URL and parameters, saving the paramters as a dictionary
url = 'http://bison.usgs.gov/api/search.json'
params = {'species':'Bison bison',
'type':'scientific_name',
'star... |
5,853 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Tidal Flow Calculator
(Greg Tucker, August 2020)
This tutorial explains the theory behind the TidalFlowCalculator Landlab component, and shows several examples of how to use the component in... | Python Code:
# imports
import numpy as np
import matplotlib.pyplot as plt
from landlab import RasterModelGrid, imshow_grid
from landlab.components import TidalFlowCalculator
# set up the grid
grid = RasterModelGrid((3, 101), xy_spacing=2.0) # only 1 row of core nodes, between 2 boundary rows
grid.set_closed_boundaries... |
5,854 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Draw Hopf fibration using python and POV-Ray
What is Hopf fibration?
Hopf fibration is a continous map from the 3-sphere $S^3$ onto the 2-sphere $S^2$, where the preimage of each point $p\in... | Python Code:
import subprocess
import numpy as np
from IPython.display import Image
PI = np.pi
POV_SCENE_FILE = "hopf_fibration.pov"
POV_DATA_FILE = "torus-data.inc"
POV_EXE = "povray"
COMMAND = "{} +I{} +W500 +H500 +Q11 +A0.01 +R2".format(POV_EXE, POV_SCENE_FILE)
IMG = POV_SCENE_FILE[:-4] + ".png"
Explanation: Draw Ho... |
5,855 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
ES-DOC CMIP6 Model Properties - Aerosol
MIP Era
Step1: Document Authors
Set document authors
Step2: Document Contributors
Specify document contributors
Step3: Document Publication
Specify... | Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ncar', 'sandbox-1', 'aerosol')
Explanation: ES-DOC CMIP6 Model Properties - Aerosol
MIP Era: CMIP6
Institute: NCAR
Source ID: SANDBOX-1
Topic: Aerosol
Sub-Topics: Transport, Emissions... |
5,856 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Monitor Convergence for Run 6
Applying multiple convergence checks for run 6, which adopted a floating Y and alpha. Up to now, we have monitored convergence by visually inspecting trace plot... | Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
Explanation: Monitor Convergence for Run 6
Applying multiple convergence checks for run 6, which adopted a floating Y and alpha. Up to now, we have monitored convergence by visually inspecting trace plots. It would be useful to know if c... |
5,857 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Step1: Session 4
Step2: <a name="part-1---pretrained-networks"></a>
Part 1 - Pretrained Networks
In the libs module, you'll see that I've included a few modules for loading some state of th... | Python Code:
# First check the Python version
import sys
if sys.version_info < (3,4):
print('You are running an older version of Python!\n\n',
'You should consider updating to Python 3.4.0 or',
'higher as the libraries built for this course',
'have only been tested in Python 3.4 and hi... |
5,858 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Outline
The purpose of this notebook is to calculate zone entry and exit-related data for tracked games, and generate TOI and shot-related data for the same games.
Here's what we'll do
Step1... | Python Code:
from os import listdir, chdir, getcwd
import pandas as pd
from pylab import *
from tqdm import tqdm # progress bar
%matplotlib inline
current_wd = getcwd()
Explanation: Outline
The purpose of this notebook is to calculate zone entry and exit-related data for tracked games, and generate TOI and shot-related... |
5,859 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Accompanying code examples of the book "Introduction to Artificial Neural Networks and Deep Learning
Step1: Model Zoo -- Saving and Loading Trained Models
from TensorFlow Checkpoint Files a... | Python Code:
%load_ext watermark
%watermark -a 'Sebastian Raschka' -v -p tensorflow
Explanation: Accompanying code examples of the book "Introduction to Artificial Neural Networks and Deep Learning: A Practical Guide with Applications in Python" by Sebastian Raschka. All code examples are released under the MIT license... |
5,860 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<a href="https
Step1: Setup a symmetric system using SyMD
Setup some simulation parameters, initialize the spatial group, and the constraint function.
Step2: Randomly initialize positions ... | Python Code:
%%capture
!pip install jax-md
!pip install symd
from symd import symd, groups
import jax.numpy as jnp
from jax import random
from jax import config; config.update('jax_enable_x64', True)
Explanation: <a href="https://colab.research.google.com/github/google/jax-md/blob/main/notebooks/symd.ipynb" target="_p... |
5,861 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Introduction to language-model-based data augmentation (LAMBADA)
https
Step1: Step 0
Step2: Step 1
Step3: Step 2a
Step4: Step 2b
Step5: Step 3 ~ 5 | Python Code:
from IPython.display import Image
Image(filename='../res/lambada_algo.png')
Explanation: Introduction to language-model-based data augmentation (LAMBADA)
https://arxiv.org/pdf/1911.03118.pdf
LAMBADA (Anaby-Tavor et al., 2019) is proposed to generate synthetic data. We follow the approach with modification ... |
5,862 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
FAQ
This document will address frequently asked questions not addressed in other pages of the documentation.
How do I install cobrapy?
Please see the INSTALL.md file.
How do I cite cobrapy?
... | Python Code:
from __future__ import print_function
import cobra.test
model = cobra.test.create_test_model()
for metabolite in model.metabolites:
metabolite.id = "test_" + metabolite.id
try:
model.metabolites.get_by_id(model.metabolites[0].id)
except KeyError as e:
print(repr(e))
Explanation: FAQ
This docume... |
5,863 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Namaste 2 example
Here is a short readable (and copy-and-pastable) example as to how to use Namaste 2 to fit a single transit.
Step1: Initialising the star
Step2: To change settings use th... | Python Code:
from namaste import *
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
#%matplotlib inline
%reload_ext autoreload
%autoreload 2
Explanation: Namaste 2 example
Here is a short readable (and copy-and-pastable) example as to how to use Namaste 2 to fit a single transit.
End of explanation... |
5,864 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
ES-DOC CMIP6 Model Properties - Toplevel
MIP Era
Step1: Document Authors
Set document authors
Step2: Document Contributors
Specify document contributors
Step3: Document Publication
Specif... | Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'noaa-gfdl', 'gfdl-cm4', 'toplevel')
Explanation: ES-DOC CMIP6 Model Properties - Toplevel
MIP Era: CMIP6
Institute: NOAA-GFDL
Source ID: GFDL-CM4
Sub-Topics: Radiative Forcings.
Prop... |
5,865 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
PD- Control of a robot
In this section you will control the paddle to move to a desired location. The robot is force controlled. This means that for every time step, you can specify an app... | Python Code:
import tutorial; from tutorial import *
initial_pose = (16, 12,0.0)
desired_pose = (16, 16,3.14/2.)
desired_vel = (0, 0, 0)
play_pd_control_solution(initial_pose, \
desired_pose, desired_vel)
Explanation: PD- Control of a robot
In this section you will control the paddle to move to a desired lo... |
5,866 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
https
Step1: http
Step2: http
Step3: https | Python Code:
#print res.text
print dir(res)
print res.status_code
print res.headers['content-type']
import requests
payload ={
'StartStation':'977abb69-413a-4ccf-a109-0272c24fd490',
'EndStation':'fbd828d8-b1da-4b06-a3bd-680cdca4d2cd',
'SearchDate':'2015/09/11',
'SearchTime':'14:30',
'SearchWay':'DepartureInMandarin'
}
... |
5,867 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Qualité des calages
Les dépenses ou quantités agrégées de Budget des Familles après calage, avec celles de la comptabilité nationale. Le calage est effectué sur les dépenses en carburants.
S... | Python Code:
# Import de modules généraux
from __future__ import division
import pkg_resources
import os
import pandas as pd
from pandas import concat
import seaborn
# modules spécifiques
from openfisca_france_indirect_taxation.examples.utils_example import graph_builder_line
# from ipp_macro_series_parser.agregats_tra... |
5,868 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
ES-DOC CMIP6 Model Properties - Ocean
MIP Era
Step1: Document Authors
Set document authors
Step2: Document Contributors
Specify document contributors
Step3: Document Publication
Specify d... | Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ncc', 'sandbox-2', 'ocean')
Explanation: ES-DOC CMIP6 Model Properties - Ocean
MIP Era: CMIP6
Institute: NCC
Source ID: SANDBOX-2
Topic: Ocean
Sub-Topics: Timestepping Framework, Adve... |
5,869 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Sentiment analysis with TFLearn
In this notebook, we'll continue Andrew Trask's work by building a network for sentiment analysis on the movie review data. Instead of a network written with ... | Python Code:
import pandas as pd
import numpy as np
import tensorflow as tf
import tflearn
from tflearn.data_utils import to_categorical
Explanation: Sentiment analysis with TFLearn
In this notebook, we'll continue Andrew Trask's work by building a network for sentiment analysis on the movie review data. Instead of a n... |
5,870 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Testing Band 9
Creation of Data Cubes
Creation of the Synthetic Data Cubes ALMA-like using ASYDO Project.
Parameters
Step1: To select the isolist, the wavelength range of the cube is obtain... | Python Code:
cube_params = {
'freq' : 604000,
'alpha' : 0,
'delta' : 0,
'spe_bw' : 4000,
'spe_res' : 1,
's_f' : 4,
's_a' : 0}
Explanation: Testing Band 9
Creation of Data Cubes
Creation of the Synthetic Data Cubes ALMA-like using ASYDO Project.
Parameters:
isolist : subset of the... |
5,871 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
$$ \LaTeX \text{ command declarations here.}
\newcommand{\R}{\mathbb{R}}
\renewcommand{\vec}[1]{\mathbf{#1}}
\newcommand{\X}{\mathcal{X}}
\newcommand{\D}{\mathcal{D}}
\newcommand{\G}{\mathca... | Python Code:
import numpy as np
np.set_printoptions(suppress=True)
parts_of_speech = DETERMINER, NOUN, VERB, END = 0, 1, 2, 3
words = THE, DOG, CAT, WALKED, RAN, IN, PARK, END = 0, 1, 2, 3, 4, 5, 6, 7
# transition probabilities
A = np.array([
# D N V E
[0.1, 0.8, 0.1, 0.0], # D: determiner most... |
5,872 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Wall Street Columns Nexa - Visualization of Code Vectors
In this notebook we will analyse the distribution of code vectors. What we want to analyse is whether we are able to increase that di... | Python Code:
import numpy as np
import h5py
%matplotlib inline
import sys
sys.path.append("../")
Explanation: Wall Street Columns Nexa - Visualization of Code Vectors
In this notebook we will analyse the distribution of code vectors. What we want to analyse is whether we are able to increase that difference by making p... |
5,873 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
wxpython
To make a graphycal interface to use a code in an interactive way we need a library of widgets, called wxpython.
We will explore the usage of this library mainly with examples. But ... | Python Code:
%%writefile framecode.py
#!/usr/bin/env python
import wx
app = wx.App(False) # Create a new app, don't redirect stdout/stderr to a window.
frame = wx.Frame(None, wx.ID_ANY, "Hello World") # A Frame is a top-level window.
frame.Show(True) # Show the frame.
app.MainLoop()
!python framecode.py
Explanatio... |
5,874 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
San Francisco Crime Dataset Conversion
Challenge
Spark does not support out-of-the box data frame creation from CSV files.
The CSV reader from Databricks provides such functionality but requ... | Python Code:
import csv
import pyspark
from pyspark.sql import SQLContext
from pyspark.sql.types import *
from StringIO import StringIO
from datetime import *
from dateutil.parser import parse
Explanation: San Francisco Crime Dataset Conversion
Challenge
Spark does not support out-of-the box data frame creation from CS... |
5,875 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Example 6 - Scattered Data and 'Heat Maps'
There are different ways to map point data to a smooth field. One way is to triangulate the data, smooth it and interpolate to a regular mesh (see ... | Python Code:
import stripy as stripy
mesh = stripy.spherical_meshes.icosahedral_mesh(refinement_levels=5, include_face_points=True, tree=True)
print(mesh.npoints)
Explanation: Example 6 - Scattered Data and 'Heat Maps'
There are different ways to map point data to a smooth field. One way is to triangulate the data, smo... |
5,876 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
ES-DOC CMIP6 Model Properties - Toplevel
MIP Era
Step1: Document Authors
Set document authors
Step2: Document Contributors
Specify document contributors
Step3: Document Publication
Specif... | Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'mpi-m', 'sandbox-1', 'toplevel')
Explanation: ES-DOC CMIP6 Model Properties - Toplevel
MIP Era: CMIP6
Institute: MPI-M
Source ID: SANDBOX-1
Sub-Topics: Radiative Forcings.
Properties... |
5,877 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
ES-DOC CMIP6 Model Properties - Toplevel
MIP Era
Step1: Document Authors
Set document authors
Step2: Document Contributors
Specify document contributors
Step3: Document Publication
Specif... | Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ec-earth-consortium', 'sandbox-1', 'toplevel')
Explanation: ES-DOC CMIP6 Model Properties - Toplevel
MIP Era: CMIP6
Institute: EC-EARTH-CONSORTIUM
Source ID: SANDBOX-1
Sub-Topics: Rad... |
5,878 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Syrian Refugee Resettlement, March 2011 - April 2017
Ionut Gitan • Data Bootcamp • Balint Szoke • 5 May 2017
Project Summary
Introduction. The project discusses an historical overview of Syr... | Python Code:
import plotly
plotly.tools.set_credentials_file(username='ionutgitan', api_key='d0QXm30QhDEcnGMQcE5c')
import plotly.plotly as py
import pandas as pd
df = pd.read_csv('https://ionutgitan.com/s/Gitan_Data.csv')
df.head()
df['text'] = df['name'] + '<br>Syrian Refugees ' + (df['pop']).astype(str)
limits = [(... |
5,879 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Step1: TV Script Generation
In this project, you'll generate your own Simpsons TV scripts using RNNs. You'll be using part of the Simpsons dataset of scripts from 27 seasons. The Neural Ne... | Python Code:
DON'T MODIFY ANYTHING IN THIS CELL
import helper
data_dir = './data/simpsons/moes_tavern_lines.txt'
text = helper.load_data(data_dir)
# Ignore notice, since we don't use it for analysing the data
text = text[81:]
Explanation: TV Script Generation
In this project, you'll generate your own Simpsons TV script... |
5,880 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Important
This notebook is to be run inside Jupyter. If you see In [ ]
Step2: Step 2
Step3: Step 3 | Python Code:
!unzip codes/cloudlab/emulab-0.9.zip -d codes/cloudlab
!cd codes/cloudlab/emulab-geni-lib-1baf79cf12cb/;\
source activate python2;\
python setup.py install --user
!ls /home/lngo/.local/lib/python2.7/site-packages/
!rm -Rf codes/cloudlab/emulab-geni-lib-1baf79cf12cb/
Explanation: Important
This note... |
5,881 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Encore une instruction pour bouger
QUESTIONS
Lorsque la liste pos contient 6 angles en degrés, que permet de faire le jeu d'instructions suivant ?
Le jeu d'instructions suivant permet de f... | Python Code:
pos = [-20, -20, 40, -30, 40, 20]
i = 0
for m in poppy.motors:
m.compliant = False
m.goto_position(pos[i], 0.5, wait = True)
i = i + 1
# importation des outils nécessaires
import cv2
%matplotlib inline
import matplotlib.pyplot as plt
from hampy import detect_markers
# affichage de l'image capt... |
5,882 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
XDAWN Decoding From EEG data
ERP decoding with Xdawn
Step1: Set parameters and read data
Step2: The patterns_ attribute of a fitted Xdawn instance (here from the last
cross-validation fol... | Python Code:
# Authors: Alexandre Barachant <alexandre.barachant@gmail.com>
#
# License: BSD-3-Clause
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import StratifiedKFold
from sklearn.pipeline import make_pipeline
from sklearn.linear_model import LogisticRegression
from sklearn.metrics... |
5,883 | Given the following text problem statement, write Python code to implement the functionality described below in problem statement
Problem:
Is it possible to perform circular cross-/auto-correlation on 1D arrays with a numpy/scipy/matplotlib function? I have looked at numpy.correlate() and matplotlib.pyplot.xcorr (based... | Problem:
import numpy as np
a = np.array([1,2,3,4])
b = np.array([5, 4, 3, 2])
result = np.correlate(a, np.hstack((b[1:], b)), mode='valid') |
5,884 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
First, load up the data
First you're going to want to create a data frame from the dailybots.csv file which can be found in the data directory. You should be able to do this with the pd.rea... | Python Code:
data = pd.read_csv( '../../data/dailybots.csv' )
#Look at a summary of the data
data.describe()
data['botfam'].value_counts()
Explanation: First, load up the data
First you're going to want to create a data frame from the dailybots.csv file which can be found in the data directory. You should be able to d... |
5,885 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
<small><i>This notebook was prepared by Donne Martin. Source and license info is on GitHub.</i></small>
Challenge Notebook
Problem
Step1: Unit Test
The following unit test is expected to fa... | Python Code:
%run ../linked_list/linked_list.py
%load ../linked_list/linked_list.py
class MyLinkedList(LinkedList):
def kth_to_last_elem(self, k):
# TODO: Implement me
pass
Explanation: <small><i>This notebook was prepared by Donne Martin. Source and license info is on GitHub.</i></small>
Challenge ... |
5,886 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Keys for each of the columns in the orbit (Keplerian state) report.
Step1: Plot the orbital parameters which are vary significantly between different tracking files. | Python Code:
utc = 0
sma = 1
ecc = 2
inc = 3
raan = 4
aop = 5
ma = 6
ta = 7
Explanation: Keys for each of the columns in the orbit (Keplerian state) report.
End of explanation
#fig1 = plt.figure(figsize = [15,8], facecolor='w')
fig_peri = plt.figure(figsize = [15,8], facecolor='w')
fig_peri_deorbit = plt.figure(figsize... |
5,887 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
ES-DOC CMIP6 Model Properties - Land
MIP Era
Step1: Document Authors
Set document authors
Step2: Document Contributors
Specify document contributors
Step3: Document Publication
Specify do... | Python Code:
# DO NOT EDIT !
from pyesdoc.ipython.model_topic import NotebookOutput
# DO NOT EDIT !
DOC = NotebookOutput('cmip6', 'ec-earth-consortium', 'sandbox-3', 'land')
Explanation: ES-DOC CMIP6 Model Properties - Land
MIP Era: CMIP6
Institute: EC-EARTH-CONSORTIUM
Source ID: SANDBOX-3
Topic: Land
Sub-Topics:... |
5,888 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Camera Calibration with OpenCV
Run the code in the cell below to extract object points and image points for camera calibration.
Step1: If the above cell ran sucessfully, you should now have... | Python Code:
import numpy as np
import cv2
import glob
import matplotlib.pyplot as plt
%matplotlib qt
# prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(6,5,0)
objp = np.zeros((6*8,3), np.float32)
objp[:,:2] = np.mgrid[0:8, 0:6].T.reshape(-1,2)
# Arrays to store object points and image points from all the im... |
5,889 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Ordinary Least-Squares with Measurement Error
Unit 12, Lecture 4
Numerical Methods and Statistics
Prof. Andrew White, April 24 2018
Goals
Step1: Plotting with Error Bars
Error bars are litt... | Python Code:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from math import sqrt, pi, erf
import seaborn
seaborn.set_context("notebook")
seaborn.set_style("whitegrid")
import scipy.stats
Explanation: Ordinary Least-Squares with Measurement Error
Unit 12, Lecture 4
Numerical Methods and Statistic... |
5,890 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Copyright 2020 The TensorFlow Authors.
Step1: Tensorflow Lattice와 형상 제약 조건
<table class="tfo-notebook-buttons" align="left">
<td><a target="_blank" href="https
Step2: 필수 패키지 가져오기
Step3: ... | 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 writing, software
# dist... |
5,891 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
tsam - 3. Example
Examples of the different methods used in the time series aggregation module (tsam)
Date
Step1: Input data
Read in time series from testdata.csv with pandas
Step2: Simple... | Python Code:
%load_ext autoreload
%autoreload 2
import copy
import os
import pandas as pd
import matplotlib.pyplot as plt
import tsam.timeseriesaggregation as tsam
%matplotlib inline
Explanation: tsam - 3. Example
Examples of the different methods used in the time series aggregation module (tsam)
Date: 04.01.2019
Autho... |
5,892 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Eclipse model
The eclipse model, pytransit.EclipseModel, can be used to model a secondary eclipse. The model is similar to pytransit.UniformModel, but the eclipse occurs correctly where it s... | Python Code:
%pylab inline
sys.path.append('..')
from pytransit import EclipseModel
seed(0)
times_sc = linspace(0.5, 2.5, 5000) # Short cadence time stamps
times_lc = linspace(0.5, 2.5, 500) # Long cadence time stamps
k, t0, p, a, i, e, w = 0.1, 1., 2.0, 4.2, 0.5*pi, 0.25, 0.4*pi
ns = 50
ks = normal(k, 0.01, ns)
t... |
5,893 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
In this notebook we will use the Monte Carlo method to find the area under a curve, so first let's define a function
$$f(x) = x^2-4x+5$$
Step1: Now, we know the probability of a random poin... | Python Code:
f = lambda x:x**2-4*x+5
x = range(0, 11, 1)
y = [f(v) for v in x]
plt.plot(y)
Explanation: In this notebook we will use the Monte Carlo method to find the area under a curve, so first let's define a function
$$f(x) = x^2-4x+5$$
End of explanation
#Will use 3000 points
number_points=3000
#We want to see the... |
5,894 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Where to Get Help
Step1: What I wanted to do was build a nested list, x is supposed to look like
Step2: To see what's happening lets rewrite the code to make the issue even clearer
Step3: ... | Python Code:
x = [ [2] * 3 ] * 3
x[0][0] = "ZZ"
print(*x, sep="\n")
Explanation: Where to Get Help: Homework Assignment
You need to be think a little bit about your search, the better that is the more likely you are to find what you want. Let me give you a real example I stuggled with:
End of explanation
out=[[0]*3]*3... |
5,895 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
1A.e - Enoncé 23 octobre 2018 (2)
Correction du second énoncé de l'examen du 23 octobre 2018. L'énoncé propose une méthode pour renseigner les valeurs manquantes dans une base de deux variab... | Python Code:
from jyquickhelper import add_notebook_menu
add_notebook_menu()
Explanation: 1A.e - Enoncé 23 octobre 2018 (2)
Correction du second énoncé de l'examen du 23 octobre 2018. L'énoncé propose une méthode pour renseigner les valeurs manquantes dans une base de deux variables.
End of explanation
import numpy.ran... |
5,896 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Before start
Step1: Getting the data
We're not going into details here
Step2: Defining the input function
If we look at the image above we can see that there're two main parts in the diagr... | Python Code:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
# our model
import model as m
# tensorflow
import tensorflow as tf
print(tf.__version__) #tested with tf v1.2
from tensorflow.contrib import learn
from tensorflow.contrib.learn.python.learn import... |
5,897 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Linear regression - audio
Use linear regression to recover or 'fill out' a completely deleted portion of an audio file!
This will be using The FSDD, Free-Spoken-Digits-Dataset, an audio data... | Python Code:
import os
import scipy.io.wavfile as wavfile
zero = []
directory = "../datasets/free-spoken-digit-dataset-master/recordings/"
for fname in os.listdir(directory):
if fname.startswith("0_jackson"):
fullname = os.path.join(directory, fname)
sample_rate, data = wavfile.read(fullname)
... |
5,898 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Sharing Tutorial
Step1: Safe default
Step2: Switching to fully private by default
Call graphistry.privacy() to default to stronger privacy. It sets
Step3: Local overrides
We can locally o... | Python Code:
#! pip install --user -q graphistry pandas
import graphistry, pandas as pd
graphistry.__version__
# To specify Graphistry account & server, use:
# graphistry.register(api=3, username='...', password='...', protocol='https', server='hub.graphistry.com')
# For more options, see https://github.com/graphistry/... |
5,899 | Given the following text description, write Python code to implement the functionality described below step by step
Description:
Searching datasets
erddapy can wrap the same form-like search capabilities of ERDDAP with the search_for keyword.
Step1: Single word search.
Step2: Filtering the search with extra words.
S... | Python Code:
from erddapy import ERDDAP
e = ERDDAP(
server="https://upwell.pfeg.noaa.gov/erddap",
protocol="griddap"
)
Explanation: Searching datasets
erddapy can wrap the same form-like search capabilities of ERDDAP with the search_for keyword.
End of explanation
import pandas as pd
search_for = "HFRadar"
url ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.