I want to apply KPCA on my training data before I pass it to my SVM which seems to work fine with kernlab. Afterwards I want to embed my testing input into the new space in order to make prediction with my SVM. The documentary recommends to use the predict function, which gives me an error:
dataTrain=as.xts(data)
inputTrain=dataTrain[1:settings$windowTrain,1:ncol(dataTrain)-1]
outputTrain=dataTrain[1:settings$windowTrain,ncol(dataTrain)]
kpcaa=kpca(x=inputTrain,data=NULL,kernel="rbfdot",kpar=list(sigma=0.01))
inputTrain=kpcaa#pcv
predict(object = kpcaa,newdata=inputTest)
predict(object = kpcaa,newdata=inputTest)
Error in .local(object, ...) :
unused argument (newdata = c(0.00065527734617099, -0.00281135973754587, 0.00121922641129046, -0.00356807890285626, 0.00140997344409755, 0.000281756282681123, 0.000657122764787132, -0.000469329337005497, -0.000187793427781635, 0.00046941746156115, -0.000751173744242273, 0.000281756282681123, 0.000187793427781635, -0.000469549710462758, 0.000751173744242273, 0.00140693171451645, -0.000937734502324261, -0.000469197212192185, 0.00112570368360299, -0.0014073277173825, 0.0014073277173825, -0.00112570368360299,
0.000656814473530609, -0.00253580788619168, 0.00187899341266107, -0.00310223515540553, 0.00282061112162602, 0.00121979841537989, -0.00150150178359798, 0.000469461536250826, -0.00140904630893512, -0.000188022939352273, -0.000470212074305643, -0.000282233408900545, 0.00094046842255846, -0.000188022939352273, -0.000470212074305643, -0.000470433277716786, 0.00234995643227709, 0.000938438507310124, 0.000937558666089799, 0.0034613440236777, 0.00493736156014979, 0.00046453292050951
Does anybody can help me with this one?
Thank you!
fortunately I found that there was an error in the code.
kpcaa=kpca(x=inputTrain,data=NULL,kernel="rbfdot",kpar=list(sigma=0.01))
has to be something like...
kpcaa=kpca(~.,data=inputTrain,...)
Related
To start, I created a Network using 2014 flight data as explained here:https://ipython-books.github.io/142-drawing-flight-routes-with-networkx/
I'm trying to create smaller graphs using airline specific flight paths to test connectivity within each business, starting with American Airlines, I did the following:
AASys = routes[
routes['source'].isin(airports_us.index) &
routes['dest'].isin(airports_us.index) &
routes['airline'].str.contains('AA')]
AASys
AAedges = AASys[['source', 'dest']].values
AAedges
AAg = nx.from_edgelist(AAedges)
len(AAg.nodes()), len(AAg.edges())
This mirrors the tutorial input almost exactly, with the only change being the additional str.contains('AA'). But when I try to test the len() of my new database, I get -- TypeError: 'str' object is not callable.
Can anyone explain why my edgelist is reading as a string? How to I fix the TypeError?
I want to use C++ to load TensorFlow model. And I want to know size of model's input, which is the placeholder in the model.
I google this problem, but I just find this link in stackoverflow :
C++ equivalent of python: tf.Graph.get_tensor_by_name() in Tensorflow?
Although I can get node, but tensorflow document don't tell me how to access the size of the node. So is there anyone know something about this?
Thank you so much!
OK,after many times attempts. I have find a workaround solution, It maybe tricky but works well.
At first, we can get the placeholder node using following code:
GraphDef mygd = graph_def.graph_def();
for (int i = 0; i < mygd.node_size(); i++)
{
if (mygd.node(i).name() == input_name)
{
auto node = mygd.node(i);
}
}
Then through the NodeDef.pd.h(tensorflow/core/framework/node_def.pb.h), we can get AttrValue through code like below:
auto attr = node.attr();
Then through the attr_value.cc(tensorflow/core/framework/attr_value.cc), we can get the shape attr value through code like below:
tensorflow::AttrValue shape = attr["shape"];
and the shape AttrValue is the structure used to store shape information. We can get the detail information through the function SummarizeAttrValue in tensorflow/core/framework/attr_value_util.h
string size_summary = SummarizeAttrValue(shape);
And then we can get the string format of shape like below:
[?,1024]
I want to get the email body from my Gmail account for an email so i use this code i found it in an example for how to read emails using c++ builder pop3
the code to extract body used
TIdText *EText;
int message = SpinEdit1->Value;
MyPoP3->Retrieve(message, MyEmail);
Edit1->Text = MyEmail->Subject + " | " + MyEmail->From->Address;
Memo1->Clear();
for (int i = 0; i < MyEmail->MessageParts->Count; i++) {
Memo1->Lines->Add(MyEmail->MessageParts->Items[i]->ContentType);
EText = dynamic_cast<TIdText*>(MyEmail->MessageParts->Items[i]);
Memo1->Lines->Add(EText->Body);
}
the problem is that i got undefine symbol to TidText and what i tried is to change it from TIdText to TIdMessage, but i got that i can't convert to it.
also i tried to try this without loop or something MyEmail->Body->Text
this return empty string.
the video i got this code from it here i don't know maybe the c++ builder he use is old. now i want to know how to extract the body text from the email address.
Thanks in advance.
the problem is that i got undefine symbol to TidText
Your code is missing an #include <IdText.hpp> statement.
what i tried is to change it from TIdText to TIdMessage, but i got that i can't convert to it.
Because TIdMessage does not contain nested TIdMessage objects.
also i tried to try this without loop or something MyEmail->Body->Text this return empty string.
If your email is MIME encoded, its text is not stored in the TIdMessage::Body property, but in a nested TIdText object within the TIdMessage::MessageParts collection. You have to look at the TIdMessage::ContentType property to know what kind of structure the email contains. For instance, if the CT begins with text/, the text is in the TIdMessage::Body. But if the CT begins with multipart/, the text is somewhere in the TIdMessage::MessageParts instead.
You should read this blog article on Indy's website for an example of how emails might be structured:
HTML Messages
the video i got this code from it here i don't know maybe the c++ builder he use is old.
No, it is not.
Hello :) I would like to import the data I marked as red.
after connecting my program to DB,
I executed this line
m_strE37 = m_command.GetString(37);
but unfortunately, m_strE37 stores "1.6799999999999"
their class is as follows
CString m_strE37;
typedef CCommand<CDynamicsStringAccessorW,CRowset> DbCommand;
DbCommand m_command;'
I Selected that record(row) and tried to get the value by using GetString(37) since it is 37th column.
I was quite new to this DB Process.
Can anyone help me to correctly get 1.68 ??
Thank you a lot in advance!
Try this snippet:
float f = atof(m_strE37);
m_strE37.Format("%3.2f",f);
For unicode :
float f = atof(CStringA(m_strE370.GetString()));
m_strE37.Format(L"%3.2f",f);
I am new to Python and am trying to get my ahead around parsing SSE client code. I am using the SSE Client library. My code is very basic and follows the sample exactly. Here it is:
from sseclient import SSEClient
devID = "xxx"
AToken = "xxx"
sparkURL = 'https://api.spark.io/v1/devices/' + devID + '/events/?access_token=' + AToken
messages = SSEClient(sparkURL)
for msg in messages:
print(msg)
print(type(msg))
The code runs without a problem and I see some blank lines and SSE data coming through. Here is the sample output:
<class 'sseclient.Event'>
{"data":"0 days, 0:54:43","ttl":"60","published_at":"2015-04-09T22:43:52.084Z","coreid":"xxxx"}
<class 'sseclient.Event'>
<class 'sseclient.Event'>
{"data":"0 days, 0:55:3","ttl":"60","published_at":"2015-04-09T22:44:12.092Z","coreid":"xxx"}
<class 'sseclient.Event'>
The actual output above looks like a dictionary, but its type is "sseclient.Event". I am trying to figure out how to parse the output so I can pull out one of the fields and nothing I have tried has worked.
Sorry if this is basic questions, but can someone provide some simple guidance on how I would either convert the entire output to a dictionary or perhaps just pull out one of the fields?
Thank you in advance!
I figured this out. In case anyone else experiences the same problem, here is how I got it to work. The key was using msg.data and not just msg. I then converted the out using the JSON library and am good to go.
messages = SSEClient(sparkURL)
for msg in messages:
outputMsg = msg.data
if type(outputMsg) is not str:
outputJS = json.loads(outputMsg)
FilterName = "data"
#print( FilterName, outputJS[FilterName] )
print(outputJS[FilterName])