teleren/devto huggingface dataset:
Principal Component Analysis (PCA)
Tags: datascience, machinelearning, beginners
Published: 2020-11-02 04:37:36

In the previous post, I discussed applying Principal Component Analysis (PCA) as a way to reduce feature space, by capturing maximum variance. So, why is variance a big deal? If there is no or little variation, it means we are not getting enough predictive information from the feature. 

Here, I wanted to experiment with covariance and correlation matrices and try to derive principal components using linear algebra. I will use the London bike sharing [dataset](https://www.kaggle.com/hmavrodiev/london-bike-sharing-dataset?select=london_merged.csv) from my previous blog. 

```python
### use 4 features
features = data.iloc[:,:4]
features.sample(5)
```
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/uag2u2b2b3splphy82u8.png)


So, the idea is to find eigenvalues and eigenvectors of the correlation matrix. Then, we can use eigenvalues to describe the explained variation ratio. 

Let’s start with the correlation matrix. We can use either original features or standardized for correlation matrix calculation, as it gives the same result.

```python
from sklearn.preprocessing import StandardScaler
# standardize features
features_scaled = StandardScaler().fit_transform(features)

# get correlation matrix on scaled features
np.corrcoef(features_scaled.T)

# correlation matrix on unscaled data gives the same result
# features.corr()

e_vals, e_vects = np.linalg.eig(np.corrcoef(features_scaled.T)) 

# normalize eigenvalues to get variations for each PC 
# sorted explained variation
# use np.sort(e_val)[::-1] to sort in descending order
print([x/e_vals.sum() for x in np.sort(e_vals)[::-1]])

```
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/rq7x07da24ymd15hz3o0.png)

We could do the same using the covariance matrix, but it requires a few more extra matrix manipulations before getting eigenvalues. You can find the code [here](https://github.com/xs-abzal/Blogs_stat_examples/blob/master/Correlation.ipynb). 


Let's check if we get the same result using sklearn’s PCA. I would like to mention that per sklearn [documentation](https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html), it uses SVD decomposition instead of eigendecomposition as we did above and we also need to standardize the data.



```python
# Use sklearn's PCA
from sklearn.decomposition import PCA

pca = PCA()

#fit and transform scaled features
pca.fit_transform(features_scaled)

# get explained varion ratio
print(pca.explained_variance_ratio_)
```

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ml2toal42f1e151ntn9j.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6q8005o91lih44i9v0lf.png)

As we can see, we got the same variance ratio. Based on that analysis, we can further decide how many principal components we would use and accordingly apply the projection matrix or sklearn to transform features into principal components.
Hacktoberfest
Tags: hacktoberfest, opensource
Published: 2020-11-02 04:33:29

---
title: Hacktoberfest
published: true
tags: hacktoberfest, opensource 
---
<!-- ✨This template is only meant to get your ideas going, so please feel free to write your own title, structure, and words! ✨ -->

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/36o6k4xtme9n9ma9cs63.jpg)


### completed Hacktoberfest 2020

#### 12 PRs

### Background

<!-- Are you brand new to open source? What about coding in general? Tell us about how you got here →

### Progress

<!-- Share a bit about where you’re at in your Hacktoberfest journey. What stage are you at? How has the process been?  -->

