Run this model with HF Jobs
Run harshiv/placement on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/harshiv/placement. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/harshiv/placement on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use harshiv/placement with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use harshiv/placement with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("harshiv/placement", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
Upload api.py
Browse files12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970import numpy as npimport pandas as pdimport torchimport torch.nn as nnimport torch.optim as optimfrom sklearn.model_selection import train_test_splitfrom sklearn.metrics import accuracy_score
class PlacementModel(nn.Module): def __init__(self, input_size, hidden_size, output_size): super(PlacementModel, self).__init__() self.fc1 = nn.Linear(input_size, hidden_size) self.fc2 = nn.Linear(hidden_size, output_size)
def forward(self, x): x = torch.relu(self.fc1(x)) x = self.fc2(x) return x
# Load and preprocess datadf = pd.read_csv("Placement (2).csv")df = df.drop(columns=["sl_no","stream","ssc_p","ssc_b","hsc_p","hsc_b","etest_p"])df['internship'] = df['internship'].map({'Yes':1,'No':0})df['status'] = df['status'].map({'Placed':1,'Not Placed':0})
X_fullstk = df.drop(['status','management','leadership','communication','sales'], axis=1)y = df['status']
X_train_fullstk, X_test_fullstk, y_train, y_test = train_test_split(X_fullstk, y, test_size=0.20, random_state=42)
# Define model hyperparametersinput_size = X_fullstk.shape[1]hidden_size = 128output_size = 2learning_rate = 0.01epochs = 100
# Initialize modelmodel = PlacementModel(input_size, hidden_size, output_size)criterion = nn.CrossEntropyLoss()optimizer = optim.Adam(model.parameters(), lr=learning_rate)
# Train modelfor epoch in range(epochs): inputs = torch.tensor(X_train_fullstk.values, dtype=torch.float32) labels = torch.tensor(y_train.values, dtype=torch.long)
optimizer.zero_grad()
outputs = model(inputs) loss = criterion(outputs, labels) loss.backward() optimizer.step()
if epoch % 10 == 0: print(f'Epoch [{epoch+1}/{epochs}], Loss: {loss.item():.4f}')
# Evaluate modelwith torch.no_grad(): inputs = torch.tensor(X_test_fullstk.values, dtype=torch.float32) labels = torch.tensor(y_test.values, dtype=torch.long)
outputs = model(inputs) _, predicted = torch.max(outputs.data, 1) accuracy = accuracy_score(labels, predicted)
print(f'Test Accuracy: {accuracy:.4f}')
# Save modeltorch.save(model.state_dict(), 'placement_model.pth')api.pyAdded+70