在sklearn-python工具箱中,有两个函数transform和fit_transformabout sklearn.decomposition.RandomizedPCA.两个功能的描述如下

但它们之间有什么区别?
我想创建一个模板作为folows.我想从矢量中删除项目列表vec1.并且我要删除的项目的索引存储在index_list.
#include <vector>
using namespace std;
template <typename a_type>
bool vector_remove(vector< a_type > & vec1, vector< int > index_list)
{
//index_list is sorted in order from small to large.
if(index_list.size() > vec1.size())
{
cout << "ERROR in 'vector_remove()': index_list is longer than vec1."<<endl;
return false;
}
if(index_list.size() == vec1.size())
{
vec1.clear();
return true;
}
vector< int >::iterator ind_pt = index_list.begin();
vector< a_type >::iterator vec1_pre = vec1.begin();
vector< a_type >::iterator vec1_pos = vec1.begin();
int vec1_ind = 0; …Run Code Online (Sandbox Code Playgroud) 我在本文档后面获得了授权码.但是当我试图获得访问令牌时,我总是遇到错误.谁能帮我 ?
public String AccessToken()
{
String accessToken = "";
StringBuilder strBuild = new StringBuilder();
String authURL = "https://accounts.google.com/o/oauth2/token?";
String code = "4/SVisuz_x*********************";
String client_id = "******************e.apps.googleusercontent.com";
String client_secret = "*******************";
String redirect_uri = "urn:ietf:wg:oauth:2.0:oob";
String grant_type="authorization_code";
strBuild.append("code=").append(code)
.append("&client_id=").append(client_id)
.append("&client_secret=").append(client_secret)
.append("&redirect_uri=").append(redirect_uri)
.append("&grant_type=").append(grant_type);
System.out.println(strBuild.toString());
try{
URL obj = new URL(authURL);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setDoOutput(true);
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
con.setRequestProperty("Host", "www.googleapis.com");
//BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(con.getOutputStream()));
//bw.write(strBuild.toString());
//bw.close();
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(strBuild.toString());
wr.flush();
wr.close();
//OutputStreamWriter out …Run Code Online (Sandbox Code Playgroud) 这些天我正在学习C++和OpenCV.鉴于图像,我想提取其SIFT功能.从http://docs.opencv.org/modules/nonfree/doc/feature_detection.html,我们可以知道OpenCV 2.4.8具有SIFT模块.看这里:

但我不知道如何使用它.目前,要使用SIFT,我需要先调用类SIFT来获取SIFT实例.然后,我需要SIFT::operator()()用来做SIFT.
但是,什么是OutputArray,InputArray, KeyPoint?谁能举个演示来演示如何使用SIFT类来做SIFT?
对于存储图像的垫子,很容易使用它来显示imshow.但是如果Mat的数据类型是CV_32FC1,我该如何显示这个垫子?
我试过imshow,但是显示图是全白的,当我缩放时,它仍然是完全空白的,我看不到垫子中的浮点数.
有谁知道如何显示整个垫矩阵?
ps:谢谢你的回复.我将发布一些代码和数字以显示更多详细信息:代码:
Mat mat1;
mat1 = Mat::ones(3,4,CV_32FC1);
mat1 = mat1 * 200;
imshow("test", mat1);
waitKey(0);
Mat dst;
normalize(mat1, dst, 0, 1, NORM_MINMAX);
imshow("test1", dst);
waitKey(0);
mat1.convertTo(dst, CV_8UC1);
imshow("test2", dst);
waitKey(0);
return 0;
Run Code Online (Sandbox Code Playgroud)
输出:

放大150%之后:

然后在我放大150%之后,我们可以看到'test'是完全白色的,我们看不到它的元素值.'test1'完全是黑色的,我们仍然无法看到它的元素值.但是对于'test2',它是灰色的,我们可以看到它的元素值是200.
这个实验是否意味着imshow()只能显示CV_8UC1,我们无法显示任何其他数据?
为什么time.clock()给出错误的结果?代码如下:
time_start1 = time.time()
time.sleep(5)
bb = time.time() - time_start1;
print bb;
time_1 = time.clock()
time.sleep(5)
cc = time.clock() - time_1
print cc
Run Code Online (Sandbox Code Playgroud)
结果是:
5.00506210327
0.006593
Run Code Online (Sandbox Code Playgroud)
第二个应该是5.0,但为什么它是0.006?我的操作系统是Ubuntu 14.04LTS 64位.我的IDLE版本是2.7.6.
谢谢!
在主脚本中,我想在某些条件下阻止它.我试过return但是它错了,因为它在函数之外.我试过了exit,但它并没有停止.请参阅以下内容:
print 'step 1'
exit
print 'step 2'
Run Code Online (Sandbox Code Playgroud)
我该怎么办 ?我使用的版本是IDLE 2.7.5+
c++ ×3
python ×3
opencv ×2
python-2.7 ×2
gmail-api ×1
google-api ×1
java ×1
scikit-learn ×1
sift ×1
templates ×1
vector ×1