Skip to content

Commit

Permalink
cleaned up
Browse files Browse the repository at this point in the history
  • Loading branch information
behrica committed Oct 3, 2024
1 parent 8449f5b commit 87ce9c4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 70 deletions.
5 changes: 1 addition & 4 deletions src/scicloj/ml/xgboost/model.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
[tech.v3.tensor :as dtt]
[tech.v3.dataset.tensor :as ds-tens]
[tech.v3.dataset :as ds]
[clojure.set :as set])
(:import [java.io ByteArrayInputStream ByteArrayOutputStream
ObjectOutputStream ObjectInputStream
InputStream OutputStream]))
[clojure.set :as set]))



Expand Down
67 changes: 1 addition & 66 deletions test/scicloj/ml/xgboost_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
[scicloj.ml.smile.nlp :as nlp]
[scicloj.ml.xgboost]
[scicloj.metamorph.ml :as ml]
[scicloj.metamorph.ml.metrics :as metrics]
[scicloj.metamorph.ml.loss :as loss]
[scicloj.metamorph.ml.verify :as verify]
[tech.v3.dataset.categorical :as ds-cat]
[scicloj.metamorph.ml.gridsearch :as ml-gs]
[scicloj.metamorph.ml.classification :as ml-class]))
[scicloj.metamorph.ml.gridsearch :as ml-gs]))



Expand Down Expand Up @@ -184,66 +182,3 @@



(comment
;; not working
(def reviews

(->
(ds/->dataset "test/data/reviews.csv.gz" {:key-fn keyword})
(ds/select-columns [:Text :Score])
(nlp/count-vectorize :Text :bow nlp/default-text->bow)
(nb/bow->SparseArray :bow :bow-sparse #(nlp/->vocabulary-top-n % 100))
(ds/drop-columns [:Text :bow])
(ds/update-column :Score
(fn [col]
(let [val-map {0 :c0
1 :c1
2 :c2
3 :c3
4 :c4
5 :c5}]
(dtype/emap val-map :keyword col))))
(ds/categorical->number cf/categorical)
(ds-mod/set-inference-target :Score)))



(def feature-ds
(cf/feature reviews))

(def target-ds
(cf/target reviews))

(require '[scicloj.ml.xgboost])
(def d
(scicloj.ml.xgboost/sparse-feature->dmatrix
feature-ds
target-ds
:bow-sparse
1000
))
(def trained-model
(ml/train reviews {:model-type :xgboost/classification
:sparse-column :bow-sparse
:n-sparse-columns 1000
;:silent 0
;:round 1
;:eval-metric "merror"
;:watches {:test-ds (ds/sample reviews 10)}
}))



(def prediction
(:Score
(ml/predict reviews trained-model)))

(metrics/accuracy (:Score reviews) prediction)

(def folds
(ml/train-k-fold reviews {:model-type :xgboost/classification
:sparse-column :bow-sparse}))


(ml/explain folds)
)

0 comments on commit 87ce9c4

Please sign in to comment.