是否有可能使用c程序找到函数的导数.我正在使用matlab,它有一个内置函数diff(),可用于查找函数的导数.
f(x)=x^2
Run Code Online (Sandbox Code Playgroud)
是否有可能使用c找到上述函数的导数.算法是什么?
是否可以使用类似于Google搜索的自动完整字符串和闪亮文本框中的堆栈溢出标记选择来选择多个值.
dataset<-cbind("John Doe","Ash","Ajay sharma","Ken Chong","Will Smith","Neo"....etc)
Run Code Online (Sandbox Code Playgroud)
我想从上面的数据集中选择多个变量作为我的文本框中的自动填充并将其传递给我的server.R
ui.R
shinyUI(fluidPage(
titlePanel("test"),
sidebarLayout(
sidebarPanel(
helpText("text"),
textInput("txt","Enter the text",""),
#Pass the dataset here for auto complete
),
mainPanel(
tabsetPanel(type="tab",tabPanel("Summary"),textOutput("text2"))
)
)
))
Run Code Online (Sandbox Code Playgroud)
server.R
# server.R
shinyServer(function(input, output) {
output$text2<- renderText({
paste("hello",input$txt)
})
}
)
Run Code Online (Sandbox Code Playgroud)
EDITED
我已经使用shinysky的select2input来选择多个变量,但现在我已经添加了提交按钮来一起获取所选值.
#ui.R
select2Input("txt","This is a multiple select2Input",choices=c("a","b","c"),selected=c("")),
actionButton("go","submit")
Run Code Online (Sandbox Code Playgroud)
我想绑定选定的选项让我们说用户选择a和c然后新的变量是
#server.R
input$go #if pressed submit button
var<-cbind("a","c")
output$text<-renderText({ print ("var")})
Run Code Online (Sandbox Code Playgroud)
但这不起作用
有没有办法在r中的一行中打印文本和变量
例如
a="Hello"
b="EKA"
c="123456"
print("$a !! my name is $b and my number is $c")
Run Code Online (Sandbox Code Playgroud)
out put会是这样的
Hello !! my name is EKA and my number is 123456
Run Code Online (Sandbox Code Playgroud) 我试图保持Python字典的顺序,因为native dict没有任何顺序.SE中的许多答案建议使用OrderedDict.
from collections import OrderedDict
domain1 = { "de": "Germany", "sk": "Slovakia", "hu": "Hungary",
"us": "United States", "no": "Norway" }
domain2 = OrderedDict({ "de": "Germany", "sk": "Slovakia", "hu": "Hungary",
"us": "United States", "no": "Norway" })
print domain1
print " "
for key,value in domain1.iteritems():
print (key,value)
print " "
print domain2
print ""
for key,value in domain2.iteritems():
print (key,value)
Run Code Online (Sandbox Code Playgroud)
迭代后,我需要字典来维护其原始顺序并将键和值打印为原始:
{
"de": "Germany",
"sk": "Slovakia",
"hu": "Hungary",
"us": "United States",
"no": "Norway"
}
Run Code Online (Sandbox Code Playgroud)
但是,我使用的任何一种方式都不会保留此顺序.
我想按列表中给定的特定顺序选择行。例如
这个数据框
a=[['car',1],['bike',3],['jewel',2],['tv',5],['phone',6]]
df=pd.DataFrame(a,columns=['items','quantity'])
>>> df
items quantity
0 car 1
1 bike 3
2 jewel 2
3 tv 5
4 phone 6
Run Code Online (Sandbox Code Playgroud)
我想按此顺序获取行['tv','car','phone'],即第一行电视,然后是汽车,然后是电话。我尝试过这种方法,但不能维持秩序
arr=['tv','car','phone']
df.loc[df['items'].isin(arr)]
items quantity
0 car 1
3 tv 5
4 phone 6
Run Code Online (Sandbox Code Playgroud) 任何人都可以告诉我如何使用curl或file_get_contents从网站下载特定数据,然后将这些特定数据保存到我的mysql数据库中.我想从这个网站http://www.traileraddict.com/获得最新的电影,我想将它保存在我的数据库中(每天;这个文本和HTML链接将显示在我的网站上).我只需要文本和HTML链接.(在图片中突出显示)

