From Python to C#

The very first language I had learned was Python, and I was planning to stick with Python for as long as I possibly could. Python was the perfect first language to learn as a beginner embarking into this field for the first time.

However, if I want to take full advantage of the opportunities around me, I must learn C#. Therefore, this weekend marks my very first major pivot in my learning journey–learning a new programming language!

This new chapter is making me feel all sorts of things. First, it’s making me feel like I’m growing as a programmer because I’m no longer going to be stuck to one language. Whereas I have a personal appreciation for Python since it’s the point at where I began, I haven’t been able to find many other people or businesses around me who work heavily with Python. A lot of what I have seen has involved other languages, C# for example.

I’ve only just begun an introduction course on C# and already I have so many questions. What helps is that, unlike when I was learning Python, for C# I have something to compare the language to, and real, in-person friends to discuss C# with. It’s an added bonus that my husband needs to improve and learn more C# for his job as well, so we will be learning together.

using System;

namespace Hello World
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

As the tradition continues, I executed my first Hello World program in C#. The very initial “installing everything and get it running” part of learning a new language (and getting it to work) is always the first hump to get passed. I remember installing and setting up Python very clearly for the first time, and the fear that came with needing to redo it on a whole bunch of other systems afterwards.

My very, very first initial impression of C# is that it’s already very visually different than Python. The structure of the code block is much larger to execute that Hello World program than what the equivalent would be in Python. I find that aspect interesting, and hope to learn why C# has a very elongated visual structure. A part of me wonders if this helps programmers find blocks of text in larger program files because of the way the curly braces signal to the eye that the block has concluded. Whereas, for Python, there’s a more linear structure and spacing.

I also learned a helpful nugget from the Programming Throwdown podcast that Python and C-based languages work very well together. That makes me feel very comfortable and optimistic about learning C# as my next programming language!

Time to get back to that introductory course!

Hacktoberfest 2019!

Image source – https://hacktoberfest.digitalocean.com

Project and Learning Update

Before I get into the Hacktoberfest fun, I wanted to update you on my progress since the last post.

I was in New York visiting family these past few months (I recently moved from NYC to Florida last year) so it’s been a little hectic! Luckily my brain needed the time to process everything I had learned from the previous machine learning course before diving into a new one.

Since then, I’ve began another course on Udemy about Machine Learning and Data Science in Python and R, which is dense but very fascinating! I’ll definitely need to add math for python, and matrix math, to my list of topics to study.

I’ve also connected to an awesome community, Women Who Code organization, which is how I learned about Hacktoberfest, through conversation on the slack channel!

Hacktoberfest Participation

For Hacktoberfest, everyone get’s together and participates in helping open source code by submitting contributions. Open source is another reason why I love this field, because the teamwork is inspiring. In order to do this you need to use GitHub to submit pull requests. Prior to this event, I had some light experience in GitHub but hadn’t gone into too much depth yet. After this event, I now understand how incredibly crucial it is for anyone interested in developing to become proficient. It’s a skill most employers will expect you to have, as a bare minimum. Moreover, GitHub is where a lot of the magic happens.

In order to be considered a full participant of Hacktoberfest and receive a super cool shirt, (dreams!), you need to submit at least four pull requests that adhere to the Hacktoberfest guidelines and rules.

I submitted five pull requests. I felt so happy to see the bar completed! But, my requests had a little clock icon near it, meaning that their eligibility was pending. To this day, a few months later, they’re still pending. However, two of my submissions were unfortunately submitted to ineligible repositories. Since the repository was ineligible, so was my pull request on that repository.

If any of these words confuse you, don’t worry, they confused me too at first. But as a beginner, I loved the freedom of Hacktoberfest. It was a time where everyone was getting together and people knew that beginners would be involved. This gave me more confidence to actually participate by submitting pull requests with less fear.

I’m so incredibly happy to have participated in Hacktoberfest this year, and am excited to see my performance for next year’s event after much more learning. I’m now off to learn, more formally, about GitHub, in preparation!

Happy Coding!

Intro to Data Visualization with Python

Over the past few months as my learning journey continued, I finally completed my first introductory course in data visualization and plotting in Python. It was a short course on Udemy which focused on utilizing the matplot library. Besides learning the actual course objective, which was plotting, I also learned something very important from this course, which was how to utilize a library in Python.

Plotting with matplotlib and pyplot

Above is a screenshot of my screen with the code we wrote in the course and the chart that was produced once the code ran. This was incredibly exciting for me to see and test for myself because I had no idea how writing code would create a chart. I had a lot of questions about data science and absolutely no frame of reference into the subject prior to this course, but this introduction has piqued my interest!