### Contributions
- [Robert Allen](https://github.com/robertjallen)
- [UnderdogDevs](https://github.com/Underdog-Devs/landed)


### Hacktoberfest is a great way to stay motivated and contribute to some unique open-source projects.
Lists and Keys
Tags: react, beginners, webdev, tutorial
Published: 2020-11-02 04:31:00

Rendering a list of items is very common in any Application.

If we render a list of items like this, then there is no problem.

```jsx
function FruitsList() {
  return (
    <ul>
      <li>apple</li>
      <li>banana</li>
      <li>grapes</li>
    </ul>
  )
}
```

If we render a list of items as an array, which very common in React.

```jsx
const fruits = ['apple', 'banana', 'grapes'];

function FruitsList() {
  return (
    <ul>
      // returns an array of React Element
      {fruits.map(fruit => <li>{fruit}</li>)}
    </ul>
  )
}
```

It will generate the same HTML, but with a warning.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/m6gngs7wmv7j3n3v9ebn.jpg)

We can interpolate an Array of renderable elements in React, but it has interesting implications when things change over time.

If you rerender that list with an added item, React does not really know whether an item is added at the beginning, middle, or end of the list. And the same goes for the removed items.

**Example 1**
{% codepen https://codepen.io/bipinrajbhar/pen/qBNYbpJ %}

If you remove the items from the end then it will work as expected but, if you remove items from the start or middle it will behave a little bit differently.

## **``key`` prop**

The ``key`` prop helps React to identify where the elements have changed, are added, or are removed.

```jsx
const fruits = [{id: 'apple', value: 'apple'}, {id: 'banana' value: 'banana'}, {id: 'grapes', value: 'grapes'}];

function FruitsList() {
  return (
    <ul>
      // returns an array of React Element
      {fruits.map(fruit => <li key={fruit.id}>{fruit.value}</li>)}
    </ul>
  )
}
```
##**Without key vs with array index as key vs with a proper key**.

**Example 2**
{% codepen https://codepen.io/bipinrajbhar/pen/JjKvXGq %}

> The behavior of React Element **without key** is the same as **with an array index as a key**.

I hope you learned something from this article and if you have any doubts, please leave a comment. I will be delighted to answer all of your questions.

My name is **Bipin Rajbhar** and I am a software engineer at [QuikieApps](https://www.quikieapps.com/), and you can follow or connect to me on [Twitter](https://twitter.com/Bipin_1598) and [Linked In](https://www.linkedin.com/in/bipinrajbhar1598/)

**Resources**
[The Beginner's Guide to React](https://egghead.io/courses/the-beginner-s-guide-to-react)
[Epic React](https://epicreact.dev/)
Reflecting on Hacktoberfest 2020
Tags: hacktoberfest
Published: 2020-11-02 04:20:07

<!-- ✨This template is only meant to get your ideas going, so please feel free to write your own title, structure, and words! ✨ -->
<!-- If you are new to the DEV community, introduce yourself and share a bit about why you joined DEV and decided to participate in Hacktoberfest this year.  --> 
Hi! My name is Helen, and I am a freshman at Duke University studying computer science (CS) and electrical and computer engineering (ECE). After hearing about Hacktoberfest, I decided that I wanted to give it a shot, and I had a great time and learned a lot! :)

<!-- Are you brand new to open source? What about coding in general? Tell us about how you got here -->
Although I have had some computer science experience in the past, this was my first time participating in a hackathon and contributing to open source software. It was definitely challenging, but I learned so much and I'm grateful for the opportunities to become a better programmer! I look forward to continue contributing to open-source software and to learning new skills!

I mainly worked on an open source badge generator:
https://tharvid.github.io/Open-Source-Badge-Generator/


<!-- Overall, how has your Hacktoberfest 2020 experience been? If you’re a first-timer, will you participate again? What have you learned? Have you made any interesting connections? What is your next step in open source?  -->
Overall, I had an amazing time at Hacktoberfest 2020! I will definitely be back for round 2 next year! In the meantime, I will work hard to learn more about computer science and continue contributing to open-source projects!
Code Smell 14 - God Objects
Tags: codenewbie, oop, tutorial, development
Published: 2020-11-02 04:05:54

*An object that knows too much or does too much.*

> TL;DR: Don't take too many responsibilities.

# Problems

- Cohesion

- Coupling

{% post https://dev.to/mcsee/coupling-the-one-and-only-software-design-problem-2pd7 %}

# Solutions

- Split responsibilities.
- Follow Single Responsibility Principle.
- Follow [The Boy Scout Rule](https://medium.com/@biratkirat/step-8-the-boy-scout-rule-robert-c-martin-uncle-bob-9ac839778385).

# Examples

- Libraries

# Exceptions

- [Facades](https://en.wikipedia.org/wiki/Facade_pattern)

# Sample Code

## Wrong

[Gist Url]: # (https://gist.github.com/mcsee/9e31898b70c00fcb2d71d6d9a47be02d)
```javascript
class Soldier {
   run(){}
   fight(){}
   driveGeneral(){}
   clean() {} 
   fire() {} 
   bePromoted() {}
   serialize() {}
   display() {} 
   persistOnDatabase() {}
   toXML() {}
   jsonDecode(){}
  
  //...     
  }
```

## Right

[Gist Url]: # (https://gist.github.com/mcsee/93818a16a693b7371c8a81670ef522e5)
```javascript
class Soldier {
   run() {}
   fight() {}
   clean() {}    
  }

```

# Detection

Linters can count methods and warn against a threshold.

# Tags

- Cohesive

# Conclusion

Libraries were fine in the 60. In Object-Oriented Programming, we will distribute responsibilities among many objects.

# Also Known as

- Large Class

# Relations

- {% post https://dev.to/mcsee/code-smell-34-too-many-attributes-584p %}

# More info

- [Wikipedia](https://en.wikipedia.org/wiki/God_object)
- [Refactoring Guru](https://refactoring.guru/es/smells/large-class)
- [Coupling](https://dev.to/mcsee/coupling-the-one-and-only-software-design-problem-2pd7)

# Credits

Photo by <a href="https://unsplash.com/@tank_ghisletti">Francisco Ghisletti</a> on <a href="https://unsplash.com/s/photos/greek-god-statue">Unsplash</a>

* * *

This article is part of the CodeSmell Series.

{% post https://dev.to/mcsee/how-to-find-the-stinky-parts-of-your-code-1dbc %}

*Last update: 2021/06/21*
How to flip array keys and values in the code editor?
Tags: php, phpstorm, tips, regex
Published: 2020-11-02 04:04:43

---
title: How to flip array keys and values in the code editor?
published: true
description: 
tags: PHP, PhpStorm, tips, regex
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/7rtbyc7puwv6s9y28sly.png
---

Easy, with regex search!
 - Press Ctrl+R for show replace bar
 - Enable regex mode (button looks like .* near search field)
 - Use regex in search field: `'(.+)'\s=>\s'(.+)',`
 - Use expression for replace: `'$2' => '$1',`

You can see a tooltip with a value that will be after replace

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/7zbpp95oup0v6tni9e50.png)


It is possible even you have different quotes and spaces between arrow

Use regex
`(?:'|")(.+)(?:'|")\s{0,}=>\s{0,}(?:'|")(.+)(?:'|"),`

And the same replace expression `'$2' => '$1',`

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/tasb4nnmh3eabzlpipa1.png)

Named capture groups also available:

Use regex
`(?:'|")(?<src>.+)(?:'|")\s{0,}=>\s{0,}(?:'|")(?<tgt>.+)(?:'|"),`

And the same replace expression `'${tgt}' => '${src}',`
The Red Flag of Client for Freelancer
Tags: discuss
Published: 2020-11-02 04:02:24

---
title: The Red Flag of Client for Freelancer
published: true
tags: discuss
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/g0e1fuiiald6llluowd5.jpg
---
Share the red flag when you identify the bad client that we should avoid.
RT-Thread OpenSource Developer Contest is On!
Published: 2020-11-02 03:57:55

“Great things in open-source are never done by one person. They’re done by a group of people.” OpenSource [**RT-Thread IoT OS**](https://www.rt-thread.io/) teams up with [**Programming For Beginners**](https://www.facebook.com/groups/ProgrammingForBeginners) to hold a developer event, we are looking for developers who have ambitions, and excitement for open-source project. Share Your Creative Ideas with RT-Thread Open-Source Internet of Things IoT Operating System!

**The Efforts You Make Will Have Great Effects!**

##**Join the developer event**

- Write down the projects you want to achieve with RT-Thread and the Dev Board you need by filling in this [**Application Form**](https://forms.gle/77ycGnkavNHaxRkc8). Opening on Nov.1 to Nov.8.

- Nov.9-Nov.11, we will choose the six most fitting projects submitted (if there are a large number of applicants, we’ll open more seats), and **RT-Thread will buy them the dev board required to do the projects.** Yes, we’ll buy you the board you need for your project, and you can keep it! …

- From Nov.12, we'll send out the dev board, when you received the board, you can start creating the project. By the time, we'll ask you to join the RT-Thread international community, the RT-Thread software engineer team will support this event by giving the technical consultant and guidance. 

- Applicants need to submit the project before Dec.15. The code and documentation related to your projects should be public and open source(on GitHub). 

- RT-Thread Reviewing: Dec 16 to Dec.20 2020.

- Winners Awards: Dec 21, 2020.

##**Prizes:** ( All the participants can join RT-Thread First International Developer Community ):

**Grand Prize(1):** RT-Thread Art-Pi Dev Board World Debut+ RT-Thread & ProgrammingForBeginners Customized Backpack.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/sn1hfj6cwor9g560anq2.jpg)

**First Prize(2):** RT-Thread & ProgrammingForBeginners Customized Backpack.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/y7y25n7lgjdkb6zu6iny.png)

**Second Prize(3):** RT-Thread & ProgrammingForBeginners Customized Hoodie.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ktjblcqnaws4o2bwk0oh.png)

For more information about this event, please talk to RT-Thread officials on [**Facebook**](https://www.facebook.com/RT-Thread-IoT-OS-110395723808463) and [**Twitter**](https://twitter.com/rt_thread).
What are your favorite Developer Jokes?
Tags: jokes, devops, productivity, development
Published: 2020-11-02 03:54:03

I've just found one in a project I was looking at, and the License for this project was the [WTFPL](http://www.wtfpl.net/) or "DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE" for short. :)

What are your favorite Developer jokes? They don't have to be licenses, they can also be your favorite [xkcd comics](https://xkcd.com/)! Whatever makes you laugh or gets you through the day :)
LAZY_LISTENER.exe
Tags: python, showdev, opensource
Published: 2020-11-02 03:50:24

Hello everyone : )

I know many of us are bored to read text files sometimes.

Here, is a solution (_LAZY_LISTENER_.exe)for that who wants to listen to the text files both on local machines and maybe online, also stores your last listened file as mp3.
{% github grpnpraveen/Lazy_Listener %}
The Month of October 2020
Tags: opensource
Published: 2020-11-02 03:31:53

## The Intro
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/iy5tzpz096q9iea256if.png)
This, month I have a had ups and downs with the first being me successful completing 4 pull requests for Hacktoberfest. But I am not exactly proud of all my contribution 2 of them were for school purposes and the other 2 that I did were fairly minor in that I wrote very minimal code. This blog will be me going over The other 2 pull requests  that were minor and why it was difficult to work on larger pull requests.

## The Contributions
![](https://images.unsplash.com/photo-1494386346843-e12284507169?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=700&q=80)
I did two prs that actually matters the 1st one was the one I wrote a blog about in the first week of October https://dev.to/zg3d/first-week-of-hacktoberfest-596e. This was a great pr to get started on and I enjoyed with working with something I was comfortable with. The last pull request was my first pull request on telescope https://dev.to/zg3d/telescope-my-first-contribution-19en. This was a good intro to the telescope project but the problem was I did this pull request in the last week of October. Those were my contributions that mattered.

## The Problem 
![](https://images.unsplash.com/photo-1552345386-6690de5b2c09?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1050&q=80)
So, The biggest problem I made was me giving my self enough time to finish more pull requests and the other problem was me being to sacred to get involved in bigger issue like I learned from telescope just setting up the dev environment helps with getting involved in a project. I should have just picked a project I like earlier and set it up on my local machine. I did not, instead I  spent hours and days scrolling through GitHub finding the perfect issue I could contribute to. But, I would just never find anything that felt comfortable so I would just look more and that ended with the month ending and me not finding anything that felt like a great contribution and was not a few lines of code.

## The Plan
![](https://images.unsplash.com/4/madebyvadim.jpg?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1049&q=80)
November is a new month and I plan to contribute more to telescope but I also want to finish the 2 pull requests I did not this month and contribute to something more than a few lines of code. This will require better time management and more just going for it and setting up the dev environment for a project that seems interesting. The time cost of getting the dev environment is a better investment then scrolling through issues on GitHub. It a much more hands on experience and I am learning something wile setting up dev environments instead of scrolling through GitHub.
Sneak peak: neoan3 v3
Tags: webdev, neoan3, news
Published: 2020-11-02 03:30:40

tldr; give it a spin: [youtube](https://www.youtube.com/playlist?list=PL5JRD-ivYK3H7oXS6Mc1y6AAyxjH94lf7)

## What is neoan3?

A PHP framework for 2021? With PHP8, the language is not your father's hypertext preprocessor anymore. Instead, the fastest interpreted language has learned many concepts from other languages over the years. However, the Wordpress dominance still results in a lot of "ugly" code and unbeknownst to us westerners, there seems to be a pop culture phenomenon in India that outputs waves of bad-example YouTube videos.  
But what about Laravel? The defacto standard in modern PHP web development has a well established community, an abundance in resources and tutorials and countless maintainers. Isn't that good enough? Well, yes and no. Laravel is a powerful solution for many use cases. Here is what it isn't:
It doesn't shine in three important categories. It's not easy/fast to learn, unless you use the work of others, development speed isn't great and benchmarks aren't impressive either. As a matter of fact, it's relatively slow. 
***neoan3*** wants to tackle all these issues while making use of a modern, convenient ecosystem.

## What has happened since version 2?

We have moved the neoan3 project to it's own GitHub organization and focused heavily on testability. The result is a decoupled framework that can almost write it's own tests, it is ready for continuous integration, mocking and easy dependency injection. But that's just the candy for industry deployment. For the coder, neoan3 will be the fastest way to develop secure, stable and high performance backends or SSR apps. CRUD basically comes out of the box without limiting you in any way.

## Why should I care?

Diving into new technology is always odd, isn't it? Sometimes we have heard a particular tech just one too many times so we decide to give it a spin. Other times, we are being presented with an opportunity and noticed we failed to explore the technology now needed. And sometimes we just stumble upon the very first solution that seems to fit our needs. 
So the question is: will you give it 5 minutes? We believe that it will take 5 minutes to get you interested, another five to see the potential, another 5 to start to understand and then another 5 to make you decide to build something amazing with it.

Don't want to wait until November 5th? Dive right in: neoan3 basics: https://www.youtube.com/playlist?list=PL5JRD-ivYK3H7oXS6Mc1y6AAyxjH94lf7
Starting to blog again
Tags: beginners, career
Published: 2020-11-02 03:27:28

Hi, my name is Joseph. I have been job hunting for a couple of months now after finishing my coding Bootcamp, and I can't say it has been easy. There are many days where I don't feel motivated to program and flat out depressed at all the rejection letters I get. If you're in the same situation as me, keep trying! Find something that will motivate you to program.

Let's get into the reason for my title. Yesterday, I came across a podcast by FreeCodeCamp. They did an episode on Shawn Wang aka. SWYX. I've been in the ReactJs subreddit for a long time so I've seen him a lot while browsing the subreddit. He is a self-taught developer who made the transition from the world of finance to software development at the age of 30.

Here's the episode if you want to listen to it. [Podcast: Leaving a $350K/year job to learn coding - Shawn Wang interview.](https://www.freecodecamp.org/news/shawn-wang-podcast-interview/) Be warned that it's kind of long (2hours). 

The main talking points that I got from the episode were, he encourages others to do "No Zero Days" and "Learn in Public". 

### No Zero Days
What do those mean? "No Zero Days", is what I think of as doing something that will bring you one step closer to the developer you dream to be. This could be something simple like writing down a todo list of all the features you want in your project you're currently working on. Do something every day and you will be surprised at what you can accomplish. Just have something to get the ball rolling, because once it starts rolling it will be hard to stop!

### Learn in Public
"Learn in Public", is just as it sounds. Most of us, me included don't blog, don't tweet, don't answer/ask questions on StackOverflow, don't participate in Reddit discussions. Let's say for example that you blog about something that you have learned recently. Others may take notice and thank you for your valuable insight. Maybe, no one reads your post, that's fine! If no one reads your post you can have something to refer back to when you forget something. Who knows you may have a React problem and the React genius himself Dan Abramov might come by to give you some help. You might be asking yourself, "what if I'm wrong?". That's okay! Shawn talks about how if you put in the effort and try to output good content, even if your wrong people will chime in to correct you. 

As the last point, if anything blog, create youtube videos, tweet, create a cheat sheet for yourself.

Thank you for reading! I'll be sure to practice Learn in Public when I can. Let me know in the comments if you've seen this episode or what are your thoughts on Learn in Public?



## Resources
- [How to get started with Learn in Public](https://gist.github.com/sw-yx/9720bd4a30606ca3ffb8d407113c0fe5)
Software Engineering - Why?
Published: 2020-11-02 03:14:57

2015 - I was a Business Management major in undergrad and was still undecided on a minor - Spanish or Computer Science. Following the advice of those around me, I pursued a minor in the former. 
2017 - I landed a Marketing Internship with a private equity firm. My role evolved into a graphic design intern, as time passed but it brought me back to a technical, more computer related mindset. But I still wasn't pursuing it full time. 
2020 - I spoke with a close friend of mine who made a career pivot from pre-med biology to IT, by way of a software engineer bootcamp and he has not looked back since. That motivated me to finally pursue it fully myself, so I applied for Flatiron School and here I am. 

Along the way, I've also learned this career move will provide me the opportunity to continue diversifying the tech industry. I'm both anxious and excited to use my career experience to engage with & encourage younger people (alike and different).


That's my why.