Five NumPy Functions a beginner should know about๐Ÿ๐ŸŒŸ

1โƒฃ ๐—ป๐—ฝ.๐—ฎ๐—ฟ๐—ฟ๐—ฎ๐˜†

In Numpy, we create arrays using the "array" function.

Numpy gives the power to create multi-dimensional arrays.

๐Ÿ”— Code
2โƒฃ ๐—ป๐—ฝ.๐˜€๐—ต๐—ฎ๐—ฝ๐—ฒ

The shape of an array is the number of elements in each dimension.

NumPy arrays have an attribute called shape that returns a tuple with each index having the number of corresponding elements.

๐Ÿ”— Code
3โƒฃ ๐—ป๐—ฝ.๐—ฟ๐—ฒ๐˜€๐—ต๐—ฎ๐—ฝ๐—ฒ

reshape is used to change the shape of the NumPy array without changing the elements of the array.

reshape is one the best function of NumPy, it helps a lot in calculations.

๐Ÿ”— Code
4โƒฃ ๐—ป๐—ฝ.๐—ฎ๐—ฟ๐—ผ๐˜‚๐—ป๐—ฑ

This mathematical function helps the user to evenly round array elements to given number of decimals

numpy.around(arr, decimals = 0, out = None)

decimal : [int, optional] Decimal places we want to round off

out : [optional] Output resulted array

๐Ÿ”— Code
5โƒฃ ๐—ป๐—ฝ.๐˜๐—ฟ๐—ฎ๐—ป๐˜€๐—ฝ๐—ผ๐˜€๐—ฒ

Remember, in your maths class, to find the transpose of a matrix you have to solve long calculations.

In NumPy, it can be done only in a single line using transpose.

It has no effect on a 1-D array!

๐Ÿ”— Code

Thanks for reading the thread โค๏ธ

I post content about Python and Machine learning!!

If you like this thread, give it a retweet :)


โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh

Keep Current with Saurav Jain

Saurav Jain Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!


Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @Sauain

20 Jul

-Want to write an "Eye-pleasing" Python code ๐Ÿ ๐Ÿ‘€?

-PEP is a thing you MUST know about while learning or writing a python code

-Python Enhancement Proposal

-Basically a guide to "๐—›๐—ผ๐˜„ ๐˜๐—ผ ๐˜„๐—ฟ๐—ถ๐˜๐—ฒ ๐—ฎ ๐—ฏ๐—ฒ๐—ฎ๐˜‚๐˜๐—ถ๐—ณ๐˜‚๐—น ๐—ฝ๐˜†๐˜๐—ต๐—ผ๐—ป ๐—ฐ๐—ผ๐—ฑ๐—ฒ?"

BIG Thread ๐Ÿงต๐Ÿ‘‡
We all know that besides having logic and coding in any programming language, there is an important factor that is "coding style"

-How we are writing comments?
-How we are giving spaces?
-How to import libraries?

These things are very important to write a beautiful code!
For Python, PEP 8 has emerged as the style guide that most projects adhere to.

It promotes a very readable and "eye-pleasing" coding style. ๐Ÿ˜

A code which anyone will love to read and is very easily understandable.
Read 12 tweets
19 Jul
๐—ฅ๐—ฒ๐—ถ๐—ป๐—ณ๐—ผ๐—ฟ๐—ฐ๐—ฒ๐—บ๐—ฒ๐—ป๐˜ ๐—น๐—ฒ๐—ฎ๐—ฟ๐—ป๐—ถ๐—ป๐—ด ๐Ÿค–

-A type of Machine Learning (What is it?)
-It's working
-Real-life Applications
-A book for learning RL

Let's learn about all these things in this thread!!

๐—ช๐—ต๐—ฎ๐˜ ๐—ถ๐˜€ ๐—ฅ๐—ฒ๐—ถ๐—ป๐—ณ๐—ผ๐—ฟ๐—ฐ๐—ฒ๐—บ๐—ฒ๐—ป๐˜ ๐—น๐—ฒ๐—ฎ๐—ฟ๐—ป๐—ถ๐—ป๐—ด?

- A machine learning area.

