8000 Machine Learning · premaseem/pythonLab@ce6428d · GitHub
[go: up one dir, main page]

Skip to content

Commit ce6428d

Browse files
Aseem JainAseem Jain
authored andcommitted
Machine Learning
1 parent 3c97d9e commit ce6428d

File tree

4 files changed

+129
-0
lines changed

4 files129

-0
lines changed

MACHINE_LEARNING.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Machine Learning
2+
3+
Machine Learning is making the computer learn from studying data and statistics.
4+
Machine Learning is a step into the direction of artificial intelligence (AI).
5+
Machine Learning is a program that analyses data and learns to predict the outcome.
6+
7+
# Definition
8+
Machine Leaarning enables a functions / program to predict the outcome based on what it have learned for dataset.
9+
10+
# Data Set
11+
In the mind of a computer, a data set is any collection of data. It can be anything from an array to a complete database.
12+
13+
We can split the data types into three main categories:
14+
15+
Numerical - Integers
16+
Categorical - data are values that cannot be measured up against each other. Example: a color value,
17+
Ordinal - data are like categorical data, but can be measured up against each other. Example: school grades where A is better than B and so on.
18+
19+
In Machine Learning (and in mathematics) there are often three values that interests us:
20+
Mean - The average value
21+
Median - The mid point value (after sorting)
22+
Mode - The most common value
23+
24+
speed = [99,86,87,88,111,86,103,87,94,78,77,85,86]

libraries/machine_learning/graph.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""
2+
@Author: Aseem Jain
3+
@Linkedin: https://www.linkedin.com/in/premaseem/
4+
@Github: https://github.com/premaseem/pythonLab/tree/master/challenge
5+
6+
"""
7+
8+
9+
import numpy
10+
import matplotlib.pyplot as plt
11+
numpy.random.seed(2)
12+
13+
x = numpy.random.normal(3, 1, 100)
14+
y = numpy.random.normal(150, 40, 100) / x
15+
16+
train_x = x[:80]
17+
train_y = y[:80]
18+
19+
test_x = x[80:]
20+
test_y = y[80:]
21+
22+
mymodel = numpy.poly1d(numpy.polyfit(train_x, train_y, 3))
23+
24+
myline = numpy.linspace(0, 6, 100)
25+
26+
plt.scatter(train_x, train_y)
27+
plt.plot(myline, mymodel(myline))
28+
plt.show()

libraries/pymongo/mongo_docker.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## Mongo db docker setup
2+
3+
# look existing images in system
4+
docker images | grep mongo
5+
6+
# pull docker image
7+
docker pull mongo
8+
9+
# Create a /mongodata directory on the host system
10+
mkdir -p ~/mongodata
11+
12+
# Start the Docker container with the run command using the mongo image. The /data/db directory in the container is mounted as /mongodata on the host.
13+
docker run -it -v ~/docker/mongodata:/data/db -p 27017:27017 --name mongodb -d mongo
14+
# -it ( run terminal iteractive mode)
15+
# -p 27017:27017 (port mapping)
16+
# -v mongodata:/data/db ( data volume mount)
17+
# --name mongodb ( container name or tag)
18+
# -d run in detached mode / background
19+
20+
# check logs onf container : docker logs <container name>
21+
docker logs mongodb
22+
23+
# connect to docker container bash : docker exec -it <container name> bash
24+
docker exec -it mongodb bash
25+
26+
# list out docker containers
27+
docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Ports}}"
28+
29+
# remove all docker images
30+
#docker image prune -a
31+

libraries/pymongo/run.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"""
2+
@Author: Aseem Jain
3+
@profile: https://www.linkedin.com/in/premaseem/
4+
5+
"""
6+
import pymongo
7+
8+
mongo_client = pymongo.MongoClient("mongodb://localhost:27017/")
9+
10+
print("Show Dbs",mongo_client.list_database_names())
11+
my_db = mongo_client["mydatabase"]
12+
my_col = my_db["customers"]
13+
my_dict = {
14+
"name" : " prem aseem",
15+
"type" : "gold customer"
16+
}
17+
# _id = my_col.insert_one(my_dict)
18+
# print(_id)
19+
20+
print(my_col.find_one())
21+
print(my_col.count_documents({}))
22+
23+
my_records = [
24+
{ "name": "Amy", "address": "Apple st 652"},
25+
{ "name": "Hannah", "address": "Mountain 21"},
26+
{ "name": "Michael", "address": "Valley 345"},
27+
{ "name": "Sandy", "address": "Ocean blvd 2"},
28+
{ "name": "Betty", "address": "Green Grass 1"},
29+
{ "name": "Richard", "address": "Sky st 331"},
30+
{ "name": "Susan", "address": "One way 98"},
31+
{ "name": "Vicky", "address": "Yellow Garden 2"},
32+
{ "name": "Ben", "address": "Park Lane 38"},
33+
{ "name": "William", "address": "Central st 954"},
34+
{ "name": "Chuck", "address": "Main Road 989"},
35+
{ "name": "Viola", "address": "Sideway 1633"}
36+
]
37+
38+
# my_col.insert_many(my_records)
39+
# my_col.insert_one({ "_id": 2, "name": "sony", "address": "Highway 37"})
40+
print(list(my_col.find({"name": {"$regex": "^s"}}).sort("name",-1)))
41+
print(list(my_col.find().sort("name",-1)))
42+
# for x in my_col.find({},{ "name": 1, "address": 0 }):
43+
# print(x)
44+
45+
my_col.update_one({"name":"Sony"},{ "$set" :{"address": "7 cloud heaven"}})
46+
my_col.find_one({"name":"Sony"})

0 commit comments

Comments
 (0)
0