How to implement NEAT into a pygame? - python

I'm fairly new to StackOverflow, so please forgive me if this is in the wrong section, or if I'm not supplying enough information.
I've been inspired by videos on the internet that use genetic algorithms with neural networks using the NEAT algorithm. I've downloaded the XOR example from the neat-python docs and understood most of its code, as well as ran it myself and experimenting with it. However, I would like to learn how I would implement this into a simple Flappy Bird styled game using Python 2.7 and pygame, as I think that would be the easiest to do. All I need is information to jump-start me and take off. :)
Thanks!

Related

Simple Captcha Solver with Python

I'm reaching to you to get some help and advices on creating a "Captcha Solver" using python and any image detection to text package
This is an example of the captcha (it contains only 4 character and its always numbers):
I am not sure if I should use a complex solver with AI and CNN and Machine Learning or just something more simple but I feel like I can't find a good tutorial... Instread I just find compagnies selling a package of multiple captcha solving...
Thanks in any case for the time and advice,
Daniel
I have tried to use these :
https://github.com/ptigas/simple-captcha-solver
https://gist.github.com/lobstrio/8010d0a21c48b8c807f0c3820467ee0c
https://github.com/cracker0dks/CaptchaSolver
I would recommend you use Tesseract or Tesseract.JS. You will find plenty of useful tutorials and articles on how to use Tesseract. you might wanna explore some additional Algorithms to reduce the noise in the image.

How to create a neuronal network in machine learning to make statistics?

