This file contains hidden or 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 json | |
from bs4 import BeautifulSoup | |
def html_to_json(html_file, output_file): | |
with open(html_file, 'r') as f: | |
soup = BeautifulSoup(f, 'lxml') | |
data = {} | |
for tag in soup.find_all(): | |
if not tag.name in data: |
This file contains hidden or 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 tempfile | |
import gradio as gr | |
from neon_tts_plugin_coqui import CoquiTTS | |
LANGUAGES = list(CoquiTTS.langs.keys()) | |
coquiTTS = CoquiTTS() | |
def tts(text: str, language: str): | |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp: | |
coquiTTS.get_tts(text, fp, speaker = {"language" : language}) |
This file contains hidden or 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 tempfile | |
from neon_tts_plugin_coqui import CoquiTTS | |
LANGUAGES = list(CoquiTTS.langs.keys()) | |
coquiTTS = CoquiTTS() | |
def tts(text: str): | |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp: | |
coquiTTS.get_tts(text, fp, speaker = {"language" : "en"}) | |
return fp.name |
This file contains hidden or 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 matplotlib.pyplot as plt | |
from sklearn.cluster import KMeans | |
from sklearn.datasets import make_blobs | |
# Generate synthetic data for clustering | |
data, _ = make_blobs(n_samples=300, centers=4, random_state=42) | |
# Create a K-Means clustering model | |
kmeans = KMeans(n_clusters=4, random_state=0) |
This file contains hidden or 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 matplotlib.pyplot as plt | |
from sklearn.cluster import KMeans | |
from sklearn.datasets import make_blobs | |
class KMeansClustering: | |
def __init__(self, n_clusters=3, random_state=0): | |
""" | |
Initialize the KMeansClustering instance. |
This file contains hidden or 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 matplotlib.pyplot as plt | |
from sklearn.decomposition import PCA | |
class DimensionalityReductionPCA: | |
def __init__(self, n_components=None): | |
""" | |
Initialize the DimensionalityReductionPCA instance. | |
Parameters: |
This file contains hidden or 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 matplotlib.pyplot as plt | |
from sklearn.ensemble import IsolationForest | |
class AnomalyDetectionIsolationForest: | |
def __init__(self, contamination=0.05, random_state=None): | |
""" | |
Initialize the AnomalyDetectionIsolationForest instance. | |
Parameters: |
This file contains hidden or 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 matplotlib.pyplot as plt | |
import tensorflow as tf | |
from tensorflow.keras.layers import Dense | |
from tensorflow.keras.models import Sequential | |
class SimpleGAN: | |
def __init__(self, input_dim, generator_output_dim, discriminator_output_dim): | |
self.input_dim = input_dim | |
self.generator_output_dim = generator_output_dim |
This file contains hidden or 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 matplotlib.pyplot as plt | |
import tensorflow as tf | |
from tensorflow.keras.layers import Input, Dense, Lambda | |
from tensorflow.keras.models import Model | |
from tensorflow.keras.losses import mse | |
from tensorflow.keras import backend as K | |
class SimpleVAE: | |
def __init__(self, input_dim, latent_dim): |
This file contains hidden or 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.feature_extraction.text import CountVectorizer | |
from sklearn.decomposition import LatentDirichletAllocation | |
class LDATopicModel: | |
def __init__(self, n_topics=5, max_features=1000): | |
self.n_topics = n_topics | |
self.max_features = max_features | |
self.vectorizer = CountVectorizer(max_features=self.max_features, stop_words='english') |
OlderNewer