我已经安装了Python 3.5并且在运行时
pip install mysql-python
Run Code Online (Sandbox Code Playgroud)
它给了我以下错误
error: Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)
Run Code Online (Sandbox Code Playgroud)
我在路径中添加了以下行
C:\Program Files\Python 3.5\Scripts\;
C:\Program Files\Python 3.5\;
C:\Windows\System32;
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC
Run Code Online (Sandbox Code Playgroud)
我的PC上有64位win 7设置.
什么是解决此错误和正确安装模块的解决方案pip.
我正在学习第1 部分和第2 部分提供的教程.不幸的是,作者没有时间进行涉及使用余弦相似性的最后一节实际找到两个文档之间的距离.我在文章的示例中借助stackoverflow中的以下链接,包括上面链接中提到的代码(只是为了让生活更轻松)
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction.text import TfidfTransformer
from nltk.corpus import stopwords
import numpy as np
import numpy.linalg as LA
train_set = ["The sky is blue.", "The sun is bright."] # Documents
test_set = ["The sun in the sky is bright."] # Query
stopWords = stopwords.words('english')
vectorizer = CountVectorizer(stop_words = stopWords)
#print vectorizer
transformer = TfidfTransformer()
#print transformer
trainVectorizerArray = vectorizer.fit_transform(train_set).toarray()
testVectorizerArray = vectorizer.transform(test_set).toarray()
print 'Fit Vectorizer to train set', trainVectorizerArray …Run Code Online (Sandbox Code Playgroud) 我的Python版本是2.6.
我想只执行一次测试setUp方法,因为我在那里做所有测试都需要的东西.
我的想法是创建一个布尔变量,在第一次执行后将设置为'true',然后禁用多次调用setup方法.
class mySelTest(unittest.TestCase):
setup_done = False
def setUp(self):
print str(self.setup_done)
if self.setup_done:
return
self.setup_done = True
print str(self.setup_done)
Run Code Online (Sandbox Code Playgroud)
输出:
False
True
--- Test 1 ---
False
True
--- Test 2 ---
Run Code Online (Sandbox Code Playgroud)
为什么这不起作用?我错过了什么吗?
这是关于管道实施的设计问题.以下是我的天真实施.
管道中各个步骤/阶段的接口:
public interface Step<T, U> {
public U execute(T input);
}
Run Code Online (Sandbox Code Playgroud)
管道中步骤/阶段的具体实现:
public class StepOne implements Step<Integer, Integer> {
@Override
public Integer execute(Integer input) {
return input + 100;
}
}
public class StepTwo implements Step<Integer, Integer> {
@Override
public Integer execute(Integer input) {
return input + 500;
}
}
public class StepThree implements Step<Integer, String> {
@Override
public String execute(Integer input) {
return "The final amount is " + input;
}
}
Run Code Online (Sandbox Code Playgroud)
管道类将保存/注册管道中的步骤并一个接一个地执行它们:
public class Pipeline {
private …Run Code Online (Sandbox Code Playgroud) 在阅读OpenStack的代码时我遇到了这个问题.
名为"Service"的类继承基类"object",然后在Service的__init__()方法__init__中调用object .相关代码如下所示:
类定义:
class Service(object):
Run Code Online (Sandbox Code Playgroud)
和服务的init方法定义:
def __init__(self, host, binary, topic, manager, report_interval=None,
periodic_interval=None, *args, **kwargs):
Run Code Online (Sandbox Code Playgroud)
并在Service的init中调用super(这里的'object'):
super(Service, self).__init__(*args, **kwargs)
Run Code Online (Sandbox Code Playgroud)
我不明白最后一次电话,object.__init__()它实际上做了什么?有人可以帮忙吗?
我想预测每周可预测的某些值(低SNR).我需要预测一年中形成的一年的整个时间序列(52个值 - 图1)
我的第一个想法是使用Keras over TensorFlow开发多对多LSTM模型(图2).我正在使用52输入层(前一年的给定时间序列)和52预测输出层(明年的时间序列)训练模型.train_X的形状是(X_examples,52,1),换言之,要训练的X_examples,每个1个特征的52个时间步长.据我所知,Keras会将52个输入视为同一域的时间序列.train_Y的形状是相同的(y_examples,52,1).我添加了一个TimeDistributed层.我的想法是算法会将值预测为时间序列而不是孤立值(我是否正确?)
Keras的模型代码是:
y = y.reshape(y.shape[0], 52, 1)
X = X.reshape(X.shape[0], 52, 1)
# design network
model = Sequential()
model.add(LSTM(n_neurons, input_shape=(X.shape[1], X.shape[2]), return_sequences=True))
model.add(TimeDistributed(Dense(1)))
model.compile(loss='mean_squared_error', optimizer='adam')
# fit network
model.fit(X, y, epochs=n_epochs, batch_size=n_batch, verbose=2)
Run Code Online (Sandbox Code Playgroud)
问题是算法没有学习这个例子.它预测的值与属性的值非常相似.我是否正确建模了问题?
第二个问题:另一个想法是用1输入和1输出训练算法,但是在测试期间如何在不查看'1输入'的情况下预测整个2015时间序列?测试数据将具有与训练数据不同的形状.
我向元素添加了一个click事件处理程序
$(".elem").click(function(){
$.post("page.php".function(){
//code1
})
})
Run Code Online (Sandbox Code Playgroud)
然后我触发一个点击事件
$(".elem").click();
//code2
Run Code Online (Sandbox Code Playgroud)
我怎样才能确保code1执行后执行code2
我是luigi的新手,在为我们的ML工作设计管道时遇到过它.虽然它不适合我的特定用例,但它有很多额外的功能,我决定让它适合.
基本上我正在寻找的是一种能够持久保存自定义构建管道并因此使其结果可重复且易于部署的方法,在阅读了大多数在线教程之后,我尝试使用现有luigi.cfg配置和命令行机制实现我的序列化并且它可能已经足够用于任务的参数但它没有提供序列化我的管道的DAG连接的方法,所以我决定有一个WrapperTask接收到一个json config file然后创建所有任务实例并连接所有输入输出通道luigi任务(做所有的管道).
我特此附上一个小测试程序供您审查:
import random
import luigi
import time
import os
class TaskNode(luigi.Task):
i = luigi.IntParameter() # node ID
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.required = []
def set_required(self, required=None):
self.required = required # set the dependencies
return self
def requires(self):
return self.required
def output(self):
return luigi.LocalTarget('{0}{1}.txt'.format(self.__class__.__name__, self.i))
def run(self):
with self.output().open('w') as outfile:
outfile.write('inside {0}{1}\n'.format(self.__class__.__name__, self.i))
self.process()
def process(self):
raise NotImplementedError(self.__class__.__name__ + " must implement this method")
class FastNode(TaskNode):
def process(self):
time.sleep(1) …Run Code Online (Sandbox Code Playgroud) python ×6
oop ×2
python-3.x ×2
c ×1
forward ×1
init ×1
java ×1
javascript ×1
jquery ×1
keras ×1
lstm ×1
luigi ×1
metaclass ×1
nltk ×1
object ×1
prediction ×1
signals ×1
tf-idf ×1
time-series ×1
unit-testing ×1
unix ×1