Difference makes the DIFFERENCE
useful link for CSS style colors: http://web.simmons.edu/~grabiner/comm244/weekthree/css-colors.html
Task on open-ended visualisation
!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]})
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>
'''))
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()
!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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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')
for further reference:
link: https://towardsdatascience.com/lambda-functions-with-practical-examples-in-python-45934f3653a8
another link: https://treyhunner.com/2018/09/stop-writing-lambda-expressions/
# method that returns a value
def add(a, b):
return a + b
add(2,3)
x = lambda c, d: c + d
x(2, 3)
# method that doesnt return any value
def sum(a, b):
print(a + b)
sum(4,4)
x = lambda y: y**2
x (4)
a = lambda c, d: c ** d
a(3,4)