How can i use the filters and other functions in weka in python? - weka

i copied a piece of code : from weka.core.filters import Filter
it comes from EDUCBA
it seems tha it can use the filters from weka in python
but when run it it always gets something wrong
it told me that: Unresolved reference 'Filter'
how can i deal with it?

Related

What is a difference between tf.GraphDef.FromString and tf.GraphDef.ParseFromString?

What is a difference between tf.GraphDef.FromString and tf.GraphDef.ParseFromString ? I cannot find anything for FromString in tensorflow documentaion.
I am trying to run a model protobuf file in C++ but the prediction output is empty. In python example the model is loaded using tf.GraphDef.FromString function. In C++ I am using ReadBinaryProto method, I am wondering if there is some other way to load the model in C++ that corresponds to tf.GraphDef.FromString .

How does one bypass SyntaxError when parsing code?

I am using openpyxl to read an excel file that will have changing values over time. The following function will take string inputs from the excel sheets to make frames for Tkinter.
def make_new_frame(strng, frame_location, frame_name, frame_list):
if not(frame_name in frame_list):
frame_list.append(frame_name)
exec("global %s" %(frame_name)) in globals()
exec("%s = Frame(%s)"%(frame_name, frame_location))
.... etc.
The code itself is quite long but I think this is enough of a snapshot to address my problem.
Now this results in the following error while parsing:
SyntaxError: function 'make_new_frame' uses import * and bare exec, which are illegal because it is a nested function
Everything in the code I included parsed and executed just fine several times, but after I added a few more lines in later versions in this function, it keeps spitting out the above error before executing the code. The error references the third line in the function, (which, I repeat, has been cleared in the past).
I added "in globals()" as recommended in another SO post, so that solution is not working.
There is a solution online here that uses setattr, which I have no idea how to use to create a widget without eventually using exec.
I would really appreciate if someone could tell me how to bypass the error while parsing or provide an alternative means for a dynamically changing set of frame names.
Quick Note:
I am aware that setting a variable as global in python is generally warned against, but I am quite certain that it will serve useful for my code
Edit 1: I have no idea why this was downvoted. If I have done something incorrectly, please let me know what it is so I can avoid doing so in the future.
I think this is an X/Y problem. You are asking for help with solution Y instead of asking for help on problem X.
If your goal is to create an unknown number of Frame objects based on external data, you can store references to the frame in a list or dictionary without having to resort to using exec and dynamically created variable names.
exec is a perfectly fine function, but is one of those things that you should never use until you fully understand why you should never use it.
Here's how to solve your actual problem without using exec:
frames = {}
def make_new_frame(strng, frame_location, frame_name, frames):
if not(frame_name in frames):
frames[frame_name] = Frame(frame_location)
return frames[frame_name]
With that, you now have a dictionary (frames) that includes a reference for every new frame by name. If you had a frame named "foo", for example, you could configure and pack it like this:
frames["foo"].configure(background="red", ...)
frames["foo"].pack(...)
If preserving the order of the frames is important you can use an OrderedDict.

Tensorflow error using tf.image.random : 'numpy.ndarray' object has no attribute 'get_shape'

Intro
I am using a modified version of the Tensorflow tutorial "Deep MNIST for experts" with the Python API for a medical images classification project using convolutionnal networks.
I want to artificially increase the size of my training set by applying random modifications on the images of my training set.
Problem
When I run the line :
flipped_images = tf.image.random_flip_left_right(images)
I get de following error :
AttributeError: 'numpy.ndarray' object has no attribute 'get_shape'
My Tensor "images" is an ndarray (shape=[batch, im_size, im_size, channels]) of "batch" ndarrays (shape=[im_size, im_size, channels]).
Just to check if my input data was packed in the right shape and type, I have tried to apply this simple function in the (not modified) tutorial "Tensorflow Mechanics 101" and I get the same error.
Finally, I still get the same error trying to use the following functions :
tf.image.random_flip_up_down()
tf.image.random_brightness()
tf.image.random_contrast()
Questions
As input data is usually carried in Tensorflow as ndarrays, I would like to know :
Is it a bug of Tensorflow Python API or is it my "fault" because
of the type/shape of my input data?
How could I get it to work and be able to apply tf.image.random_flip_left_right to my training set?
This seems like an inconsistency in the TensorFlow API, since almost all other op functions accept NumPy arrays wherever a tf.Tensor is expected. I've filed an issue to track the fix.
Fortunately, there is a simple workaround, using tf.convert_to_tensor(). Replace your code with the following:
flipped_images = tf.image.random_flip_left_right(tf.convert_to_tensor(images))

Embedding Rekall in an external python program

http://docs.rekall.googlecode.com/git/tutorial.html#_embedding_rekall_in_an_external_python_program
I try to run the program as the link suggested, however i am getting this error
"ValueError: Unable to load profile WinXPSP2x86 from any repository."
look like it does not automatically search for Profile like running commands
this should be the old codes, as WinXPSP3 is not a valid profile name, so with the suggestion from the author, I am looking into
https://code.google.com/p/grr/source/browse/client/client_actions/grr_rekall.py#157
but i am new to it, need some help to make it work
e.g. import an image, and call pslist
any ideas? thanks a lot!
You are just following an old link that is not accessible anyway.
http://www.rekall-forensic.com/docs/Manual/tutorial.html
The example found here works well !

Custom sorl-thumbnail processor

I found a question (and an answer) related to sorl-thumbnail that looks like a good point related to what I’m looking for :
Image filtering with the new sorl-thumbnail. But my django knowledge is far too weak to understand what I could do with that.
I’d like to extend sorll-thumbnail so that I could process an image before serving it. For example : add a blur effect. I can deal with the image processing part (already done such things with php/imagemagick), but I don’t know where to start to plug my own function above sorl-thumbnail.
In my project, I installed the lib with pip. Where in my code can I create a class/subclass so that I could pass an argument to the templatetag? What should this class look like?
Is the RoundedCornerEngine class described in the mentioned post ok ? Where should I have this code ?
Thanks for your help.
Anywhere… Ok…
The only detail is to correctly link the new Engine from the settings :
THUMBNAIL_ENGINE = "my.module.MyEngine"
If anyone is looking for custom processors, built with PIL on top of sorl-thumbnail, here are two examples : https://gist.github.com/1647660 and https://gist.github.com/1920535.