我到处搜索,但我没有找到任何有用的教程.我有两个主要问题要问
1)如何使用cURL或file_get_contents获取特定数据.
2)如何将特定内容保存到我的mysql数据库表(一列中的文本和另一列中的链接)
我是python和pandas的新手,主要是学习它以使我的编程技能多样化以及python作为通用程序语言的优势.在这个程序中,我使用它从雅虎获取历史数据,并使用talib中的函数进行一些技术分析
import pandas_datareader.data as web
import datetime
import talib as ta
start = datetime.datetime.strptime('12/1/2015', '%m/%d/%Y')
end = datetime.datetime.strptime('2/20/2016', '%m/%d/%Y')
f = web.DataReader('GOOG', 'yahoo', start, end)
print 'Closing Prices'
print f['Close'].describe()
print f.Close
print ta.RSI(f.Close,2)
print ta.SMA(f.Close,2)
print ta.SMA(f.Volume,4)
print ta.ATR
print ta.ATR(f.High,f.Low,f.Close,3)
Run Code Online (Sandbox Code Playgroud)
上面的代码工作,print f.Close但它显示此错误
print ta.RSI(f.Close,2)
TypeError: Argument 'real' has incorrect type (expected numpy.ndarray, got Series)
Run Code Online (Sandbox Code Playgroud)
我使用R及其库进行库存技术分析,它有一个内置的库Quantmod,可以使技术分析更容易,代码更少.
library(quantmod)
symbol=getSymbols(AAPL)
SMA=SMA(Cl(Symbol),2)
Run Code Online (Sandbox Code Playgroud)
是否有类似的Python可用的库?
我正在学习交叉验证 - 网格搜索并遇到了这个youtube播放列表,该教程也已作为ipython笔记本上传到github.我试图在同时搜索多个参数部分重新创建代码,但不是使用knn我正在使用SVM回归.这是我的代码
from sklearn.datasets import load_iris
from sklearn import svm
from sklearn.grid_search import GridSearchCV
import matplotlib.pyplot as plt
import numpy as np
iris = load_iris()
X = iris.data
y = iris.target
k=['rbf', 'linear','poly','sigmoid','precomputed']
c= range(1,100)
g=np.arange(1e-4,1e-2,0.0001)
g=g.tolist()
param_grid=dict(kernel=k, C=c, gamma=g)
print param_grid
svr=svm.SVC()
grid = GridSearchCV(svr, param_grid, cv=5,scoring='accuracy')
grid.fit(X, y)
print()
print("Grid scores on development set:")
print()
print grid.grid_scores_
print("Best parameters set found on development set:")
print()
print(grid.best_params_)
print("Grid best score:")
print()
print …Run Code Online (Sandbox Code Playgroud) 我正在加强学习计划,我正在使用这篇文章作为参考.我使用python与keras(theano)创建神经网络和我正在使用的伪代码
Do a feedforward pass for the current state s to get predicted Q-values for all actions.
Do a feedforward pass for the next state s’ and calculate maximum overall network outputs max a’ Q(s’, a’).
Set Q-value target for action to r + ?max a’ Q(s’, a’) (use the max calculated in step 2). For all other actions, set the Q-value target to the same as originally returned from step 1, making the error 0 for those …Run Code Online (Sandbox Code Playgroud) 我使用从网络教程中获得的知识和我自己的直觉,编写了一个序列来编码keras中的学习LSTM.我将示例文本转换为序列,然后使用pad_sequencekeras中的函数进行填充.
from keras.preprocessing.text import Tokenizer,base_filter
from keras.preprocessing.sequence import pad_sequences
def shift(seq, n):
n = n % len(seq)
return seq[n:] + seq[:n]
txt="abcdefghijklmn"*100
tk = Tokenizer(nb_words=2000, filters=base_filter(), lower=True, split=" ")
tk.fit_on_texts(txt)
x = tk.texts_to_sequences(txt)
#shifing to left
y = shift(x,1)
#padding sequence
max_len = 100
max_features=len(tk.word_counts)
X = pad_sequences(x, maxlen=max_len)
Y = pad_sequences(y, maxlen=max_len)
Run Code Online (Sandbox Code Playgroud)
仔细检查后,我发现我的填充序列看起来像这样
>>> X[0:6]
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …Run Code Online (Sandbox Code Playgroud) python ×6
keras ×2
pandas ×2
r ×2
autocomplete ×1
c ×1
derivative ×1
dictionary ×1
lstm ×1
mysql ×1
php ×1
scikit-learn ×1
shiny ×1
svm ×1
ta-lib ×1
textbox ×1
theano ×1