The library that we were working with had a lot of features that made it simple to create visuals and change them as needed. The image above shows many lines of code beginning with plt. and that is because we were heavily working within that library and using its prewritten features. I never actually took a course that focused on utilizing a single library; the other courses and projects I have done used multiple libraries, so although I was able to follow the general philosophy behind their usage, this course really helped me understand the basics much better.

Scale Matters

One takeaway I took from this introductory course is that when working with data, scale matters. Scale alters the initial impression of what the visual data is saying. For example, we changed the y and x axis values often, and when doing this, the lines on the graph, including where they began and ended, shifted in ways that changed the visual to relay different messages. This made me realize why data science, interpretation, and visualization is so important.

Since I’m a visual learner, the visual aspect of data science is very satisfying for me because it combines two aspects that I favor: information and art.(Yes, for the sake of this post, I will consider a graph a piece of art!)

I’ve worked heavily with data in previous jobs, and with this new knowledge, I think back to all of our excel spreadsheets with statistical data sorted from A-Z, and wonder what that data would have said if plotted in a chart. What trends that may have been overlooked would we be able to see?

What’s Next?!

I will be posting soon about this year’s Hacktoberfest! Because I’ve been traveling these past few months, it’s been a tad difficult to write as many posts as I would like, but that won’t be the case for much longer!

Lastly, once I get back to my home base and re-unite with my Raspberry Pi and Vector Robot, I will be utilizing my new knowledge for more projects. This course made me better able to understand how to utilize the libraries offered in the Anki Vector SDK, which I’m very happy to test out! It feels wonderful to witness information click together.

Getting Lost in The (Google) Cloud(s)

I’ve been very interested in the topic of machine learning, so I did some research and found an awesome project that I could do with my Vector Robot (…who I may refer to as El Robo sometimes).

The Project:

After some research, I found a project that would allow me to learn about robotics, machine learning, and object detection with Vector: https://medium.com/@unbug/anki-vector-detects-objects-with-machine-learning-a095317326e1

Basically, the project would allow my Vector Robot to connect to the Google Cloud Vision API so it could machine learn and object detect.

The list of instructions seemed short enough:

INSTRUCTION SET A

  1. Install Vector Python SDK. You can test the SDK by running any of the examples from anki/vector-python-sdk/examples/tutorials/
  2. Set up your Google Vision account. Then follow the Quickstart to test the API.
  3. Clone this project to local. It requires Python 3.6+.
  4. Don’t forget to set Google Vision environment variable GOOGLE_APPLICATION_CREDENTIALS to the file path of the JSON file that contains your service account key. e.g. export GOOGLE_APPLICATION_CREDENTIALS="/Workspace/Vector-vision-62d48ad8da6e.json"
  5. Make sure your computer and Vector in the same WiFi network. Then run python3 object_detection.py.

source – https://medium.com/@unbug/anki-vector-detects-objects-with-machine-learning-a095317326e1

Step one was easy-peasy, since I had tested and ran the SDK a multitude of times previously already (woo-hoo!). But oh boy, guess what Step 2 truly looked like once you followed the Quickstart link for the API setup:

INSTRUCTION SET B

  1. Select or create a GCP project.
  2. Make sure that billing is enabled for your Google Cloud Platform project.LEARN HOW TO ENABLE BILLING
  3. Enable the Cloud Vision API.ENABLE THE API
  4. Set up authentication:
    1. In the GCP Console, go to the Create service account key page.GO TO THE CREATE SERVICE ACCOUNT KEY PAGE
    2. From the Service account list, select New service account.
    3. In the Service account name field, enter a name.
    4. From the Role list, select Project > Owner.Note: The Role field authorizes your service account to access resources. You can view and change this field later by using the GCP Console. If you are developing a production app, specify more granular permissions than Project > Owner. For more information, see granting roles to service accounts.
    5. Click Create. A JSON file that contains your key downloads to your computer.
  5. Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the file path of the JSON file that contains your service account key. This variable only applies to your current shell session, so if you open a new session, set the variable again.Example: Linux or macOSExample: Windows

For more on setting up your Python development environment, refer to the Python Development Environment Setup Guide.

pip install --upgrade google-cloud-vision

source – https://cloud.google.com/vision/docs/quickstart-client-libraries

Yeah, so things got complicated real fast. Instruction Set A:PT 2 is where I officially fell down the rabbit hole of Google Cloud.

