Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 135 additions & 0 deletions docs/ClassPerson.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"id": "3e860c77-1efe-4bc5-a4dd-f6dda52f49d9",
"metadata": {},
"outputs": [],
"source": [
"class Person:\n",
" def __init__(self, givenName, givenColor, givenWeight):\n",
" self.name = givenName\n",
" self.color = givenColor\n",
" self.weight = givenWeight\n",
" def introduce_yourself(self):\n",
" print(\"My name is \" + self.name)\n",
" def sit_down(self):\n",
" self.isSitting = true\n",
" def stand_up(self):\n",
" sel.isSitting = false"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "59231686-ea98-4d80-9e56-e2cdf79a264f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"My name is Mateo\n"
]
}
],
"source": [
"mateo = Person(\"Mateo\", \"white\", 65)\n",
"mateo.introduce_yourself()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "6781ce28-7295-4c58-ae5d-6980580a1e11",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"int"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(5)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "2366135b-11af-4faf-9960-d90ada0d6d3f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"bool"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(True)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "8b625d8c-5f0e-46e0-9401-30dbff8158e8",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"A is greater than b\n"
]
}
],
"source": [
"a = 3\n",
"b = 1\n",
"if(a>b):\n",
" print(\"A is greater than b\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d1464218-f3ae-42ab-84f3-c4151e86ea4b",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
8 changes: 8 additions & 0 deletions docs/jupyter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
step by step basic command for jupyter lab
1. Install jupyter:
- pip install jupyterlab
- jupyter lab

2. Install jupyter notebook
- pip install notebook
- jupyter notebook
Binary file added requirements.txt
Binary file not shown.
44 changes: 44 additions & 0 deletions src/mateo/collections.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Named tuple example
from collections import namedtuple
Point = namedtuple('Point', ['x', 'y'])
p = Point(100, 100)
print(f"Point coordinates: ({p.x}, {p.y})")

# Dataclasses example

from dataclasses import dataclass

@dataclass
class PointData:
x: int
y: int
p_data = PointData(200, 200)
print(f"PointData coordinates: ({p_data.x}, {p_data.y})")

# Ordered dict example
from collections import OrderedDict

od = OrderedDict()
od['first'] = 1
od['second'] = 2
od['third'] = 3

for key, value in od.items():
print(f"{key}: {value}")

# Default dict example
from collections import defaultdict
dd = defaultdict(list)
dd['a'].append(1)
dd['b'].append(2)
dd['a'].append(3)
for key, value in dd.items():
print(f"{key}: {value}")

# Deque example
from collections import deque
dq = deque(['a', 'b', 'c'])
dq.append('d')
dq.appendleft('z')
print(f"Deque contents: {list(dq)}")

22 changes: 22 additions & 0 deletions src/mateo/gaussian_distribution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import numpy as np
from scipy.cluster.vq import kmeans, whiten
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(style="whitegrid")

pts = 10
rands = np.random.randint(0, 100, (10, 2))
# Generate two clusters of points
print(rands)
a = np.random.multivariate_normal([0, 0], [[1, 0], [0, 1]], pts)
b = np.random.multivariate_normal([5, 5], [[1, 0], [0, 1]], pts)

features = np.concatenate((a, b), axis=0)

whitened_features = whiten(features)

codebook = kmeans(whitened_features, 2)

plt.scatter(features[:, 0], features[:, 1], c='blue', label='Data Points')
plt.scatter(codebook[0][:, 0], codebook[0][:, 1], c='red', marker='x', s=100, label='Centroids')
plt.show()
21 changes: 21 additions & 0 deletions src/mateo/kent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
numbers = [None for _ in range(5)]
print(numbers)

CASHE_SIZE = 16
_cache = [None for _ in range(CASHE_SIZE)]
print(_cache)

rows, cols = 5, 5
grid = [['x' for _ in range(cols)] for _ in range(rows)]
print(grid)

for row in range(rows):
temp_row = []
for col in range(cols):
temp_row.append('o' if col > row else 'x')
grid.append(temp_row)
print(grid)


# dictionary comprehension

16 changes: 16 additions & 0 deletions src/mateo/linear_regression.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import numpy as np
from sklearn.linear_model import LinearRegression

x = np.array([5, 15, 25, 35, 45, 55]).reshape(-1, 1)
y = np.array([5, 20, 14, 32, 22, 38])
model = LinearRegression()

model.fit(x, y)
predictions = model.predict(x)

r_squared = model.score(x, y)

print(f"Coefficients: {r_squared}")

y_pred = model.predict(x)
print(f"Predictions: {y_pred}")
29 changes: 29 additions & 0 deletions src/mateo/unionfind.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class UnionFind:
def __init__(self, n):
self.parent = [i for i in range(n)]
self.rank = [0] * n
def find(self, x):
if(self.parent[x] != x):
self.parent[x] = self.find(self.parent[x])
return self.parent[x]
def union(self, x, y):
root_x = self.find(x)
root_y = self.find(y)
if(root_x == root_y):
return False
if root_x != root_y:
if self.rank[root_x] > self.rank[root_y]:
self.parent[root_y] = root_x
elif self.rank[root_x] < self.rank[root_y]:
self.parent[root_x] = root_y
else:
self.parent[root_y] = root_x
self.rank[root_x] += 1
return True
u = UnionFind(10)

print(u.union(1, 2)) # True
print(u.union(2, 3)) # True
print(u.union(1, 3)) # False
print(u.find(1))
print(u.find(2))