Skip to content

Instantly share code, notes, and snippets.

View lucifermorningstar1305's full-sized avatar
👨‍💻
Always Coding

Adityam Ghosh lucifermorningstar1305

👨‍💻
Always Coding
View GitHub Profile
@lucifermorningstar1305
lucifermorningstar1305 / FlashCard.jsx
Created January 31, 2024 13:00
Implementation of the FlashCard excercise
import React, { useState } from "react";
const FlashCard = ({ question }) => {
const [isSelected, setSelected] = useState(false);
const handleClick = () => {
setSelected((s) => !s);
};
const handleMouseLeave = () => {
@lucifermorningstar1305
lucifermorningstar1305 / FlashCards.jsx
Created January 31, 2024 12:59
Implementation of the FlashCard exercise
import React from "react";
import FlashCard from "./FlashCard";
const FlashCards = ({ questions }) => {
return (
<div className="flashcards">
{questions.map((question) => (
<FlashCard question={question} key={question.id} />
))}
</div>
@lucifermorningstar1305
lucifermorningstar1305 / pg_no_gradient_mcar.py
Last active December 24, 2023 07:04
Policy Gradient method for Mountain Car Continuous with Evolution Algorithm
"""
This is an implementation of the Hill Climbing algorithm for the MountainCar-v1 (Continuous Spaces) environment.
No gradient ascent is performed in this script.
"""
from typing import Callable, Dict, List, Any, Tuple, Optional
import numpy as np
import matplotlib.pyplot as plt
import torch
@lucifermorningstar1305
lucifermorningstar1305 / evaluate_model.jl
Created July 29, 2022 14:03
Evaluating model performance in Julia
yhat = MLJ.predict(tree, coerce(X[test, :], Continuous))
# To calculate the log-loss or binary cross entropy of our classification algorithm
println("Log-Loss on the Test Set : $(log_loss(yhat, coerce(y[test], Multiclass)) |> mean)")
# To calculate the accuracy of our classification algorithm
println("Accuracy on the Test Set : $(accuracy(mode.(yhat), coerce(y[test], Multiclass)))")
# To generate the Confusion Matrix of our Classification algorithm
ConfusionMatrix()(mode.(yhat), coerce(y[test], Multiclass))
@lucifermorningstar1305
lucifermorningstar1305 / fit_model.jl
Created July 29, 2022 14:00
fit a model in julia
MLJ.fit!(tree, rows=train)
@lucifermorningstar1305
lucifermorningstar1305 / split_data.jl
Created July 29, 2022 13:50
Partitioning data into train and test sets
rng = StableRNG(42)
train, test = partition(eachindex(y), 0.85, shuffle=true, rng=rng);
tree = machine(tree_model, coerce(X, Continuous), coerce(y, Multiclass))
DecisionTreeClassifier = @load DecisionTreeClassifier pkg=DecisionTree
tree_model = DecisionTreeClassifier()
@lucifermorningstar1305
lucifermorningstar1305 / def_x_y.jl
Created July 29, 2022 13:09
Define the X and y
X, y = tfidf_mat, df[:, :Category]
@lucifermorningstar1305
lucifermorningstar1305 / build_tfidf.jl
Created July 29, 2022 12:40
Build the TF-IDF matrix of the text data
m = DocumentTermMatrix(crps)
tfidf_mat = tf_idf(m)