For ease of reference, I’ve labeled the instructions sets A and B, but let’s be clear: All of B is actually just a sub-set of A. Instruction set B is just to set up Google Cloud Platform account and installation, which was not something I was anticipating to learn throughout this journey, but I am so happy I stumbled upon it!

Google Cloud is offering one year free for new users, which is a crazy value considering the retail price allotted is $900+ for the year!

Once I set up my Google Cloud Platform account and logged into the console, I felt a unique sense of adrenaline, almost with a tint of rebellion.

Reading all of the tabs and sub-tabs like: Cloud Build, Big Data, and last but not least… Artificial Intelligence. I don’t even have the right words that could capture the feelings I was experiencing while scrolling up and down the console’s navigation menu, but I definitely had a huge smile on my face. Although I had (and still don’t) exactly know what Google Cloud can do or how to use it fully, what was clear right away, even as a complete novice, was that this tool is powerful and if learned properly, it could be utilized for epic projects (and help with future career prospects, *wink wink*).

Im a very visual learner, so seeing the categorization of the navigation menu taught me vital information for my coding journey, because it can be used like a road map. Now I know for sure that two areas of interest I have going forward involve Big Data and Artificial Intelligence.

As I continued to read Google’s instructions, a little voice was starting to whisper that perhaps this project was over my head. Especially once I got down to Instruction Set B: Step 5

  • Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the file path of the JSON file that contains your service account key. This variable only applies to your current shell session, so if you open a new session, set the variable again.

Which corresponded to Instruction Set A: Step 4

  • Don’t forget to set Google Vision environment variable GOOGLE_APPLICATION_CREDENTIALS to the file path of the JSON file that contains your service account key. e.g. export GOOGLE_APPLICATION_CREDENTIALS="/Workspace/Vector-vision-62d48ad8da6e.json"

And these instructions left me like this:

But no matter how much I re-read the instructions, I just couldn’t understand what they were telling me, which actually made me feel as if I didn’t even know how to read! After some trial and error, I looked more like this:

Finally, I decided to cave and ask for help. Luckily, my husband and his coworkers were over. I asked them for help but quickly came to learn that Google Cloud is a pretty niche subject to just casually ask about.

“Damnit, Jason!”

I was stuck on the .json file part, for which I kept yelling “Damnit, Jason!” in the house, confusing everyone. (“Jason” has now become an inside joke in the house, and from now on, whenever I work with .json files again, this first memory will be in my mind).

The next day while cooking dinner, I decided to watch a YouTube instructional video on how to setup Google Vision. As the tutorial leader was going through the steps, I was happy to see that some of the steps were very familiar, which meant I had definitely learned something from the previous day. And then finally, I got my answers, and the instructions were demystified. I was so, so happy to finally understand what the heck the above steps meant and looked like.

What I love most about coding and these projects is that I end up learning about so much more than what I initially intend.

Through this process I learned about:

  • Google Cloud Platform
  • How to install and configure Google Cloud Vision API
  • Virtual Environments and Environment Variables
  • Changing .bash profile in the terminal (including how to inadvertently fuck up your bash profile, and then fix it again).
  • More about python pip installations and configurations
  • How to move through different directories in the terminal

Finally, I had made it passed every single step and it was finally time to test out the python program to see if my Vector Robot would begin object detecting.

Successfully setting up the Google Cloud Vision API was such a pivotal milestone for me in this learning journey.

Now, that means that I had just gotten past one subset of the main instructions for my intended purpose of setting all of this up, which was ultimately to run one program, created by one single person, and see if it worked.

Drumroll…anticipation…andddddd:

It did not work.

Type Error:__init__() got an unexpected keyword argument ‘enable_camera_feed’ 

I looked over all of my steps. Everything was in order, but I kept getting a Type Error from the python file written by the creator. After countless web searching and troubleshooting, I was at a dead end. I had only one option left. I had to contact the person who made the program.

I went to GitHub and posted my first “issue” on the python file. This was the first time I had ever posted an issue, so I was very unsure of any “etiquettes.” The creator got back to me and said that he had created and tested this back with the old Anki Vector SDK package, and not the most recently updated one.

This may seem like a very sad ending to this story, since the project was not successfully executed on my end, but I was so happy with that response from the creator! The reason being because the creator didn’t say that my error message was due to something wrong with my steps, but perhaps elements outside of my control.

What a relief! For that alone, I considered this project a “success” in that I followed through to the end.

Although I couldn’t get this program to work, that doesn’t mean I can’t try to write my own program utilizing similar features. This project taught me a lot of different lessons and I can’t wait to try more Google Cloud Platform projects while I have the free trial!