I'm actually working on a machine learning project and I need to make some "previsions".
I have this datas (solar panel and kind of weather)
I need to make a prevision of the energy efficiency of the following days.
I search a little bit on this, there is some informations about neuronal network like Keras. I install it but I just don't know how to make it works in my situation. I am beginer in machine learning, I learn a lot about this but it's a lot of theory and little practice so I'm really lost.
If there is someone who can just says me how can I do or give me something like a search trail !
Thanks a lot for the support !
To use keras/tensorflow or other libraries you need to know how to code in python at least and should have the understanding of neural networks. To begin with, you can have a look at knime (https://www.knime.org/) this provides similar functionalities but you need not do any coding. This might help you in understanding what's happening when you apply any kind of algorithm. Once you have a fair idea you might want to try to use keras/tensorflow.

Can difflib be used to make a plagiarism detection program?

I am trying to figure this out...
Can the difflib.* library in Python be used to make some kind of plagiarism detection program? If so how?
Maybe anyone could help me to figure out this question.
It could be used, but you're going to face all the same general issues you find in automated plagiarism detection. It might give you a little bit of a head start on implementing some of the algorithms you need, but I don't think it is likely to take you very far.
The short answer is yes.
The long answer is that it will be a lot of work and you'll probably find that you'd be better using another language or an off-the-shelf tool, depending on the vast amount of sources you're likely to be referencing.

Is python is a good choice as language used to implementing my first 3D model?

I am C/C /Java programmer, but lately I have started learn Python.
Moreover I have 3D Graphics on my studies. I have to create 3D model of my apartment, with dynamic camera. I am wondering if this is a good idea to merge this two issues, by writing this 3D model in python.
However as I said, I am a python beginner, so I don't know possibilities, which python can give me in this area. Which libraries/engine will be the best for a start?
You can also checkout Pyglet, which is a higher-level library for using with OpenGL.
IMHO C++ is a better option for 3D graphics, and you have experience in it.
Though you can have a look at PyOpenGL, python bindings for OpenGl.
http://pyopengl.sourceforge.net/
If you're solely trying to learn how to do a 3d model go for the language you're the most familiar with. I'd recommend C++ or C# in that case (whichever of the 2 you meant with the second C).
If you also want to learn more about the language Python is the better choice.
But pure language wise I wouldn't say that C++/c#/python beats the other.
There are a lot of options and libraries regardless of the language you choose. But if you need a quick and dirty model you might want to check out VPython, which is python plus a simple 3D library (http://vpython.org/index.html. There are video tutorials at: http://www.youtube.com/vpythonvideos
The programming part would likely be very easy using VPython.
The hard part is creating the object for your apartment, which you might have to do by hand, with hand coding of the coordinates to define each object. The VPython site has a utility for importing .stl files, and many 3D programs, e.g., Blender, will export .stl files. (I've never used this, so I can't speak to how well it works).
If you just need to model the walls, floor, and ceiling, and maybe a simple object or two, it wouldn't be hard to hand-code the coordinates. Sketch it out on graph paper and make notes of the z axis values.

Machine vision in Python

I would like to perform a few basic machine vision tasks using Python and I'd like to know where I could find tutorials to help me get started.
As far as I know, the only free library for Python that does machine vision is PyCV (which is a wrapper for OpenCV apparently), but I can't find any appropriate tutorials.
My main tasks are to acquire an image from FireWire. Segment the image in different regions. And then perform statistics on each regions to determine pixel area and center of mass.
Previously, I've used Matlab's Image Processing Tootlbox without any problems. The functions I would like to find an equivalent in Python are graythresh, regionprops and gray2ind.
Thanks!
OpenCV is probably your best bet for a library; you have your choice of wrappers for them. I looked at the SWIG wrapper that comes with the standard OpenCV install, but ended up using ctypes-opencv because the memory management seemed cleaner.
They are both very thin wrappers around the C code, so any C references you can find will be applicable to the Python.
OpenCV is huge and not especially well documented, but there are some decent samples included in the samples directory that you can use to get started. A searchable OpenCV API reference is here.
You didn't mention if you were looking for online or print sources, but I have the O'Reilly book and it's quite good (examples in C, but easily translatable).
The FindContours function is a bit similar to regionprops; it will get you a list of the connected components, which you can then inspect to get their info.
For thresholding you can try Threshold. I was sure you could pass a flag to it to use Otsu's method, but it doesn't seem to be listed in the docs there.
I haven't come across specific functions corresponding to gray2ind, but they may be in there.
documentation: A few years ago I used OpenCV wrapped for Python quite a lot. OpenCV is extensively documented, ships with many examples, and there's even a book. The Python wrappers I was using were thin enough so that very little wrapper specific documentation was required (and this is typical for many other wrapped libraries). I imagine that a few minutes looking at an example, like the PyCV unit tests would be all you need, and then you could focus on the OpenCV documentation that suited your needs.
analysis: As for whether there's a better library than OpenCV, my somewhat outdated opinion is that OpenCV is great if you want to do fairly advanced stuff (e.g. object tracking), but it is possibly overkill for your needs. It sounds like scipy ndimage combined with some basic numpy array manipulation might be enough.
acquisition: The options I know of for acquisition are OpenCV, Motmot, or using ctypes to directly interface to the drivers. Of these, I've never used Motmot because I had trouble installing it. The other methods I found fairly straightforward, though I don't remember the details (which is a good thing, since it means it was easy).
I've started a website on this subject: pythonvision.org. It has some tutorials, &c and some links to software. There are more links and tutorials there.
You probably would be well served by SciPy. Here is the introductory tutorial for SciPy. It has a lot of similarities to Matlab. Especially the included matplotlib package, which is explicitly made to emulate the Matlab plotting functions. I don't believe SciPy has equivalents for the functions you mentioned. There are some things which are similar. For example, threshold is a very simple version of graythresh. It doesn't implement "Otsu's" method, it just does a simple threshold, but that might be close enough.
I'm sorry that I don't know of any tutorials which are closer to the task you described. But if you are accustomed to Matlab, and you want to do this in Python, SciPy is a good starting point.
I don't know much about this package Motmot or how it compares to OpenCV, but I have imported and used a class or two from it. Much of the image processing is done via numpy arrays and might be similar enough to how you've used Matlab to meet your needs.
I've acquired image from FW camera using .NET and IronPython. On CPython I would checkout ctypes library, unless you find any library support for grabbing.
Foreword: This book is more for people who want a good hands on introduction into computer or machine vision, even though it covers what the original question asked.
[BOOK]: Programming Computer Vision with Python
At the moment you can download the final draft from the book's website for free as pdf:
http://programmingcomputervision.com/
From the introduction:
The idea behind this book is to give an easily accessible entry point to hands-on
computer vision with enough understanding of the underlying theory and algorithms
to be a foundation for students, researchers and enthusiasts.
What you need to know
Basic programming experience. You need to know how to use an editor and run
scripts, how to structure code as well as basic data types. Familiarity with Python or other scripting style languages like Ruby or Matlab will help.
Basic mathematics. To make full use of the examples it helps if you know about
matrices, vectors, matrix multiplication, the standard mathematical functions
and concepts like derivatives and gradients. Some of the more advanced mathe-
matical examples can be easily skipped.
What you will learn
Hands-on programming with images using Python.
Computer vision techniques behind a wide variety of real-world applications.
Many of the fundamental algorithms and how to implement and apply them your-
self.

Categories