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
from typing import List, Dict, Tuple | |
x: int = 10 | |
y: float = 0.8 | |
string: str = 'I am a string' | |
hash_map: Dict[str, int] = {} | |
List1: List[int] = [] | |
my_tuple: Tuple[str, int] = () | |
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 numpy as np | |
import pandas as pd | |
from sklearn.datasets import make_blobs | |
from sklearn.base import BaseEstimator, TransformerMixin | |
from sklearn.preprocessing import StandardScaler | |
from sklearn.pipeline import Pipeline | |
from sklearn.linear_model import LogisticRegression | |
class CustomImputer(BaseEstimator, TransformerMixin): |
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 numpy as np | |
import pandas as pd | |
from typing import Dict, List | |
from sklearn.datasets import make_blobs | |
from sklearn.base import BaseEstimator, TransformerMixin | |
from sklearn.preprocessing import StandardScaler | |
from sklearn.pipeline import Pipeline | |
from sklearn.linear_model import LogisticRegression | |
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 apache_beam as beam | |
from apache_beam.options.pipeline_options import PipelineOptions | |
from google.cloud import bigquery | |
import re | |
import logging | |
import sys | |
PROJECT='user-logs-237110' | |
schema = 'remote_addr:STRING, timelocal:STRING, request_type:STRING, status:STRING, body_bytes_sent:STRING, http_referer:STRING, http_user_agent:STRING' |
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
from apache_beam.options.pipeline_options import PipelineOptions | |
from google.cloud import pubsub_v1 | |
from google.cloud import bigquery | |
import apache_beam as beam | |
import logging | |
import argparse | |
import sys | |
import re | |
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
from faker import Faker | |
import time | |
import random | |
import os | |
import numpy as np | |
from datetime import datetime, timedelta | |
LINE = """\ |
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
from stream_logs import generate_log_line | |
import logging | |
from google.cloud import pubsub_v1 | |
import random | |
import time | |
PROJECT_ID="user-logs-237110" | |
TOPIC = "userlogs" |
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
def predict(self, X): | |
"""Returns predicted labels using Bayes Rule to | |
Calculate the posterior distribution | |
Parameters: | |
------------- | |
X: N*d numpy array | |
Returns: | |
---------- |
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
def fit(self, X): | |
"""Compute the E-step and M-step and | |
Calculates the lowerbound | |
Parameters: | |
----------- | |
X: (N x d), data | |
Returns: | |
---------- |
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
def _compute_loss_function(self, X, pi, mu, sigma): | |
"""Computes lower bound loss function | |
Parameters: | |
----------- | |
X: (N x d), data | |
Returns: | |
--------- | |
pi: (C) |
NewerOlder