Views
No views yet
transformers model — it's a scikit-learn/XGBoost pipeline:linguistic_feature_columns.pkl) and fed to an XGBClassifier.hybrid_xgb.pkl — the trained XGBClassifier (500 estimators)tfidf_vectorizer.pkl — fitted TfidfVectorizer (char, ngram_range=(2,5), max_features=20000)linguistic_feature_columns.pkl — ordered list of the 13 linguistic feature names0 = Human-written, 1 = AI-generated.farasapy Python package).1from huggingface_hub import hf_hub_download
2import joblib, numpy as np
3
4repo = "nawaf11570/arabic-ai-hybrid-xgboost"
5model = joblib.load(hf_hub_download(repo, "hybrid_xgb.pkl"))
6vectorizer = joblib.load(hf_hub_download(repo, "tfidf_vectorizer.pkl"))
7feature_columns = joblib.load(hf_hub_download(repo, "linguistic_feature_columns.pkl"))
8
9# see linguistic_features.py in the GitHub repo for extract_linguistic_features()
10text = "هذا نص تجريبي لاختبار النموذج."
11tfidf_vec = vectorizer.transform([text]).toarray()
12ling_feats = extract_linguistic_features(text) # dict of the 13 features
13ling_vec = np.array([[ling_feats[c] for c in feature_columns]])
14
15x = np.hstack([tfidf_vec, ling_vec])
16proba = model.predict_proba(x)[0]
17print("AI-generated" if proba.argmax() == 1 else "Human-written", proba.max())scripts/predict_hybrid.py in the GitHub repo.