This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyrealsense2 as rs | |
pipeline = rs.pipeline() | |
profile = pipeline.start() | |
align = rs.align(rs.stream.color) | |
all_color_frames = [] | |
all_depth_frames = [] | |
for i in range(20): | |
print(i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import typing | |
from pyspark.sql import DataFrame | |
T = typing.TypeVar("T", bound="DynamicDataFrame") | |
class DynamicDataFrame(DataFrame): | |
def __init__(self, df: DataFrame): | |
super().__init__(df._jdf, df.sql_ctx) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from sklearn.feature_selection import SelectKBest | |
from sklearn.linear_model import LogisticRegression | |
from sklearn.metrics import accuracy_score | |
from sklearn.pipeline import Pipeline | |
dataset = pd.read_csv("iris.csv") | |
features = dataset[["s-l", "s-w", "p-l", "p-w"]] | |
target = dataset["variety"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import... | |
dataset = pd.read_csv("iris.csv") | |
features = dataset[["s-l", "s-w", "p-l", "p-w"]] | |
target = dataset["variety"] | |
classifier = Pipeline(steps=[("select", SelectKBest(k=2)), | |
("clf", LogisticRegression())]) | |
classifier.fit(features, target) | |
with open("model.pkl", "wb") as model_file: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import... | |
dataset = pd.read_csv("unseen_iris.csv") | |
features = dataset[["s-l", "s-w", "p-l", "p-w"]] | |
target = dataset["variety"] | |
with open("model.pkl", "rb") as model_file: | |
classifier = pickle.load(model_file) | |
score = accuracy_score(target, classifier.predict(features)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pickle | |
def load_model(filename): | |
with open(filename, "rb") as model_file: | |
classifier = pickle.load(model_file) | |
return classifier | |
def save_model(classifier, filename): | |
with open(filename, "wb") as model_file: | |
pickle.dump(classifier, model_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
save_model(classifier, "model.pkl") | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
classifier = load_model("model.pkl") | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#file: train.py | |
... | |
classifier = Pipeline(steps=[("select", SelectKBest(k=2)), | |
("clf", LogisticRegression())]) | |
classifier.fit(features, target) | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
classifier = fit_model(features, target) | |
save_model(classifier, "model.pkl") | |
... |
OlderNewer