如果语句不显示else结果

时间:2019-03-28 04:22:38

标签: php laravel laravel-5

我的代码的else部分未显示在我的laravel刀片中。我需要显示该语句的else部分。当前,如果if语句为false,则该按钮会丢失。

import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import  RandomForestClassifier
from sklearn import metrics

df1=pd.read_csv('sample.csv')

X=df1.drop(['lable'], axis=1)  # Features
y=df1['lable']  # Labels
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3,random_state=5)

clf=RandomForestClassifier(random_state = 42, class_weight="balanced")
clf.fit(X_train,y_train)
y_pred=clf.predict(X_test)
print("Accuracy:",metrics.accuracy_score(y_test, y_pred))

2 个答案:

答案 0 :(得分:1)

from sympy.printing.theanocode import theano_function
import sympy as sp
import numpy as np

x, y, z = sp.symbols('x y z')
f = sp.sin(x)*sp.cos(y)*sp.sin(z) + sp.sin(4*(x - y**2*sp.sin(z)))
xg, yg, zg = np.mgrid[0:1:50*1j, 0:1:50*1j, 0:1:50*1j]

theano_f = theano_function([x, y, z], [f], dims={x: 3, y: 3, z: 3})

答案 1 :(得分:0)

  • 第一种方法
@auth
    @forelse($quote->userLike as $like)
            @if($like->pivot->user_id == $id) //passing user  id from controller here
            <li class="list-inline-item">
                <form  method="POST" action="{{route('likequote')}}" class="likequote">
                    @csrf
                    <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='{{$quote->id}}'>
                    <button type="submit" class="btn btn-danger shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
                </form>
            </li>
            @endif
    @empty
    <li class="list-inline-item">
        <form  method="POST" action="{{route('likequote')}}" class="likequote">
            @csrf
            <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='{{$quote->id}}'>
            <button type="submit" class="btn btn-primary shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
        </form>
    </li>
    @endforelse
@endauth
  • 第二
@auth
    @if(!empty($quote->userLike) && count($quote->userLike)>0)
        @foreach($quote->userLike as $like)
            @if($like->pivot->user_id == $id) //passing user  id from controller here
            <li class="list-inline-item">
                <form  method="POST" action="{{route('likequote')}}" class="likequote">
                    @csrf
                    <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='{{$quote->id}}'>
                    <button type="submit" class="btn btn-danger shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
                </form>
            </li>
            @endif
        @endforeach 
    @else
    <li class="list-inline-item">
        <form  method="POST" action="{{route('likequote')}}" class="likequote">
            @csrf
            <input type="hidden" class="form-control col-md-4" name="likequote" id="likequote" value='{{$quote->id}}'>
            <button type="submit" class="btn btn-primary shadow-lg " id="savelike"><i class="fas fa-heart"></button></i>
        </form>
    </li>
    @endif  
@endauth