useful link for CSS style colors: http://web.simmons.edu/~grabiner/comm244/weekthree/css-colors.html

 

Task on open-ended visualisation

http://ml-india.org/datasets/

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

!pip install chart_studio

import numpy as np
import pandas as pd
import cufflinks as cf

 

from plotly.offline import download_plotlyjs, init_notebook_mode, iplot, plot

cf.go_offline()
%matplotlib inline
init_notebook_mode(connected = True)

 

df = pd.DataFrame(np.random.randn(100, 4), columns='a b c d'.split())
df2 = pd.DataFrame({"Category":["one", "two", "three", "four", "five"], "Count":[10,20,30,20,10]})

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Call this function when ever a plotly graph is to be displayed

 

def configure_plotly_browser_state():
   import IPython
  display(IPython.core.display.HTML('''
        <script src="/static/components/requirejs/require.js"></script>
        <script>
          requirejs.config({
            paths: {
              base: '/static/base',
              plotly: 'https://cdn.plot.ly/plotly-1.5.1.min.js?noext',
            },
          });
        </script>
        '''))

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
How to plot a graph from the outcome of the Linear Regression or Logistic Regression

 

plt.scatter(x_test, y_test, color = "red")
plt.plot(x_train, lr.predict(x_train), color = "green")
plt.title("Salary vs Experience (Testing set)")
plt.xlabel("Years of Experience")
plt.ylabel("Salary")
plt.show()

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Convert IPYNB file in google colab to html file

!pip install nbconvert
%shell jupyter nbconvert --to html /content/testfile.ipynb

 

Also pass the --execute flag to generate the output cells

jupyter nbconvert --execute --to html notebook.ipynb jupyter nbconvert --execute --to pdf notebook.ipynb

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

procedure:
1. upload the file into the file location in colab
2. execute the above command
3. find the converted html file in the same location.

link on StackOverFlow:
https://stackoverflow.com/questions/53460051/convert-ipynb-notebook-to-html-in-google-colab

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To place annotations - values on bars

#for p in ax.patches:

# ax.annotate(np.round(p.get_width(), decimals = 2), (p.get_y() * 1.05, p.get_width() * 1.05))

 

for i in ax.patches:

plt.text(i.get_width(), i.get_y()+.05, str(round((i.get_width()), 2)), fontsize = 10, fontweight ='bold', color ='grey')

BASIC CODE HELP
for my reference
Lambda
In [ ]:
# method that returns a value
def add(a, b):
    return a + b

add(2,3)
Out[ ]:
5
In [ ]:
x = lambda c, d: c + d
x(2, 3)
Out[ ]:
5
In [ ]:
# method that doesnt return any value
def sum(a, b):
    print(a + b)

sum(4,4)
8
In [ ]:
x = lambda y: y**2
x (4)
Out[ ]:
16
In [ ]:
a = lambda c, d: c ** d
a(3,4)
Out[ ]:
81
In [ ]: