Skip to content

Instantly share code, notes, and snippets.

View fuwiak's full-sized avatar
💭
I may be slow to respond.

Pawel fuwiak

💭
I may be slow to respond.
View GitHub Profile
@fuwiak
fuwiak / forecast.py
Last active February 5, 2024 21:00
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from statsmodels.tsa.holtwinters import SimpleExpSmoothing
from sklearn.metrics import mean_squared_error
# Assuming df_list[100]['y_lag'] is your time series data
# Ensure it's a pandas Series for compatibility with SimpleExpSmoothing
data = pd.Series(df_list[100]['y_lag'])
import requests
import pandas as pd
number_of_pages = 100
#number_of_ads = number_of_pages * per_page
job_title = ["'Data Analyst' and 'data scientist'"]
for job in job_title:
class Vector2D:
def __init__(self, x, y):
self.x = x
self.y = y
def __str__(self):
return f"Vector2D({self.x}, {self.y})"
def __add__(self, other):
if isinstance(other, Vector2D):
import os
import sys
# Pobierz aktualną ścieżkę do bieżącego pliku
current_path = os.path.dirname(os.path.abspath(__file__))
# Dodaj dwa poziomy wyżej do ścieżki
two_levels_up = os.path.abspath(os.path.join(current_path, "../../"))
# Dodaj nową ścieżkę do sys.path, aby Python mógł znaleźć moduł
def compare_algorithms2df(MLA, X_train, X_test, y_train, y_test, sorted_by_measure='accuracy'):
#show grid with compared results - accuracy, recall, ppv, f1-measure, mcc
MLA_columns = []
MLA_compare = pd.DataFrame(columns = MLA_columns)
row_index = 0
for alg in MLA:
import pyspark
#import udf
from pyspark.sql.functions import udf
from pyspark.sql.types import BooleanType
from shapely.geometry import Point, Polygon
# Create a SparkContext
sc = pyspark.SparkContext()
class IP:
def __init__(self, ip_address, filename):
self.ip_address = ip_address
self.filename = filename
def random_ip_nonlocal(self):
lista_ip_non_local = []
for i in range(self.ip_address):
ip = ""
p.generate_ips()
(['127.247.9.229'], ['124.72.36.132'])
function p = predict(theta, X)
%PREDICT Predict whether the label is 0 or 1 using learned logistic
%regression parameters theta
% p = PREDICT(theta, X) computes the predictions for X using a
% threshold at 0.5 (i.e., if sigmoid(theta'*x) >= 0.5, predict 1)
m = size(X, 1); % Number of training examples
% You need to return the following variables correctly
p = zeros(m, 1);
function [J, grad] = costFunction(theta, X, y)
%COSTFUNCTION Compute cost and gradient for logistic regression
% J = COSTFUNCTION(theta, X, y) computes the cost of using theta as the
% parameter for logistic regression and the gradient of the cost
% w.r.t. to the parameters.
% Initialize some useful values
m = length(y); % number of training examples
% You need to return the following variables correctly