Skip to content

Instantly share code, notes, and snippets.

View mysticBliss's full-sized avatar
🏠
Working from home

myticBliss mysticBliss

🏠
Working from home
View GitHub Profile
@mysticBliss
mysticBliss / Understanding Linear Regression.md
Last active July 31, 2017 07:07
Linear Regression - Understanding

Question: Why do we use gradient descent in linear regression?

From https://stackoverflow.com/questions/26804656/why-do-we-use-gradient-descent-in-linear-regression

In some machine learning classes I took recently, I've covered gradient descent to find the best fit line for linear regression.

In some statistics classes, I have learnt that we can compute this line using statistic analysis, using the mean and standard deviation - this page covers this approach in detail [http://onlinestatbook.com/2/regression/intro.html]. Why is this seemingly more simple technique not used in machine learning?

My question is, is gradient descent the preferred method for fitting linear models? If so, why? Or did the professor simply use gradient descent in a simpler setting to introduce the class to the technique?

Intro to Advanced Python

By Adam Anderson

adam.b.anderson.96@gmail.com

These notes are mostly just summaries of the provided references. The purpose of this document is to centralize the resources I found useful so they would be easy to find. Most definitions and explanations are paraphrased or quoted directly from the sources.

Table of Contents

@mysticBliss
mysticBliss / pkl_to_json.py
Created November 27, 2017 07:29 — forked from hailiang-wang/pkl_to_json.py
Convert python pickle file to json
#!/usr/local/bin/python3
'''
Convert a pkl file into json file
'''
import sys
import os
import _pickle as pickle
import json
@mysticBliss
mysticBliss / Introduction to Python.ipynb
Created November 27, 2017 07:31 — forked from fonnesbeck/Introduction to Python.ipynb
python/Introduction to Python.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# Given a two dictionaries empdesig and empdet containing details about employees and managers in a key value pair - print a hierarchical tree
# empdesig = {'Simha': 'Khan', 'Khan': '', 'Vijay': 'Simha', 'Sai': 'Khan', 'Kiran': 'Kiran'}
# empdet = {'Simha': 'Khan', 'Khan': '', 'Vijay': 'Simha', 'Sai': 'Khan', 'Kiran': 'Kiran'}
# If an employee has manager null(like Khan) or has manager as himself - then they are board members and have no bosses.
for emp,mgr in empdesig.items():
new[emp] = {key:'' for key,value in empdesig.items() if value == emp}
for k,v in new.items():
@mysticBliss
mysticBliss / python-interview-tests
Created November 27, 2017 07:34 — forked from davidlu1001/python-interview-tests
python-interview-tests
http://programmers.stackexchange.com/questions/21917/python-interview-questions
https://github.com/sigmavirus24/python-interview-questions
https://gist.github.com/xiangzhuyuan/7454001522d275021b2d
https://github.com/ContinuumIO/interview-questions
https://github.com/Flowerowl/python_articles
http://marselester.com/preparation-to-python-interview.html
https://github.com/zachwill/cracking-the-coding-interview
http://www.bogotobogo.com/python/python_interview_questions.php
https://www.quora.com/What-are-good-Python-interview-questions
https://www.reddit.com/r/Python/comments/1knw7z/python_interview_questions

Interview Sample Question

    1. why is not all memory free when Python exits?
    1. write the output of below code:
   var1 = lambda q: q * 5
   var2 = lambda q: q * 3
   x = 2
   x = var1(x)
   x = var1(x)
   x = var1(x)
@mysticBliss
mysticBliss / tech-interview-guide.md
Created November 27, 2017 07:39 — forked from vicyap/tech-interview-guide.md
tech interview guide

A quick guide on getting ready for tech interviews.

Chitchat like a pro.

Before diving into code, most interviewers like to chitchat about your background. They're looking for:

  • Metacognition about coding. Do you think about how to code well?
  • Ownership/leadership. Do you see your work through to completion? Do you fix things that aren't quite right, even if you don't have to?
  • Communication. Nerd out about stuff. Show you're proud of what you've done, you're amped about what they're doing, and you have opinions about languages and workflows.
  • STAR (Situation, Task, Action, Result). It’s good to have a project in your back pocket that you can talk about in a direct and concise way.

Coding Question

Explain all the file processing modes supported by Python ?

Python allows you to open files in one of the three modes. They are: read-only mode, write-only mode, read-write mode, and append mode by specifying the flags r, w, rw, a respectively.

A text file can be opened in any one of the above said modes by specifying the option t along with r, w, rw, and a, so that the preceding modes become rt, wt, rwt, and at.

A binary file can be opened in any one of the above said modes by specifying the option b along with r, w, rw, and a so that the preceding modes become rb, wb, rwb, ab.

@mysticBliss
mysticBliss / Generator.md
Last active February 2, 2018 06:33
Generator

Generator(s): python

Yield result one by one!

Generators are used to create iterators, but with a different approach. Generators are simple functions which return an iterable set of items, one at a time, in a special way.

When an iteration over a set of item starts using the for statement, the generator is run. Once the generator's function code reaches a "yield" statement, the generator yields its execution back to the for loop, returning a new value from the set. The generator function can generate as many values (possibly infinite) as it wants, yielding each one in its turn.

Fibonacci series

def fib():