// Predict perform classification on an array of test vectors X
Predict perform classification on an array of test vectors X
// Predict perform classification on an array of test vectors X
func (m *BaseNB) Predict(X mat.Matrix, Y mat.Mutable) *mat.Dense {
	Ypred := base.ToDense(Y)
	if Y == mat.Mutable(nil) {
		NSamples, _ := X.Dims()
		Ypred = mat.NewDense(NSamples, m.GetNOutputs(), nil)
	}
	NSamples, NFeatures := X.Dims()
	row := make([]float64, NFeatures)
	jll := make([]float64, len(m.Classes))
	for i := 0; i < NSamples; i++ {
		mat.Row(row, i, X)
		m.jointLogLikelihood(jll, row)
		index := floats.MaxIdx(jll)
		Ypred.Set(i, 0, m.Classes[index])
	}
	return base.FromDense(Y, Ypred)
}
func ( m * BaseNB ) Predict ( X mat . Matrix , Y mat . Mutable ) * mat . Dense { Ypred := base . ToDense ( Y ) if Y == mat . Mutable ( nil ) { NSamples , _ := X . Dims ( ) Ypred = mat . NewDense ( NSamples , m . GetNOutputs ( ) , nil ) } NSamples , NFeatures := X . Dims ( ) row := make ( [ ] float64 , NFeatures ) jll := make ( [ ] float64 , len ( m . Classes ) ) for i := 0 ; i < NSamples ; i ++ { mat . Row ( row , i , X ) m . jointLogLikelihood ( jll , row ) index := floats . MaxIdx ( jll ) Ypred . Set ( i , 0 , m . Classes [ index ] ) } return base . FromDense ( Y , Ypred ) }
Predict perform classification on an array of test vectors X
Predict perform classification on an array of test vectors X
//jll = self._joint_log_likelihood(X) //return self.classes_[np.argmax(jll, axis=1)]