-1

私はこれらの2つのクラスを持っています

public class Iris_Setosa {

private double sepal_length;
private double sepal_width;
private double petal_length;
private double petal_width;


//Constractor
public Iris_Setosa(double s_length,double s_width,double p_length,double p_width)
{
    this.sepal_length=s_length;
    this.sepal_width=s_width;
    this.petal_length=p_length;
    this.petal_width=p_width;
}

public double sepal_length()
{
    return this.sepal_length;
}

public double sepal_width()
{
    return this.sepal_width;
}

public double petal_length()
{
    return this.petal_length;
}

public double petal_width()
{
    return this.petal_width;
}
}

public class Iris_Versicolour {
private double sepal_length;
private double sepal_width;
private double petal_length;
private double petal_width;


//Constractor
public Iris_Versicolour(double s_length,double s_width,double p_length,double p_width)
{
    this.sepal_length=s_length;
    this.sepal_width=s_width;
    this.petal_length=p_length;
    this.petal_width=p_width;

}


public double sepal_length()
{
    return this.sepal_length;
}

public double sepal_width()
{
    return this.sepal_width;
}

public double petal_length()
{
    return this.petal_length;
}

public double petal_width()
{
    return this.petal_width;
}
}

2 つのベクトルを定義し、データを設定しました。

Vector <Iris_Setosa> I_Setosa = new Vector <Iris_Setosa>();
Vector <Iris_Versicolour> I_Versicolour = new Vector <Iris_Versicolouלr>();
//data
I_Setosa.add(new Iris_Setosa (4.6,3.4,1.4,0.3));
I_Setosa.add(new Iris_Setosa (5.4,3.9,1.7,0.4));
I_Versicolour.add(new Iris_Versicolour(6.4,3.2,4.5,1.5));
I_Versicolour.add(new Iris_Versicolour(6.9,3.1,4.9,1.5));
.......

空間内の点として扱うために、これら 2 つのベクトルを一緒に分類するにはどうすればよいでしょうか?

4

1 に答える 1

0

これで、新しいサンプルs = [4.7, 3.3, 1.5, 0.5] が得られました。

最初の簡単で汚れた方法は、1NN (K = 1 の K 最近隣人) です。この場合、sと 4 つの点のそれぞれの間のユークリッド距離を計算します。
4 つのケースの距離が 5.93、6.40、6.94、および 7.12 であることがわかります。この場合、最初のトレーニング サンプルが最も近いため、I_Setosa の予測につながるため、最初のトレーニング サンプルを選択します。具体的には、Iris_Setosa (4.6,3.4,1.4,0.3) に最も類似していました。

お役に立てれば

于 2013-06-11T21:22:57.310 に答える