Skip to content

Instantly share code, notes, and snippets.

x_1 x_2 y
0 -0.759415996185977 2.7532400952557747 0
1 -1.8852779019387766 1.6295265391438516 0
2 2.46330243466849 -1.023868884412727 0
3 -1.9860041519965943 -0.8988097871506215 0
4 2.0108340318241424 -2.58011744859958 0
5 2.4101875198381917 2.370500867155556 0
6 1.5991400471635622 -0.8627316166103238 0
7 -1.109856441968584 -2.4696974604953335 0
8 2.447341902744885 2.8111799446840005 0
@sithu
sithu / svm.py
Last active April 6, 2022 00:56
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# https://gist.github.com/sithu/4722649d23c83440f2067ed429fa434b
import utils
from sklearn.svm import SVC
# Loading the linear dataset
# linear.csv: https://gist.github.com/sithu/701d1182d63b01e740bb244d8059ceb1
linear_data = pd.read_csv('linear.csv')
x_1 x_2 y
0 -2.9215421587612864 -2.9240927587498557 0
1 0.1367823452479766 0.5404018260196919 1
2 2.7472957442884027 1.547236841959032 1
3 -2.780707006283153 -2.673130701821511 0
4 2.0304211973846185 1.3294522550124075 1
5 -0.314170015192591 -2.591670461555064 0
6 -1.8962190518539415 -0.5169526296813127 0
7 1.4321480571961844 0.8410803230124659 1
8 0.8859891385888985 2.4247415377997505 1
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
learning_rate = 0.01
training_epochs = 1000
num_labels = 3
batch_size = 100
x1_label0 = np.random.normal(1, 1, (100, 1))
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
learning_rate = 0.1
training_epochs = 2000
def sigmoid(x):
return 1. / (1. + np.exp(-x))
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
learning_rate = 0.01
training_epochs = 1000
x1 = np.random.normal(-4, 2, 1000)
x2 = np.random.normal(4, 2, 1000)
xs = np.append(x1, x2)
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
# 1-dimensional values.
# Numbers close to 5 will be given the label [0], and
# Numbers close to 2 will be given the label [1].
x_label0 = np.random.normal(5, 1, 10)
# outliers:
import math
size = 5
# ( 1 + (1/1!) + (1/2!) + (1/3!) + (1/4!) + (1/5!) + ......... + 1/i! )
_list = [(1 / math.factorial(i)) for i in range(size)]
e = sum(_list)
print(f"e={e}")
import sys
# Prompt the user to enter the number of students
numOfStudents = sys.stdin.readline()
print("number of students = " + numOfStudents)
maxScore = 0
topStudent = None
for i in range(int(numOfStudents)):
line = sys.stdin.readline()
@sithu
sithu / python_tests_dir_structure.md
Created March 18, 2020 04:49 — forked from tasdikrahman/python_tests_dir_structure.md
Typical Directory structure for python tests

A Typical directory structure for running tests using unittest

Ref : stackoverflow

The best solution in my opinion is to use the unittest [command line interface][1] which will add the directory to the sys.path so you don't have to (done in the TestLoader class).

For example for a directory structure like this:

new_project

├── antigravity.py