Showing posts with label 30daysofml. Show all posts
Showing posts with label 30daysofml. Show all posts

Friday, August 06, 2021

Day 4 of #30daysofML Learning

Below is my learning for Day 4 of #30daysofML

The datatype for boolean in python is 'bool'

Boolean operators are used for comparison

3.0 == 3

'3'== 3

Comparison operators can be combined with the arithmetic operators 

Remember to use == instead of = when making comparisons.

Booleans are most useful when combined with conditional statements like if then else statement

Python has a functions as below:

  • int() function  which turns things into ints, 
  • float() functon which turns things into floats, 
  • bool() function which turns things into bools.
  • Calling bool() on an integer returns False if it’s equal to 0 and True otherwise. 
  • int(True) is 1, and int(False) is 0.

We can use non-boolean objects in if conditions and other places where a boolean would be expected. Python will implicitly treat them as their corresponding boolean value:

Here is the order of precedence of operators in Python


Operator

Description

(expressions...),

[expressions...]{key: value...}{expressions...}

Binding or parenthesized expression, list display, dictionary display, set display

x[index]x[index:index]x(arguments...)x.attribute

Subscription, slicing, call, attribute reference

await x

Await expression

**

Exponentiation 5

+x-x~x

Positive, negative, bitwise NOT

*@///%

Multiplication, matrix multiplication, division, floor division, remainder 6

+-

Addition and subtraction

<<>>

Shifts

&

Bitwise AND

^

Bitwise XOR

|

Bitwise OR

innot inisis not<<=>>=!===

Comparisons, including membership tests and identity tests

not x

Boolean NOT

and

Boolean AND

or

Boolean OR

if – else

Conditional expression

lambda

Lambda expression

:=

Assignment expression


Thursday, August 05, 2021

Day 3 of #30daysofML from Kaggle

Below is my learning for today as part of Day 3 of #30daysofML


help()

help(round)

help(round(-30.18)

help(print)


Defining functions

Builtin functions are great, but we can only get so far with them before we need to start defining our own functions. 

Example if we want to calculate the least difference between 3 numbers

def least_diff (num1, num2, num3):

diff1 =num1-num2

diff2 =num2-num3

diff3 =num3-num1

return min(diff1, diff2, diff3)

Functions start with a header introduced by the def keyword. The indented block of code following the : is run when the function is called.

return is another keyword uniquely associated with functions. When Python encounters a return statement, it exits the function immediately, and passes the value on the right hand side to the calling context.

If there is no return in the function, then the function will not return anything.

But there are some functions with no return statements inside them.  Examples are print() and help()

Python allows trailing commas in argument lists. How nice is that?


Wednesday, August 04, 2021

Day 2 of #30daysofML from Kaggle

 Below is the learning for today as part of the #30daysofML challenge

  • Variable assignment
  • Print function
  • #commenting the code in Python
  • Variable reassignment
  • Writing conditional statements using if

The colon (:) at the end of the if line indicates that a new code block is starting

The * operator can be used to multiply two numbers (3 * 3 evaluates to 9), but we can also multiply a string by a number, to get a version that's been repeated that many times. Python offers a number of cheeky little time-saving tricks like this where operators like * and + have a different meaning depending on what kind of thing they're applied to. 

What is type function used for ?

type(spam_amount)

The // operator gives us a result that's rounded down to the next integer.

print(float(10))

print(int(3.33))

# They can even be called on strings!

print(int('807') + 1)




Tuesday, August 03, 2021

Day 1 of #30daysofML from Kaggle

I signed up for the 30 days of ML challenge organised by Kaggle.  It started today.  

I am so excited to learn Machine Learning as part of this initiative.

The tasks that were completed on Day1 were as below :

  • Created a kaggle profile
  • Used Titanic Datasets to load the train and test datasets
  • Used a Random Forest Algorithm to make predictions for Survival
  • Submitted my first prediction for the competition. 

I am looking forward for Day 2







Power BI Kids competition 2026

 Celebrating the next generation of data rockstars! 🚀✨ I am incredibly proud to share that we have officially wrapped up our 8-week #PowerB...