Posts

Python enchant and building a spell checker

Image
I decided to do this experiment because I realized Whispering wall would default to the end clause if everything a user enters is spelled wrong. Pictured below:  Watson assistant failed when I told him "I want to work on improving watson"  I probably had a mispelling, I can not fathom why it didn't pick something out of the sentence to use. h htt https://twitter.com/NelliesNoodles/status/1109236474640257024 ps://twitter.com/NelliesNoodles/status/1109236474640257024 ttps://twitter.com/NelliesNoodles/status/1109236474640257024 My enchant dictionary checked the validity of a word, but if that word was misspelled it was not valid, and placed in the errors.  The enchant dictionary also has an issue with whitespace, as I found out doing this, and that needed to be corrected for Wiwa also. Hoping to update her tomorrow. I still have to build the method that returns a 'fixed it for you' sentence, But I am debating if I want wiwa to just run with whatever w...

Python class and instance explained in simple terms

I was trying to explain this to someone in the forum, and decided it's time to re-write how class's, instances, object, and self work.  Here it goes, a big ol' metaphor. A Python class is like a blueprint. I have all the technical data inside it to lay out how to build a particular object. The Python compiler is going to store that code away, and then you can 'access' it, or build something from that blueprint.  The thing that is built is the instance. class Spamalot(object):     def __init__(self):         self.spam = "spam"     def give_me_spam(self):         print("here is your ", self.spam) It's just a silly class that doesn't do much.  Python has much more complex class's stored away in it's library for us to use on a regular basis.  Blueprints to something like : BaseException or modules like math. We create instances of Spamalot because we don'...

JavaScript Ascii animation with while loops and console.log

I was working on figuring out while loops for an exercise in LearnJavaScriptTheHardWay  by Zed Shaw,  and I decided to do this: The red text console.logs were for debugging, and will take over the animation if the comments are removed. The bold red number is the point at which the loop stops.  My CPU didn't have too much trouble with that large number, but I'd recommend dialing it down if your CPU is slow. Also if your CPU is really fast, you'll have to change the pause to something much lower to see the animation better.  That too is in a loop, so the more that pause happens, the more loops your CPU is running.   Link: https://stackoverflow.com/questions/9006988/node-js-on-windows-how-to-clear-console To clear screen as described in link above, uncomment the bold purple comment I tried to comment the code to help learners see what I did,  any comments or suggestions, feel free to drop em in!        ...

refactor Python Binary Tree

Image
I have an older post where I posted this code, but I wanted to explain my 'delete' method in more detail. Take a look at this: [alt attribute attached] This depicts how at some point, depending on which side of a node you are on, there is a limit to how far a branch can reach. 'A' would be the Left child node of 'H', and the farthest it's right branches can reach is to 'H'.   Anything more than H, is on the other child node on the right. Likewise, for child node 'Z',  it's left most branches have the same limit of 'H'.  Because all other smaller/lesser than keys would go on the left child node. At first I had my delete method throwing all right children onto the right branch of the left child  and replacing the parent node with that modified left child. But then I realized: [alt in image] The right most branch of the right side of root has limitless potential.  It is not restricted in any way by the median f...

pandas python and probability Part 2

Image
So I may have a really weird way going about figuring this stuff out. I pound in code, break it tons of times and then keep googling until I find what I need to fix each break.  I have a very strong feeling the test first crowd would be furious with me.... But,  here it goes. I wanted to create a training set for my machine learning experiment. This is the order in which I did that:    1) create the pandas database      pd.set_option('max_columns', 100)    train_data = { 'run number': [0], #'run number:' as key produces NaN results                 'odd probability': [0.50],                 'even probability': [0.50],                 }    train_prob_data = pd.DataFrame(train_data, columns = ['run numbe...

Pandas Python and a little probability

Image
Ok, so after looking through different tutorials, I found out pandas is way easier to handle then SQL. So for the first step in that machine learning experiment from the last post, I came up with this little piece of code. It uses random/randomint and pandas as import. Resources and references are in the code comments. As always, drop me a comment, hate it, love it, what to improve. Next step is to get this rolling with more math involved and a bigger sets of probability data to store. Adding an 'old_odd_probability' and 'old_even_probability' would probably be the next step toward getting that bayes to interpret a bigger picture of when and how random chooses it's *random integers*. For example, to use the water droplet example from Jurassic Park (assuming you repeat the experiment 5 times)... https://scienceonblog.wordpress.com/2017/04/13/chaos-theory-in-jurassic-park/    If the droplet tends to roll left off your hand the second time you try, and yo...

machine learning Experiment Psuedocode only

This is all psuedocode Disclaimer: None of the code has been run, tested or even typed into a code editor.  This post is to hold the experiment idea, for future use. Machine Learning Experiment (1-27-19) The idea is to try this out, so I can see how machine learning works more. I understand there is a lot of data reconciliation and probability involved. The libraries currently used in python are advanced and extremely well built I am sure, but I need to see the interaction, see what's happening and how. This may be completely wrong, but once again.... Why not? After completing the initial post, I have the suspicion that I am in way over my head. It's way past my bedtime, I gotta sleep.  So not just a grain of salt with this one, bring a whole bucket. 1:  SQLite does not support holding a list      solution, either use an INTEGER and increment                ...