Code
include("../utils.jl")
import Plots:scatter!,contourf
import MLJ:predict,predict_mode,measures
using Plots, MLJ, CSV, DataFrames
using CatBoost.MLJCatBoostInterface
dataset 参见 clustering-exercises dataset
include("../utils.jl")
import Plots:scatter!,contourf
import MLJ:predict,predict_mode,measures
using Plots, MLJ, CSV, DataFrames
using CatBoost.MLJCatBoostInterface
=load_csv("basic1")
df=df[:,:color]|>levels|>length # 类别
cat= unpack(df, ==(:color), rng=123);
ytrain, Xtrain first(df,10)
Row | x | y | color |
---|---|---|---|
Float64 | Float64 | Int64 | |
1 | 79.4083 | 152.834 | 0 |
2 | 98.0463 | 186.911 | 0 |
3 | 240.579 | 48.4737 | 1 |
4 | 109.687 | 277.946 | 0 |
5 | 249.626 | 229.753 | 1 |
6 | 100.785 | 281.983 | 0 |
7 | 235.33 | 109.54 | 1 |
8 | 262.352 | 64.5746 | 1 |
9 | 76.5589 | 204.296 | 0 |
10 | 245.558 | 134.502 | 1 |
= CatBoostClassifier(iterations=2,learning_rate=0.20)
catboost = machine(catboost, Xtrain, ytrain;scitype_check_level=0)|>fit!
mach =boundary_data(df) # boudary data and xtest
tx,ty,xtest= predict_mode(mach, xtest)[:,1]|>Array ytest
[ Info: Training machine(CatBoostClassifier(iterations = 2, …), …).
40000-element Vector{Int64}:
0
0
0
0
0
0
0
0
0
0
0
0
0
⋮
3
3
3
3
3
3
3
3
3
3
3
3
contourf(tx,ty,ytest,levels=cat,color=cgrad(:redsblues),alpha=0.7)
=scatter!(df[:,:x],df[:,:y],group=df[:,:color],label=false,ms=3,alpha=0.3) p1