Skip to content

Instantly share code, notes, and snippets.

@stevelukis
stevelukis / main.css
Created July 25, 2023 06:36
main.css
html, body {
margin: 0;
padding: 0;
height: 100vh;
width: 100%;
box-sizing: border-box;
font-family: Arial, sans-serif;
}
.center {
@stevelukis
stevelukis / index.html
Created July 25, 2023 05:23
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Color Palette Generator</title>
<link
rel="stylesheet"
href="{{ url_for('static', filename='css/main.css') }}"
/>
<script src="https://unpkg.com/@popperjs/core@2"></script>
@stevelukis
stevelukis / HomePage.tsx
Created May 1, 2023 06:38
Infinite Scroll in React (Typescript + React Query)
import React from "react";
import { Container, SimpleGrid, Text } from "@chakra-ui/react";
import ProductCard from "./ProductCard";
import useProducts from "../hooks";
import InfiniteScroll from "react-infinite-scroll-component";
const HomePage = () => {
const { data, fetchNextPage, hasNextPage } = useProducts();
return (
@stevelukis
stevelukis / ProductCard.tsx
Created May 1, 2023 06:37
Infinite Scroll in React (Typescript + React Query)
import React from "react";
import {
AspectRatio,
Card,
CardBody,
Heading,
Image,
Stack,
Text,
} from "@chakra-ui/react";
@stevelukis
stevelukis / hooks.ts
Last active May 1, 2023 06:25
Infinite Scroll in React (Typescript + React Query)
import axios from "axios";
import { useInfiniteQuery } from "@tanstack/react-query";
export interface Product {
id: number;
title: string;
price: number;
images: string[];
}
final_model = grid_search.best_estimator_
X_test = test_set.drop("charges", axis=1)
y_test = test_set["charges"].copy()
X_test_prepared = full_pipeline.transform(X_test)
final_predictions = final_model.predict(X_test_prepared)
final_rmse = np.sqrt(mean_squared_error(y_test, final_predictions))
print(final_rmse)
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import GridSearchCV
param_grid = [
{'n_estimators': [3, 10, 30], 'max_features': [2, 4, 6, 8]},
{'bootstrap': [False], 'n_estimators': [3, 10], 'max_features': [2, 3, 4]}
]
forest_reg = RandomForestRegressor()
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_squared_error
forest_reg = RandomForestRegressor()
forest_reg.fit(insurance_prepared, insurance_labels)
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler, OneHotEncoder
from sklearn.compose import ColumnTransformer
num_attrs = ["age", "bmi", "children"]
cat_attrs = ["sex", "smoker", "region"]
num_pipeline = Pipeline([
('std_scaler', StandardScaler())
])
insurance = train_set.drop("charges", axis=1)
insurance_labels = train_set["charges"].copy()