-In RL an ML model is trained to take a sequence of decisions.

-If the model takes a correct decision it will get awarded otherwise negative points will be given.

Perfect Explanation๐Ÿ‘‡

Environment: Physical world in which the agent operates

State: Current situation of the agent

Reward: Feedback from the env.

Policy: Method to map agentโ€™s state to actions

Value: Future reward that an agent would receive by taking an action in particular state
Read 9 tweets
14 Jul
๐—›๐—ฎ๐—ฎ๐—ฟ ๐—–๐—ฎ๐˜€๐—ฐ๐—ฎ๐—ฑ๐—ฒ๐˜€๐Ÿ‘จโ€๐Ÿ’ป

- Arguably OpenCVโ€™s ( Open source Computer Vision ) most popular object detection algorithm.

-What is it?

A BIG Thread ๐Ÿงต๐Ÿ‘‡
We are living in an era, where object detection is used everywhere.

From security cameras to our mobile phones, it is used everywhere.

Haar classifiers, classifiers were used in the ๐—ณ๐—ถ๐—ฟ๐˜€๐˜ ๐—ฟ๐—ฒ๐—ฎ๐—น-๐˜๐—ถ๐—บ๐—ฒ ๐—ณ๐—ฎ๐—ฐ๐—ฒ ๐—ฑ๐—ฒ๐˜๐—ฒ๐—ฐ๐˜๐—ผ๐—ฟ.
๐—ช๐—ต๐—ฎ๐˜ ๐—ถ๐˜€ ๐—›๐—ฎ๐—ฎ๐—ฟ ๐—–๐—ฎ๐˜€๐—ฐ๐—ฎ๐—ฑ๐—ฒ โ”

Haar Cascade classifiers are an effective way for object detection.

This method was proposed by Paul Viola and Michael Jones in their paper Rapid Object Detection using a Boosted Cascade of Simple Features.
Read 13 tweets
13 Jul
Learn Python while playing games ๐ŸŽฏ

Five Ideas to make a game using Python๐Ÿ

1โƒฃ Dice Roller

Have no dice for your ludo game?

No worries you can create one using Python in just a few minutes.

Just use a random library and make one for yourself๐Ÿ˜‰
2โƒฃ Hangman

You can make this game in Python too ;)

The word to guess is represented by a row of dashes.

If the player guesses a letter that exists in the word, the script writes it in all its correct positions. The player has 10 turns to guess the word.
Read 7 tweets
12 Jul
Seven Python Math Library Functions ๐Ÿงฎ ๐Ÿ

A beginner should know about these important functions, it will make your work easy!!

Thread ๐Ÿ˜๐Ÿงต Image
1โƒฃ ๐˜€๐—พ๐—ฟ๐˜

In python, to find the square root of any number ( 3 is the square root of 9 ) you don't have to use power operator.

There is a special function " sqrt " which square roots the number given it as a parameter :)

๐Ÿ”— Code Image
2โƒฃ ๐—ฝ๐—ผ๐˜„

In the above tweet, we have learned how to square root a given number.

A square root is actually a number raised to a power of 0.5

But what if we want 3 or something as power.

Here we use " pow(x,y) " it returns x raised to power y.

๐Ÿ”— Code Image
Read 9 tweets
10 Jul
Five Python Libraries for Machine Learning ๐Ÿ

Thread ๐Ÿงต๐Ÿ‘‡
1โƒฃ ๐—ง๐—ฒ๐—ป๐˜€๐—ผ๐—ฟ๐—™๐—น๐—ผ๐˜„

It is an open-source library created by the Google Brain team.

It is very popular for high-performance numerical computation.

It has an ecosystem of tools, libraries, and community resources for building and deploying powerful ML applications.
2โƒฃ ๐—ž๐—ฒ๐—ฟ๐—ฎ๐˜€

Keras is a deep learning API written in Python, running on top of the machine learning platform TensorFlow.

It is a high-level neural networks API capable of running on top of TensorFlow, CNTK, or Theano.

It can run seamlessly on both CPU and GPU.
Read 7 tweets

Did Thread Reader help you today?

Support us! We are indie developers!

This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!